babylon.module.d.ts 4.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391
  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. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module "babylonjs/Offline/IOfflineProvider" {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module "babylonjs/Misc/observable" {
  4199. import { Nullable } from "babylonjs/types";
  4200. /**
  4201. * A class serves as a medium between the observable and its observers
  4202. */
  4203. export class EventState {
  4204. /**
  4205. * Create a new EventState
  4206. * @param mask defines the mask associated with this state
  4207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4208. * @param target defines the original target of the state
  4209. * @param currentTarget defines the current target of the state
  4210. */
  4211. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4212. /**
  4213. * Initialize the current event state
  4214. * @param mask defines the mask associated with this state
  4215. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4216. * @param target defines the original target of the state
  4217. * @param currentTarget defines the current target of the state
  4218. * @returns the current event state
  4219. */
  4220. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4221. /**
  4222. * An Observer can set this property to true to prevent subsequent observers of being notified
  4223. */
  4224. skipNextObservers: boolean;
  4225. /**
  4226. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4227. */
  4228. mask: number;
  4229. /**
  4230. * The object that originally notified the event
  4231. */
  4232. target?: any;
  4233. /**
  4234. * The current object in the bubbling phase
  4235. */
  4236. currentTarget?: any;
  4237. /**
  4238. * This will be populated with the return value of the last function that was executed.
  4239. * If it is the first function in the callback chain it will be the event data.
  4240. */
  4241. lastReturnValue?: any;
  4242. }
  4243. /**
  4244. * Represent an Observer registered to a given Observable object.
  4245. */
  4246. export class Observer<T> {
  4247. /**
  4248. * Defines the callback to call when the observer is notified
  4249. */
  4250. callback: (eventData: T, eventState: EventState) => void;
  4251. /**
  4252. * Defines the mask of the observer (used to filter notifications)
  4253. */
  4254. mask: number;
  4255. /**
  4256. * Defines the current scope used to restore the JS context
  4257. */
  4258. scope: any;
  4259. /** @hidden */
  4260. _willBeUnregistered: boolean;
  4261. /**
  4262. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4263. */
  4264. unregisterOnNextCall: boolean;
  4265. /**
  4266. * Creates a new observer
  4267. * @param callback defines the callback to call when the observer is notified
  4268. * @param mask defines the mask of the observer (used to filter notifications)
  4269. * @param scope defines the current scope used to restore the JS context
  4270. */
  4271. constructor(
  4272. /**
  4273. * Defines the callback to call when the observer is notified
  4274. */
  4275. callback: (eventData: T, eventState: EventState) => void,
  4276. /**
  4277. * Defines the mask of the observer (used to filter notifications)
  4278. */
  4279. mask: number,
  4280. /**
  4281. * Defines the current scope used to restore the JS context
  4282. */
  4283. scope?: any);
  4284. }
  4285. /**
  4286. * Represent a list of observers registered to multiple Observables object.
  4287. */
  4288. export class MultiObserver<T> {
  4289. private _observers;
  4290. private _observables;
  4291. /**
  4292. * Release associated resources
  4293. */
  4294. dispose(): void;
  4295. /**
  4296. * Raise a callback when one of the observable will notify
  4297. * @param observables defines a list of observables to watch
  4298. * @param callback defines the callback to call on notification
  4299. * @param mask defines the mask used to filter notifications
  4300. * @param scope defines the current scope used to restore the JS context
  4301. * @returns the new MultiObserver
  4302. */
  4303. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4304. }
  4305. /**
  4306. * The Observable class is a simple implementation of the Observable pattern.
  4307. *
  4308. * 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.
  4309. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4310. * 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).
  4311. * 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.
  4312. */
  4313. export class Observable<T> {
  4314. private _observers;
  4315. private _eventState;
  4316. private _onObserverAdded;
  4317. /**
  4318. * Creates a new observable
  4319. * @param onObserverAdded defines a callback to call when a new observer is added
  4320. */
  4321. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4322. /**
  4323. * Create a new Observer with the specified callback
  4324. * @param callback the callback that will be executed for that Observer
  4325. * @param mask the mask used to filter observers
  4326. * @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.
  4327. * @param scope optional scope for the callback to be called from
  4328. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4329. * @returns the new observer created for the callback
  4330. */
  4331. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4332. /**
  4333. * Create a new Observer with the specified callback and unregisters after the next notification
  4334. * @param callback the callback that will be executed for that Observer
  4335. * @returns the new observer created for the callback
  4336. */
  4337. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4338. /**
  4339. * Remove an Observer from the Observable object
  4340. * @param observer the instance of the Observer to remove
  4341. * @returns false if it doesn't belong to this Observable
  4342. */
  4343. remove(observer: Nullable<Observer<T>>): boolean;
  4344. /**
  4345. * Remove a callback from the Observable object
  4346. * @param callback the callback to remove
  4347. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4348. * @returns false if it doesn't belong to this Observable
  4349. */
  4350. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4351. private _deferUnregister;
  4352. private _remove;
  4353. /**
  4354. * Notify all Observers by calling their respective callback with the given data
  4355. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4356. * @param eventData defines the data to send to all observers
  4357. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4358. * @param target defines the original target of the state
  4359. * @param currentTarget defines the current target of the state
  4360. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4361. */
  4362. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4363. /**
  4364. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4365. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4366. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4367. * and it is crucial that all callbacks will be executed.
  4368. * The order of the callbacks is kept, callbacks are not executed parallel.
  4369. *
  4370. * @param eventData The data to be sent to each callback
  4371. * @param mask is used to filter observers defaults to -1
  4372. * @param target defines the callback target (see EventState)
  4373. * @param currentTarget defines he current object in the bubbling phase
  4374. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4375. */
  4376. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4377. /**
  4378. * Notify a specific observer
  4379. * @param observer defines the observer to notify
  4380. * @param eventData defines the data to be sent to each callback
  4381. * @param mask is used to filter observers defaults to -1
  4382. */
  4383. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4384. /**
  4385. * Gets a boolean indicating if the observable has at least one observer
  4386. * @returns true is the Observable has at least one Observer registered
  4387. */
  4388. hasObservers(): boolean;
  4389. /**
  4390. * Clear the list of observers
  4391. */
  4392. clear(): void;
  4393. /**
  4394. * Clone the current observable
  4395. * @returns a new observable
  4396. */
  4397. clone(): Observable<T>;
  4398. /**
  4399. * Does this observable handles observer registered with a given mask
  4400. * @param mask defines the mask to be tested
  4401. * @return whether or not one observer registered with the given mask is handeled
  4402. **/
  4403. hasSpecificMask(mask?: number): boolean;
  4404. }
  4405. }
  4406. declare module "babylonjs/Misc/filesInputStore" {
  4407. /**
  4408. * Class used to help managing file picking and drag'n'drop
  4409. * File Storage
  4410. */
  4411. export class FilesInputStore {
  4412. /**
  4413. * List of files ready to be loaded
  4414. */
  4415. static FilesToLoad: {
  4416. [key: string]: File;
  4417. };
  4418. }
  4419. }
  4420. declare module "babylonjs/Engines/constants" {
  4421. /** Defines the cross module used constants to avoid circular dependncies */
  4422. export class Constants {
  4423. /** Defines that alpha blending is disabled */
  4424. static readonly ALPHA_DISABLE: number;
  4425. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4426. static readonly ALPHA_ADD: number;
  4427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4428. static readonly ALPHA_COMBINE: number;
  4429. /** Defines that alpha blending to DEST - SRC * DEST */
  4430. static readonly ALPHA_SUBTRACT: number;
  4431. /** Defines that alpha blending to SRC * DEST */
  4432. static readonly ALPHA_MULTIPLY: number;
  4433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4434. static readonly ALPHA_MAXIMIZED: number;
  4435. /** Defines that alpha blending to SRC + DEST */
  4436. static readonly ALPHA_ONEONE: number;
  4437. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4438. static readonly ALPHA_PREMULTIPLIED: number;
  4439. /**
  4440. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4441. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4442. */
  4443. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4444. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4445. static readonly ALPHA_INTERPOLATE: number;
  4446. /**
  4447. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4448. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4449. */
  4450. static readonly ALPHA_SCREENMODE: number;
  4451. /** Defines that the ressource is not delayed*/
  4452. static readonly DELAYLOADSTATE_NONE: number;
  4453. /** Defines that the ressource was successfully delay loaded */
  4454. static readonly DELAYLOADSTATE_LOADED: number;
  4455. /** Defines that the ressource is currently delay loading */
  4456. static readonly DELAYLOADSTATE_LOADING: number;
  4457. /** Defines that the ressource is delayed and has not started loading */
  4458. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4460. static readonly NEVER: number;
  4461. /** 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 */
  4462. static readonly ALWAYS: number;
  4463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4464. static readonly LESS: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4466. static readonly EQUAL: number;
  4467. /** 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 */
  4468. static readonly LEQUAL: number;
  4469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4470. static readonly GREATER: number;
  4471. /** 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 */
  4472. static readonly GEQUAL: number;
  4473. /** 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 */
  4474. static readonly NOTEQUAL: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be kept */
  4476. static readonly KEEP: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4478. static readonly REPLACE: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4480. static readonly INCR: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4482. static readonly DECR: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4484. static readonly INVERT: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4486. static readonly INCR_WRAP: number;
  4487. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4488. static readonly DECR_WRAP: number;
  4489. /** Texture is not repeating outside of 0..1 UVs */
  4490. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4491. /** Texture is repeating outside of 0..1 UVs */
  4492. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4493. /** Texture is repeating and mirrored */
  4494. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4495. /** ALPHA */
  4496. static readonly TEXTUREFORMAT_ALPHA: number;
  4497. /** LUMINANCE */
  4498. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4499. /** LUMINANCE_ALPHA */
  4500. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4501. /** RGB */
  4502. static readonly TEXTUREFORMAT_RGB: number;
  4503. /** RGBA */
  4504. static readonly TEXTUREFORMAT_RGBA: number;
  4505. /** RED */
  4506. static readonly TEXTUREFORMAT_RED: number;
  4507. /** RED (2nd reference) */
  4508. static readonly TEXTUREFORMAT_R: number;
  4509. /** RG */
  4510. static readonly TEXTUREFORMAT_RG: number;
  4511. /** RED_INTEGER */
  4512. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4513. /** RED_INTEGER (2nd reference) */
  4514. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4515. /** RG_INTEGER */
  4516. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4517. /** RGB_INTEGER */
  4518. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4519. /** RGBA_INTEGER */
  4520. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4521. /** UNSIGNED_BYTE */
  4522. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4523. /** UNSIGNED_BYTE (2nd reference) */
  4524. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4525. /** FLOAT */
  4526. static readonly TEXTURETYPE_FLOAT: number;
  4527. /** HALF_FLOAT */
  4528. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4529. /** BYTE */
  4530. static readonly TEXTURETYPE_BYTE: number;
  4531. /** SHORT */
  4532. static readonly TEXTURETYPE_SHORT: number;
  4533. /** UNSIGNED_SHORT */
  4534. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4535. /** INT */
  4536. static readonly TEXTURETYPE_INT: number;
  4537. /** UNSIGNED_INT */
  4538. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4539. /** UNSIGNED_SHORT_4_4_4_4 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4541. /** UNSIGNED_SHORT_5_5_5_1 */
  4542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4543. /** UNSIGNED_SHORT_5_6_5 */
  4544. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4545. /** UNSIGNED_INT_2_10_10_10_REV */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4547. /** UNSIGNED_INT_24_8 */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4549. /** UNSIGNED_INT_10F_11F_11F_REV */
  4550. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4551. /** UNSIGNED_INT_5_9_9_9_REV */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4553. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4554. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4555. /** nearest is mag = nearest and min = nearest and mip = linear */
  4556. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4558. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4559. /** Trilinear is mag = linear and min = linear and mip = linear */
  4560. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4561. /** nearest is mag = nearest and min = nearest and mip = linear */
  4562. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4564. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4565. /** Trilinear is mag = linear and min = linear and mip = linear */
  4566. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4567. /** mag = nearest and min = nearest and mip = nearest */
  4568. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4569. /** mag = nearest and min = linear and mip = nearest */
  4570. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4571. /** mag = nearest and min = linear and mip = linear */
  4572. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4573. /** mag = nearest and min = linear and mip = none */
  4574. static readonly TEXTURE_NEAREST_LINEAR: number;
  4575. /** mag = nearest and min = nearest and mip = none */
  4576. static readonly TEXTURE_NEAREST_NEAREST: number;
  4577. /** mag = linear and min = nearest and mip = nearest */
  4578. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4579. /** mag = linear and min = nearest and mip = linear */
  4580. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4581. /** mag = linear and min = linear and mip = none */
  4582. static readonly TEXTURE_LINEAR_LINEAR: number;
  4583. /** mag = linear and min = nearest and mip = none */
  4584. static readonly TEXTURE_LINEAR_NEAREST: number;
  4585. /** Explicit coordinates mode */
  4586. static readonly TEXTURE_EXPLICIT_MODE: number;
  4587. /** Spherical coordinates mode */
  4588. static readonly TEXTURE_SPHERICAL_MODE: number;
  4589. /** Planar coordinates mode */
  4590. static readonly TEXTURE_PLANAR_MODE: number;
  4591. /** Cubic coordinates mode */
  4592. static readonly TEXTURE_CUBIC_MODE: number;
  4593. /** Projection coordinates mode */
  4594. static readonly TEXTURE_PROJECTION_MODE: number;
  4595. /** Skybox coordinates mode */
  4596. static readonly TEXTURE_SKYBOX_MODE: number;
  4597. /** Inverse Cubic coordinates mode */
  4598. static readonly TEXTURE_INVCUBIC_MODE: number;
  4599. /** Equirectangular coordinates mode */
  4600. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4601. /** Equirectangular Fixed coordinates mode */
  4602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4603. /** Equirectangular Fixed Mirrored coordinates mode */
  4604. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4605. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4606. static readonly SCALEMODE_FLOOR: number;
  4607. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4608. static readonly SCALEMODE_NEAREST: number;
  4609. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4610. static readonly SCALEMODE_CEILING: number;
  4611. /**
  4612. * The dirty texture flag value
  4613. */
  4614. static readonly MATERIAL_TextureDirtyFlag: number;
  4615. /**
  4616. * The dirty light flag value
  4617. */
  4618. static readonly MATERIAL_LightDirtyFlag: number;
  4619. /**
  4620. * The dirty fresnel flag value
  4621. */
  4622. static readonly MATERIAL_FresnelDirtyFlag: number;
  4623. /**
  4624. * The dirty attribute flag value
  4625. */
  4626. static readonly MATERIAL_AttributesDirtyFlag: number;
  4627. /**
  4628. * The dirty misc flag value
  4629. */
  4630. static readonly MATERIAL_MiscDirtyFlag: number;
  4631. /**
  4632. * The all dirty flag value
  4633. */
  4634. static readonly MATERIAL_AllDirtyFlag: number;
  4635. /**
  4636. * Returns the triangle fill mode
  4637. */
  4638. static readonly MATERIAL_TriangleFillMode: number;
  4639. /**
  4640. * Returns the wireframe mode
  4641. */
  4642. static readonly MATERIAL_WireFrameFillMode: number;
  4643. /**
  4644. * Returns the point fill mode
  4645. */
  4646. static readonly MATERIAL_PointFillMode: number;
  4647. /**
  4648. * Returns the point list draw mode
  4649. */
  4650. static readonly MATERIAL_PointListDrawMode: number;
  4651. /**
  4652. * Returns the line list draw mode
  4653. */
  4654. static readonly MATERIAL_LineListDrawMode: number;
  4655. /**
  4656. * Returns the line loop draw mode
  4657. */
  4658. static readonly MATERIAL_LineLoopDrawMode: number;
  4659. /**
  4660. * Returns the line strip draw mode
  4661. */
  4662. static readonly MATERIAL_LineStripDrawMode: number;
  4663. /**
  4664. * Returns the triangle strip draw mode
  4665. */
  4666. static readonly MATERIAL_TriangleStripDrawMode: number;
  4667. /**
  4668. * Returns the triangle fan draw mode
  4669. */
  4670. static readonly MATERIAL_TriangleFanDrawMode: number;
  4671. /**
  4672. * Stores the clock-wise side orientation
  4673. */
  4674. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4675. /**
  4676. * Stores the counter clock-wise side orientation
  4677. */
  4678. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4679. /**
  4680. * Nothing
  4681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4682. */
  4683. static readonly ACTION_NothingTrigger: number;
  4684. /**
  4685. * On pick
  4686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4687. */
  4688. static readonly ACTION_OnPickTrigger: number;
  4689. /**
  4690. * On left pick
  4691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4692. */
  4693. static readonly ACTION_OnLeftPickTrigger: number;
  4694. /**
  4695. * On right pick
  4696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4697. */
  4698. static readonly ACTION_OnRightPickTrigger: number;
  4699. /**
  4700. * On center pick
  4701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4702. */
  4703. static readonly ACTION_OnCenterPickTrigger: number;
  4704. /**
  4705. * On pick down
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_OnPickDownTrigger: number;
  4709. /**
  4710. * On double pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnDoublePickTrigger: number;
  4714. /**
  4715. * On pick up
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnPickUpTrigger: number;
  4719. /**
  4720. * On pick out.
  4721. * This trigger will only be raised if you also declared a OnPickDown
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnPickOutTrigger: number;
  4725. /**
  4726. * On long press
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnLongPressTrigger: number;
  4730. /**
  4731. * On pointer over
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_OnPointerOverTrigger: number;
  4735. /**
  4736. * On pointer out
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPointerOutTrigger: number;
  4740. /**
  4741. * On every frame
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnEveryFrameTrigger: number;
  4745. /**
  4746. * On intersection enter
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4750. /**
  4751. * On intersection exit
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnIntersectionExitTrigger: number;
  4755. /**
  4756. * On key down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnKeyDownTrigger: number;
  4760. /**
  4761. * On key up
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnKeyUpTrigger: number;
  4765. /**
  4766. * Billboard mode will only apply to Y axis
  4767. */
  4768. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4769. /**
  4770. * Billboard mode will apply to all axes
  4771. */
  4772. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4773. /**
  4774. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4775. */
  4776. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4777. /**
  4778. * Gets or sets base Assets URL
  4779. */
  4780. static readonly PARTICLES_BaseAssetsUrl: string;
  4781. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4782. * Test order :
  4783. * Is the bounding sphere outside the frustum ?
  4784. * If not, are the bounding box vertices outside the frustum ?
  4785. * It not, then the cullable object is in the frustum.
  4786. */
  4787. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4788. /** Culling strategy : Bounding Sphere Only.
  4789. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4790. * It's also less accurate than the standard because some not visible objects can still be selected.
  4791. * Test : is the bounding sphere outside the frustum ?
  4792. * If not, then the cullable object is in the frustum.
  4793. */
  4794. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4795. /** Culling strategy : Optimistic Inclusion.
  4796. * This in an inclusion test first, then the standard exclusion test.
  4797. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4798. * 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.
  4799. * Anyway, it's as accurate as the standard strategy.
  4800. * Test :
  4801. * Is the cullable object bounding sphere center in the frustum ?
  4802. * If not, apply the default culling strategy.
  4803. */
  4804. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4805. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4806. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4807. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4808. * 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.
  4809. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4810. * Test :
  4811. * Is the cullable object bounding sphere center in the frustum ?
  4812. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4813. */
  4814. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4815. /**
  4816. * No logging while loading
  4817. */
  4818. static readonly SCENELOADER_NO_LOGGING: number;
  4819. /**
  4820. * Minimal logging while loading
  4821. */
  4822. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4823. /**
  4824. * Summary logging while loading
  4825. */
  4826. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4827. /**
  4828. * Detailled logging while loading
  4829. */
  4830. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4831. }
  4832. }
  4833. declare module "babylonjs/Misc/domManagement" {
  4834. /**
  4835. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4836. * Babylon.js
  4837. */
  4838. export class DomManagement {
  4839. /**
  4840. * Checks if the window object exists
  4841. * @returns true if the window object exists
  4842. */
  4843. static IsWindowObjectExist(): boolean;
  4844. /**
  4845. * Extracts text content from a DOM element hierarchy
  4846. * @param element defines the root element
  4847. * @returns a string
  4848. */
  4849. static GetDOMTextContent(element: HTMLElement): string;
  4850. }
  4851. }
  4852. declare module "babylonjs/Misc/logger" {
  4853. /**
  4854. * Logger used througouht the application to allow configuration of
  4855. * the log level required for the messages.
  4856. */
  4857. export class Logger {
  4858. /**
  4859. * No log
  4860. */
  4861. static readonly NoneLogLevel: number;
  4862. /**
  4863. * Only message logs
  4864. */
  4865. static readonly MessageLogLevel: number;
  4866. /**
  4867. * Only warning logs
  4868. */
  4869. static readonly WarningLogLevel: number;
  4870. /**
  4871. * Only error logs
  4872. */
  4873. static readonly ErrorLogLevel: number;
  4874. /**
  4875. * All logs
  4876. */
  4877. static readonly AllLogLevel: number;
  4878. private static _LogCache;
  4879. /**
  4880. * Gets a value indicating the number of loading errors
  4881. * @ignorenaming
  4882. */
  4883. static errorsCount: number;
  4884. /**
  4885. * Callback called when a new log is added
  4886. */
  4887. static OnNewCacheEntry: (entry: string) => void;
  4888. private static _AddLogEntry;
  4889. private static _FormatMessage;
  4890. private static _LogDisabled;
  4891. private static _LogEnabled;
  4892. private static _WarnDisabled;
  4893. private static _WarnEnabled;
  4894. private static _ErrorDisabled;
  4895. private static _ErrorEnabled;
  4896. /**
  4897. * Log a message to the console
  4898. */
  4899. static Log: (message: string) => void;
  4900. /**
  4901. * Write a warning message to the console
  4902. */
  4903. static Warn: (message: string) => void;
  4904. /**
  4905. * Write an error message to the console
  4906. */
  4907. static Error: (message: string) => void;
  4908. /**
  4909. * Gets current log cache (list of logs)
  4910. */
  4911. static readonly LogCache: string;
  4912. /**
  4913. * Clears the log cache
  4914. */
  4915. static ClearLogCache(): void;
  4916. /**
  4917. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4918. */
  4919. static LogLevels: number;
  4920. }
  4921. }
  4922. declare module "babylonjs/Misc/typeStore" {
  4923. /** @hidden */
  4924. export class _TypeStore {
  4925. /** @hidden */
  4926. static RegisteredTypes: {
  4927. [key: string]: Object;
  4928. };
  4929. /** @hidden */
  4930. static GetClass(fqdn: string): any;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/deepCopier" {
  4934. /**
  4935. * Class containing a set of static utilities functions for deep copy.
  4936. */
  4937. export class DeepCopier {
  4938. /**
  4939. * Tries to copy an object by duplicating every property
  4940. * @param source defines the source object
  4941. * @param destination defines the target object
  4942. * @param doNotCopyList defines a list of properties to avoid
  4943. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4944. */
  4945. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4946. }
  4947. }
  4948. declare module "babylonjs/Misc/precisionDate" {
  4949. /**
  4950. * Class containing a set of static utilities functions for precision date
  4951. */
  4952. export class PrecisionDate {
  4953. /**
  4954. * Gets either window.performance.now() if supported or Date.now() else
  4955. */
  4956. static readonly Now: number;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4960. /**
  4961. * Class used to evalaute queries containing `and` and `or` operators
  4962. */
  4963. export class AndOrNotEvaluator {
  4964. /**
  4965. * Evaluate a query
  4966. * @param query defines the query to evaluate
  4967. * @param evaluateCallback defines the callback used to filter result
  4968. * @returns true if the query matches
  4969. */
  4970. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4971. private static _HandleParenthesisContent;
  4972. private static _SimplifyNegation;
  4973. }
  4974. }
  4975. declare module "babylonjs/Misc/tags" {
  4976. /**
  4977. * Class used to store custom tags
  4978. */
  4979. export class Tags {
  4980. /**
  4981. * Adds support for tags on the given object
  4982. * @param obj defines the object to use
  4983. */
  4984. static EnableFor(obj: any): void;
  4985. /**
  4986. * Removes tags support
  4987. * @param obj defines the object to use
  4988. */
  4989. static DisableFor(obj: any): void;
  4990. /**
  4991. * Gets a boolean indicating if the given object has tags
  4992. * @param obj defines the object to use
  4993. * @returns a boolean
  4994. */
  4995. static HasTags(obj: any): boolean;
  4996. /**
  4997. * Gets the tags available on a given object
  4998. * @param obj defines the object to use
  4999. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5000. * @returns the tags
  5001. */
  5002. static GetTags(obj: any, asString?: boolean): any;
  5003. /**
  5004. * Adds tags to an object
  5005. * @param obj defines the object to use
  5006. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5007. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5008. */
  5009. static AddTagsTo(obj: any, tagsString: string): void;
  5010. /**
  5011. * @hidden
  5012. */
  5013. static _AddTagTo(obj: any, tag: string): void;
  5014. /**
  5015. * Removes specific tags from a specific object
  5016. * @param obj defines the object to use
  5017. * @param tagsString defines the tags to remove
  5018. */
  5019. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5020. /**
  5021. * @hidden
  5022. */
  5023. static _RemoveTagFrom(obj: any, tag: string): void;
  5024. /**
  5025. * Defines if tags hosted on an object match a given query
  5026. * @param obj defines the object to use
  5027. * @param tagsQuery defines the tag query
  5028. * @returns a boolean
  5029. */
  5030. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5031. }
  5032. }
  5033. declare module "babylonjs/Materials/materialDefines" {
  5034. /**
  5035. * Manages the defines for the Material
  5036. */
  5037. export class MaterialDefines {
  5038. private _keys;
  5039. private _isDirty;
  5040. /** @hidden */
  5041. _renderId: number;
  5042. /** @hidden */
  5043. _areLightsDirty: boolean;
  5044. /** @hidden */
  5045. _areAttributesDirty: boolean;
  5046. /** @hidden */
  5047. _areTexturesDirty: boolean;
  5048. /** @hidden */
  5049. _areFresnelDirty: boolean;
  5050. /** @hidden */
  5051. _areMiscDirty: boolean;
  5052. /** @hidden */
  5053. _areImageProcessingDirty: boolean;
  5054. /** @hidden */
  5055. _normals: boolean;
  5056. /** @hidden */
  5057. _uvs: boolean;
  5058. /** @hidden */
  5059. _needNormals: boolean;
  5060. /** @hidden */
  5061. _needUVs: boolean;
  5062. /**
  5063. * Specifies if the material needs to be re-calculated
  5064. */
  5065. readonly isDirty: boolean;
  5066. /**
  5067. * Marks the material to indicate that it has been re-calculated
  5068. */
  5069. markAsProcessed(): void;
  5070. /**
  5071. * Marks the material to indicate that it needs to be re-calculated
  5072. */
  5073. markAsUnprocessed(): void;
  5074. /**
  5075. * Marks the material to indicate all of its defines need to be re-calculated
  5076. */
  5077. markAllAsDirty(): void;
  5078. /**
  5079. * Marks the material to indicate that image processing needs to be re-calculated
  5080. */
  5081. markAsImageProcessingDirty(): void;
  5082. /**
  5083. * Marks the material to indicate the lights need to be re-calculated
  5084. */
  5085. markAsLightDirty(): void;
  5086. /**
  5087. * Marks the attribute state as changed
  5088. */
  5089. markAsAttributesDirty(): void;
  5090. /**
  5091. * Marks the texture state as changed
  5092. */
  5093. markAsTexturesDirty(): void;
  5094. /**
  5095. * Marks the fresnel state as changed
  5096. */
  5097. markAsFresnelDirty(): void;
  5098. /**
  5099. * Marks the misc state as changed
  5100. */
  5101. markAsMiscDirty(): void;
  5102. /**
  5103. * Rebuilds the material defines
  5104. */
  5105. rebuild(): void;
  5106. /**
  5107. * Specifies if two material defines are equal
  5108. * @param other - A material define instance to compare to
  5109. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5110. */
  5111. isEqual(other: MaterialDefines): boolean;
  5112. /**
  5113. * Clones this instance's defines to another instance
  5114. * @param other - material defines to clone values to
  5115. */
  5116. cloneTo(other: MaterialDefines): void;
  5117. /**
  5118. * Resets the material define values
  5119. */
  5120. reset(): void;
  5121. /**
  5122. * Converts the material define values to a string
  5123. * @returns - String of material define information
  5124. */
  5125. toString(): string;
  5126. }
  5127. }
  5128. declare module "babylonjs/Misc/performanceMonitor" {
  5129. /**
  5130. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5131. */
  5132. export class PerformanceMonitor {
  5133. private _enabled;
  5134. private _rollingFrameTime;
  5135. private _lastFrameTimeMs;
  5136. /**
  5137. * constructor
  5138. * @param frameSampleSize The number of samples required to saturate the sliding window
  5139. */
  5140. constructor(frameSampleSize?: number);
  5141. /**
  5142. * Samples current frame
  5143. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5144. */
  5145. sampleFrame(timeMs?: number): void;
  5146. /**
  5147. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5148. */
  5149. readonly averageFrameTime: number;
  5150. /**
  5151. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5152. */
  5153. readonly averageFrameTimeVariance: number;
  5154. /**
  5155. * Returns the frame time of the most recent frame
  5156. */
  5157. readonly instantaneousFrameTime: number;
  5158. /**
  5159. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5160. */
  5161. readonly averageFPS: number;
  5162. /**
  5163. * Returns the average framerate in frames per second using the most recent frame time
  5164. */
  5165. readonly instantaneousFPS: number;
  5166. /**
  5167. * Returns true if enough samples have been taken to completely fill the sliding window
  5168. */
  5169. readonly isSaturated: boolean;
  5170. /**
  5171. * Enables contributions to the sliding window sample set
  5172. */
  5173. enable(): void;
  5174. /**
  5175. * Disables contributions to the sliding window sample set
  5176. * Samples will not be interpolated over the disabled period
  5177. */
  5178. disable(): void;
  5179. /**
  5180. * Returns true if sampling is enabled
  5181. */
  5182. readonly isEnabled: boolean;
  5183. /**
  5184. * Resets performance monitor
  5185. */
  5186. reset(): void;
  5187. }
  5188. /**
  5189. * RollingAverage
  5190. *
  5191. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5192. */
  5193. export class RollingAverage {
  5194. /**
  5195. * Current average
  5196. */
  5197. average: number;
  5198. /**
  5199. * Current variance
  5200. */
  5201. variance: number;
  5202. protected _samples: Array<number>;
  5203. protected _sampleCount: number;
  5204. protected _pos: number;
  5205. protected _m2: number;
  5206. /**
  5207. * constructor
  5208. * @param length The number of samples required to saturate the sliding window
  5209. */
  5210. constructor(length: number);
  5211. /**
  5212. * Adds a sample to the sample set
  5213. * @param v The sample value
  5214. */
  5215. add(v: number): void;
  5216. /**
  5217. * Returns previously added values or null if outside of history or outside the sliding window domain
  5218. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5219. * @return Value previously recorded with add() or null if outside of range
  5220. */
  5221. history(i: number): number;
  5222. /**
  5223. * Returns true if enough samples have been taken to completely fill the sliding window
  5224. * @return true if sample-set saturated
  5225. */
  5226. isSaturated(): boolean;
  5227. /**
  5228. * Resets the rolling average (equivalent to 0 samples taken so far)
  5229. */
  5230. reset(): void;
  5231. /**
  5232. * Wraps a value around the sample range boundaries
  5233. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5234. * @return Wrapped position in sample range
  5235. */
  5236. protected _wrapPosition(i: number): number;
  5237. }
  5238. }
  5239. declare module "babylonjs/Misc/stringDictionary" {
  5240. import { Nullable } from "babylonjs/types";
  5241. /**
  5242. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5243. * The underlying implementation relies on an associative array to ensure the best performances.
  5244. * The value can be anything including 'null' but except 'undefined'
  5245. */
  5246. export class StringDictionary<T> {
  5247. /**
  5248. * This will clear this dictionary and copy the content from the 'source' one.
  5249. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5250. * @param source the dictionary to take the content from and copy to this dictionary
  5251. */
  5252. copyFrom(source: StringDictionary<T>): void;
  5253. /**
  5254. * Get a value based from its key
  5255. * @param key the given key to get the matching value from
  5256. * @return the value if found, otherwise undefined is returned
  5257. */
  5258. get(key: string): T | undefined;
  5259. /**
  5260. * Get a value from its key or add it if it doesn't exist.
  5261. * This method will ensure you that a given key/data will be present in the dictionary.
  5262. * @param key the given key to get the matching value from
  5263. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5264. * The factory will only be invoked if there's no data for the given key.
  5265. * @return the value corresponding to the key.
  5266. */
  5267. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5268. /**
  5269. * Get a value from its key if present in the dictionary otherwise add it
  5270. * @param key the key to get the value from
  5271. * @param val if there's no such key/value pair in the dictionary add it with this value
  5272. * @return the value corresponding to the key
  5273. */
  5274. getOrAdd(key: string, val: T): T;
  5275. /**
  5276. * Check if there's a given key in the dictionary
  5277. * @param key the key to check for
  5278. * @return true if the key is present, false otherwise
  5279. */
  5280. contains(key: string): boolean;
  5281. /**
  5282. * Add a new key and its corresponding value
  5283. * @param key the key to add
  5284. * @param value the value corresponding to the key
  5285. * @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
  5286. */
  5287. add(key: string, value: T): boolean;
  5288. /**
  5289. * Update a specific value associated to a key
  5290. * @param key defines the key to use
  5291. * @param value defines the value to store
  5292. * @returns true if the value was updated (or false if the key was not found)
  5293. */
  5294. set(key: string, value: T): boolean;
  5295. /**
  5296. * Get the element of the given key and remove it from the dictionary
  5297. * @param key defines the key to search
  5298. * @returns the value associated with the key or null if not found
  5299. */
  5300. getAndRemove(key: string): Nullable<T>;
  5301. /**
  5302. * Remove a key/value from the dictionary.
  5303. * @param key the key to remove
  5304. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5305. */
  5306. remove(key: string): boolean;
  5307. /**
  5308. * Clear the whole content of the dictionary
  5309. */
  5310. clear(): void;
  5311. /**
  5312. * Gets the current count
  5313. */
  5314. readonly count: number;
  5315. /**
  5316. * Execute a callback on each key/val of the dictionary.
  5317. * Note that you can remove any element in this dictionary in the callback implementation
  5318. * @param callback the callback to execute on a given key/value pair
  5319. */
  5320. forEach(callback: (key: string, val: T) => void): void;
  5321. /**
  5322. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5323. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5326. * @returns the first item
  5327. */
  5328. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5329. private _count;
  5330. private _data;
  5331. }
  5332. }
  5333. declare module "babylonjs/Misc/promise" {
  5334. /**
  5335. * Helper class that provides a small promise polyfill
  5336. */
  5337. export class PromisePolyfill {
  5338. /**
  5339. * Static function used to check if the polyfill is required
  5340. * If this is the case then the function will inject the polyfill to window.Promise
  5341. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5342. */
  5343. static Apply(force?: boolean): void;
  5344. }
  5345. }
  5346. declare module "babylonjs/Meshes/buffer" {
  5347. import { Nullable, DataArray } from "babylonjs/types";
  5348. /**
  5349. * Class used to store data that will be store in GPU memory
  5350. */
  5351. export class Buffer {
  5352. private _engine;
  5353. private _buffer;
  5354. /** @hidden */
  5355. _data: Nullable<DataArray>;
  5356. private _updatable;
  5357. private _instanced;
  5358. /**
  5359. * Gets the byte stride.
  5360. */
  5361. readonly byteStride: number;
  5362. /**
  5363. * Constructor
  5364. * @param engine the engine
  5365. * @param data the data to use for this buffer
  5366. * @param updatable whether the data is updatable
  5367. * @param stride the stride (optional)
  5368. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5369. * @param instanced whether the buffer is instanced (optional)
  5370. * @param useBytes set to true if the stride in in bytes (optional)
  5371. */
  5372. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5373. /**
  5374. * Create a new VertexBuffer based on the current buffer
  5375. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5376. * @param offset defines offset in the buffer (0 by default)
  5377. * @param size defines the size in floats of attributes (position is 3 for instance)
  5378. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5379. * @param instanced defines if the vertex buffer contains indexed data
  5380. * @param useBytes defines if the offset and stride are in bytes
  5381. * @returns the new vertex buffer
  5382. */
  5383. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5384. /**
  5385. * Gets a boolean indicating if the Buffer is updatable?
  5386. * @returns true if the buffer is updatable
  5387. */
  5388. isUpdatable(): boolean;
  5389. /**
  5390. * Gets current buffer's data
  5391. * @returns a DataArray or null
  5392. */
  5393. getData(): Nullable<DataArray>;
  5394. /**
  5395. * Gets underlying native buffer
  5396. * @returns underlying native buffer
  5397. */
  5398. getBuffer(): Nullable<WebGLBuffer>;
  5399. /**
  5400. * Gets the stride in float32 units (i.e. byte stride / 4).
  5401. * May not be an integer if the byte stride is not divisible by 4.
  5402. * DEPRECATED. Use byteStride instead.
  5403. * @returns the stride in float32 units
  5404. */
  5405. getStrideSize(): number;
  5406. /**
  5407. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5408. * @param data defines the data to store
  5409. */
  5410. create(data?: Nullable<DataArray>): void;
  5411. /** @hidden */
  5412. _rebuild(): void;
  5413. /**
  5414. * Update current buffer data
  5415. * @param data defines the data to store
  5416. */
  5417. update(data: DataArray): void;
  5418. /**
  5419. * Updates the data directly.
  5420. * @param data the new data
  5421. * @param offset the new offset
  5422. * @param vertexCount the vertex count (optional)
  5423. * @param useBytes set to true if the offset is in bytes
  5424. */
  5425. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5426. /**
  5427. * Release all resources
  5428. */
  5429. dispose(): void;
  5430. }
  5431. /**
  5432. * Specialized buffer used to store vertex data
  5433. */
  5434. export class VertexBuffer {
  5435. /** @hidden */
  5436. _buffer: Buffer;
  5437. private _kind;
  5438. private _size;
  5439. private _ownsBuffer;
  5440. private _instanced;
  5441. private _instanceDivisor;
  5442. /**
  5443. * The byte type.
  5444. */
  5445. static readonly BYTE: number;
  5446. /**
  5447. * The unsigned byte type.
  5448. */
  5449. static readonly UNSIGNED_BYTE: number;
  5450. /**
  5451. * The short type.
  5452. */
  5453. static readonly SHORT: number;
  5454. /**
  5455. * The unsigned short type.
  5456. */
  5457. static readonly UNSIGNED_SHORT: number;
  5458. /**
  5459. * The integer type.
  5460. */
  5461. static readonly INT: number;
  5462. /**
  5463. * The unsigned integer type.
  5464. */
  5465. static readonly UNSIGNED_INT: number;
  5466. /**
  5467. * The float type.
  5468. */
  5469. static readonly FLOAT: number;
  5470. /**
  5471. * Gets or sets the instance divisor when in instanced mode
  5472. */
  5473. instanceDivisor: number;
  5474. /**
  5475. * Gets the byte stride.
  5476. */
  5477. readonly byteStride: number;
  5478. /**
  5479. * Gets the byte offset.
  5480. */
  5481. readonly byteOffset: number;
  5482. /**
  5483. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5484. */
  5485. readonly normalized: boolean;
  5486. /**
  5487. * Gets the data type of each component in the array.
  5488. */
  5489. readonly type: number;
  5490. /**
  5491. * Constructor
  5492. * @param engine the engine
  5493. * @param data the data to use for this vertex buffer
  5494. * @param kind the vertex buffer kind
  5495. * @param updatable whether the data is updatable
  5496. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5497. * @param stride the stride (optional)
  5498. * @param instanced whether the buffer is instanced (optional)
  5499. * @param offset the offset of the data (optional)
  5500. * @param size the number of components (optional)
  5501. * @param type the type of the component (optional)
  5502. * @param normalized whether the data contains normalized data (optional)
  5503. * @param useBytes set to true if stride and offset are in bytes (optional)
  5504. */
  5505. 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);
  5506. /** @hidden */
  5507. _rebuild(): void;
  5508. /**
  5509. * Returns the kind of the VertexBuffer (string)
  5510. * @returns a string
  5511. */
  5512. getKind(): string;
  5513. /**
  5514. * Gets a boolean indicating if the VertexBuffer is updatable?
  5515. * @returns true if the buffer is updatable
  5516. */
  5517. isUpdatable(): boolean;
  5518. /**
  5519. * Gets current buffer's data
  5520. * @returns a DataArray or null
  5521. */
  5522. getData(): Nullable<DataArray>;
  5523. /**
  5524. * Gets underlying native buffer
  5525. * @returns underlying native buffer
  5526. */
  5527. getBuffer(): Nullable<WebGLBuffer>;
  5528. /**
  5529. * Gets the stride in float32 units (i.e. byte stride / 4).
  5530. * May not be an integer if the byte stride is not divisible by 4.
  5531. * DEPRECATED. Use byteStride instead.
  5532. * @returns the stride in float32 units
  5533. */
  5534. getStrideSize(): number;
  5535. /**
  5536. * Returns the offset as a multiple of the type byte length.
  5537. * DEPRECATED. Use byteOffset instead.
  5538. * @returns the offset in bytes
  5539. */
  5540. getOffset(): number;
  5541. /**
  5542. * Returns the number of components per vertex attribute (integer)
  5543. * @returns the size in float
  5544. */
  5545. getSize(): number;
  5546. /**
  5547. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5548. * @returns true if this buffer is instanced
  5549. */
  5550. getIsInstanced(): boolean;
  5551. /**
  5552. * Returns the instancing divisor, zero for non-instanced (integer).
  5553. * @returns a number
  5554. */
  5555. getInstanceDivisor(): number;
  5556. /**
  5557. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5558. * @param data defines the data to store
  5559. */
  5560. create(data?: DataArray): void;
  5561. /**
  5562. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5563. * This function will create a new buffer if the current one is not updatable
  5564. * @param data defines the data to store
  5565. */
  5566. update(data: DataArray): void;
  5567. /**
  5568. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5569. * Returns the directly updated WebGLBuffer.
  5570. * @param data the new data
  5571. * @param offset the new offset
  5572. * @param useBytes set to true if the offset is in bytes
  5573. */
  5574. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5575. /**
  5576. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5577. */
  5578. dispose(): void;
  5579. /**
  5580. * Enumerates each value of this vertex buffer as numbers.
  5581. * @param count the number of values to enumerate
  5582. * @param callback the callback function called for each value
  5583. */
  5584. forEach(count: number, callback: (value: number, index: number) => void): void;
  5585. /**
  5586. * Positions
  5587. */
  5588. static readonly PositionKind: string;
  5589. /**
  5590. * Normals
  5591. */
  5592. static readonly NormalKind: string;
  5593. /**
  5594. * Tangents
  5595. */
  5596. static readonly TangentKind: string;
  5597. /**
  5598. * Texture coordinates
  5599. */
  5600. static readonly UVKind: string;
  5601. /**
  5602. * Texture coordinates 2
  5603. */
  5604. static readonly UV2Kind: string;
  5605. /**
  5606. * Texture coordinates 3
  5607. */
  5608. static readonly UV3Kind: string;
  5609. /**
  5610. * Texture coordinates 4
  5611. */
  5612. static readonly UV4Kind: string;
  5613. /**
  5614. * Texture coordinates 5
  5615. */
  5616. static readonly UV5Kind: string;
  5617. /**
  5618. * Texture coordinates 6
  5619. */
  5620. static readonly UV6Kind: string;
  5621. /**
  5622. * Colors
  5623. */
  5624. static readonly ColorKind: string;
  5625. /**
  5626. * Matrix indices (for bones)
  5627. */
  5628. static readonly MatricesIndicesKind: string;
  5629. /**
  5630. * Matrix weights (for bones)
  5631. */
  5632. static readonly MatricesWeightsKind: string;
  5633. /**
  5634. * Additional matrix indices (for bones)
  5635. */
  5636. static readonly MatricesIndicesExtraKind: string;
  5637. /**
  5638. * Additional matrix weights (for bones)
  5639. */
  5640. static readonly MatricesWeightsExtraKind: string;
  5641. /**
  5642. * Deduces the stride given a kind.
  5643. * @param kind The kind string to deduce
  5644. * @returns The deduced stride
  5645. */
  5646. static DeduceStride(kind: string): number;
  5647. /**
  5648. * Gets the byte length of the given type.
  5649. * @param type the type
  5650. * @returns the number of bytes
  5651. */
  5652. static GetTypeByteLength(type: number): number;
  5653. /**
  5654. * Enumerates each value of the given parameters as numbers.
  5655. * @param data the data to enumerate
  5656. * @param byteOffset the byte offset of the data
  5657. * @param byteStride the byte stride of the data
  5658. * @param componentCount the number of components per element
  5659. * @param componentType the type of the component
  5660. * @param count the total number of components
  5661. * @param normalized whether the data is normalized
  5662. * @param callback the callback function called for each value
  5663. */
  5664. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5665. private static _GetFloatValue;
  5666. }
  5667. }
  5668. declare module "babylonjs/Maths/sphericalPolynomial" {
  5669. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5670. /**
  5671. * Class representing spherical polynomial coefficients to the 3rd degree
  5672. */
  5673. export class SphericalPolynomial {
  5674. /**
  5675. * The x coefficients of the spherical polynomial
  5676. */
  5677. x: Vector3;
  5678. /**
  5679. * The y coefficients of the spherical polynomial
  5680. */
  5681. y: Vector3;
  5682. /**
  5683. * The z coefficients of the spherical polynomial
  5684. */
  5685. z: Vector3;
  5686. /**
  5687. * The xx coefficients of the spherical polynomial
  5688. */
  5689. xx: Vector3;
  5690. /**
  5691. * The yy coefficients of the spherical polynomial
  5692. */
  5693. yy: Vector3;
  5694. /**
  5695. * The zz coefficients of the spherical polynomial
  5696. */
  5697. zz: Vector3;
  5698. /**
  5699. * The xy coefficients of the spherical polynomial
  5700. */
  5701. xy: Vector3;
  5702. /**
  5703. * The yz coefficients of the spherical polynomial
  5704. */
  5705. yz: Vector3;
  5706. /**
  5707. * The zx coefficients of the spherical polynomial
  5708. */
  5709. zx: Vector3;
  5710. /**
  5711. * Adds an ambient color to the spherical polynomial
  5712. * @param color the color to add
  5713. */
  5714. addAmbient(color: Color3): void;
  5715. /**
  5716. * Scales the spherical polynomial by the given amount
  5717. * @param scale the amount to scale
  5718. */
  5719. scale(scale: number): void;
  5720. /**
  5721. * Gets the spherical polynomial from harmonics
  5722. * @param harmonics the spherical harmonics
  5723. * @returns the spherical polynomial
  5724. */
  5725. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5726. /**
  5727. * Constructs a spherical polynomial from an array.
  5728. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5729. * @returns the spherical polynomial
  5730. */
  5731. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5732. }
  5733. /**
  5734. * Class representing spherical harmonics coefficients to the 3rd degree
  5735. */
  5736. export class SphericalHarmonics {
  5737. /**
  5738. * The l0,0 coefficients of the spherical harmonics
  5739. */
  5740. l00: Vector3;
  5741. /**
  5742. * The l1,-1 coefficients of the spherical harmonics
  5743. */
  5744. l1_1: Vector3;
  5745. /**
  5746. * The l1,0 coefficients of the spherical harmonics
  5747. */
  5748. l10: Vector3;
  5749. /**
  5750. * The l1,1 coefficients of the spherical harmonics
  5751. */
  5752. l11: Vector3;
  5753. /**
  5754. * The l2,-2 coefficients of the spherical harmonics
  5755. */
  5756. l2_2: Vector3;
  5757. /**
  5758. * The l2,-1 coefficients of the spherical harmonics
  5759. */
  5760. l2_1: Vector3;
  5761. /**
  5762. * The l2,0 coefficients of the spherical harmonics
  5763. */
  5764. l20: Vector3;
  5765. /**
  5766. * The l2,1 coefficients of the spherical harmonics
  5767. */
  5768. l21: Vector3;
  5769. /**
  5770. * The l2,2 coefficients of the spherical harmonics
  5771. */
  5772. lL22: Vector3;
  5773. /**
  5774. * Adds a light to the spherical harmonics
  5775. * @param direction the direction of the light
  5776. * @param color the color of the light
  5777. * @param deltaSolidAngle the delta solid angle of the light
  5778. */
  5779. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5780. /**
  5781. * Scales the spherical harmonics by the given amount
  5782. * @param scale the amount to scale
  5783. */
  5784. scale(scale: number): void;
  5785. /**
  5786. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5787. *
  5788. * ```
  5789. * E_lm = A_l * L_lm
  5790. * ```
  5791. *
  5792. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5793. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5794. * the scaling factors are given in equation 9.
  5795. */
  5796. convertIncidentRadianceToIrradiance(): void;
  5797. /**
  5798. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5799. *
  5800. * ```
  5801. * L = (1/pi) * E * rho
  5802. * ```
  5803. *
  5804. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5805. */
  5806. convertIrradianceToLambertianRadiance(): void;
  5807. /**
  5808. * Gets the spherical harmonics from polynomial
  5809. * @param polynomial the spherical polynomial
  5810. * @returns the spherical harmonics
  5811. */
  5812. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5813. /**
  5814. * Constructs a spherical harmonics from an array.
  5815. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5816. * @returns the spherical harmonics
  5817. */
  5818. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5819. }
  5820. }
  5821. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5822. import { Nullable } from "babylonjs/types";
  5823. /**
  5824. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5825. */
  5826. export interface CubeMapInfo {
  5827. /**
  5828. * The pixel array for the front face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. front: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The pixel array for the back face.
  5834. * This is stored in format, left to right, up to down format.
  5835. */
  5836. back: Nullable<ArrayBufferView>;
  5837. /**
  5838. * The pixel array for the left face.
  5839. * This is stored in format, left to right, up to down format.
  5840. */
  5841. left: Nullable<ArrayBufferView>;
  5842. /**
  5843. * The pixel array for the right face.
  5844. * This is stored in format, left to right, up to down format.
  5845. */
  5846. right: Nullable<ArrayBufferView>;
  5847. /**
  5848. * The pixel array for the up face.
  5849. * This is stored in format, left to right, up to down format.
  5850. */
  5851. up: Nullable<ArrayBufferView>;
  5852. /**
  5853. * The pixel array for the down face.
  5854. * This is stored in format, left to right, up to down format.
  5855. */
  5856. down: Nullable<ArrayBufferView>;
  5857. /**
  5858. * The size of the cubemap stored.
  5859. *
  5860. * Each faces will be size * size pixels.
  5861. */
  5862. size: number;
  5863. /**
  5864. * The format of the texture.
  5865. *
  5866. * RGBA, RGB.
  5867. */
  5868. format: number;
  5869. /**
  5870. * The type of the texture data.
  5871. *
  5872. * UNSIGNED_INT, FLOAT.
  5873. */
  5874. type: number;
  5875. /**
  5876. * Specifies whether the texture is in gamma space.
  5877. */
  5878. gammaSpace: boolean;
  5879. }
  5880. /**
  5881. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5882. */
  5883. export class PanoramaToCubeMapTools {
  5884. private static FACE_FRONT;
  5885. private static FACE_BACK;
  5886. private static FACE_RIGHT;
  5887. private static FACE_LEFT;
  5888. private static FACE_DOWN;
  5889. private static FACE_UP;
  5890. /**
  5891. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5892. *
  5893. * @param float32Array The source data.
  5894. * @param inputWidth The width of the input panorama.
  5895. * @param inputHeight The height of the input panorama.
  5896. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5897. * @return The cubemap data
  5898. */
  5899. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5900. private static CreateCubemapTexture;
  5901. private static CalcProjectionSpherical;
  5902. }
  5903. }
  5904. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5905. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5907. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5908. /**
  5909. * Helper class dealing with the extraction of spherical polynomial dataArray
  5910. * from a cube map.
  5911. */
  5912. export class CubeMapToSphericalPolynomialTools {
  5913. private static FileFaces;
  5914. /**
  5915. * Converts a texture to the according Spherical Polynomial data.
  5916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5917. *
  5918. * @param texture The texture to extract the information from.
  5919. * @return The Spherical Polynomial data.
  5920. */
  5921. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5922. /**
  5923. * Converts a cubemap to the according Spherical Polynomial data.
  5924. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5925. *
  5926. * @param cubeInfo The Cube map to extract the information from.
  5927. * @return The Spherical Polynomial data.
  5928. */
  5929. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5930. }
  5931. }
  5932. declare module "babylonjs/Engines/engineStore" {
  5933. import { Nullable } from "babylonjs/types";
  5934. import { Engine } from "babylonjs/Engines/engine";
  5935. import { Scene } from "babylonjs/scene";
  5936. /**
  5937. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5938. * during the life time of the application.
  5939. */
  5940. export class EngineStore {
  5941. /** Gets the list of created engines */
  5942. static Instances: import("babylonjs/Engines/engine").Engine[];
  5943. /**
  5944. * Gets the latest created engine
  5945. */
  5946. static readonly LastCreatedEngine: Nullable<Engine>;
  5947. /**
  5948. * Gets the latest created scene
  5949. */
  5950. static readonly LastCreatedScene: Nullable<Scene>;
  5951. }
  5952. }
  5953. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5954. /**
  5955. * Define options used to create a render target texture
  5956. */
  5957. export class RenderTargetCreationOptions {
  5958. /**
  5959. * Specifies is mipmaps must be generated
  5960. */
  5961. generateMipMaps?: boolean;
  5962. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5963. generateDepthBuffer?: boolean;
  5964. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5965. generateStencilBuffer?: boolean;
  5966. /** Defines texture type (int by default) */
  5967. type?: number;
  5968. /** Defines sampling mode (trilinear by default) */
  5969. samplingMode?: number;
  5970. /** Defines format (RGBA by default) */
  5971. format?: number;
  5972. }
  5973. }
  5974. declare module "babylonjs/States/alphaCullingState" {
  5975. /**
  5976. * @hidden
  5977. **/
  5978. export class _AlphaState {
  5979. private _isAlphaBlendDirty;
  5980. private _isBlendFunctionParametersDirty;
  5981. private _isBlendEquationParametersDirty;
  5982. private _isBlendConstantsDirty;
  5983. private _alphaBlend;
  5984. private _blendFunctionParameters;
  5985. private _blendEquationParameters;
  5986. private _blendConstants;
  5987. /**
  5988. * Initializes the state.
  5989. */
  5990. constructor();
  5991. readonly isDirty: boolean;
  5992. alphaBlend: boolean;
  5993. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5994. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5995. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5996. reset(): void;
  5997. apply(gl: WebGLRenderingContext): void;
  5998. }
  5999. }
  6000. declare module "babylonjs/States/depthCullingState" {
  6001. import { Nullable } from "babylonjs/types";
  6002. /**
  6003. * @hidden
  6004. **/
  6005. export class _DepthCullingState {
  6006. private _isDepthTestDirty;
  6007. private _isDepthMaskDirty;
  6008. private _isDepthFuncDirty;
  6009. private _isCullFaceDirty;
  6010. private _isCullDirty;
  6011. private _isZOffsetDirty;
  6012. private _isFrontFaceDirty;
  6013. private _depthTest;
  6014. private _depthMask;
  6015. private _depthFunc;
  6016. private _cull;
  6017. private _cullFace;
  6018. private _zOffset;
  6019. private _frontFace;
  6020. /**
  6021. * Initializes the state.
  6022. */
  6023. constructor();
  6024. readonly isDirty: boolean;
  6025. zOffset: number;
  6026. cullFace: Nullable<number>;
  6027. cull: Nullable<boolean>;
  6028. depthFunc: Nullable<number>;
  6029. depthMask: boolean;
  6030. depthTest: boolean;
  6031. frontFace: Nullable<number>;
  6032. reset(): void;
  6033. apply(gl: WebGLRenderingContext): void;
  6034. }
  6035. }
  6036. declare module "babylonjs/States/stencilState" {
  6037. /**
  6038. * @hidden
  6039. **/
  6040. export class _StencilState {
  6041. /** 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 */
  6042. static readonly ALWAYS: number;
  6043. /** Passed to stencilOperation to specify that stencil value must be kept */
  6044. static readonly KEEP: number;
  6045. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6046. static readonly REPLACE: number;
  6047. private _isStencilTestDirty;
  6048. private _isStencilMaskDirty;
  6049. private _isStencilFuncDirty;
  6050. private _isStencilOpDirty;
  6051. private _stencilTest;
  6052. private _stencilMask;
  6053. private _stencilFunc;
  6054. private _stencilFuncRef;
  6055. private _stencilFuncMask;
  6056. private _stencilOpStencilFail;
  6057. private _stencilOpDepthFail;
  6058. private _stencilOpStencilDepthPass;
  6059. readonly isDirty: boolean;
  6060. stencilFunc: number;
  6061. stencilFuncRef: number;
  6062. stencilFuncMask: number;
  6063. stencilOpStencilFail: number;
  6064. stencilOpDepthFail: number;
  6065. stencilOpStencilDepthPass: number;
  6066. stencilMask: number;
  6067. stencilTest: boolean;
  6068. constructor();
  6069. reset(): void;
  6070. apply(gl: WebGLRenderingContext): void;
  6071. }
  6072. }
  6073. declare module "babylonjs/States/index" {
  6074. export * from "babylonjs/States/alphaCullingState";
  6075. export * from "babylonjs/States/depthCullingState";
  6076. export * from "babylonjs/States/stencilState";
  6077. }
  6078. declare module "babylonjs/Instrumentation/timeToken" {
  6079. import { Nullable } from "babylonjs/types";
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _TimeToken {
  6084. _startTimeQuery: Nullable<WebGLQuery>;
  6085. _endTimeQuery: Nullable<WebGLQuery>;
  6086. _timeElapsedQuery: Nullable<WebGLQuery>;
  6087. _timeElapsedQueryEnded: boolean;
  6088. }
  6089. }
  6090. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6091. import { Nullable } from "babylonjs/types";
  6092. /**
  6093. * Internal interface used to track InternalTexture already bound to the GL context
  6094. */
  6095. export interface IInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. /**
  6106. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6107. */
  6108. export class DummyInternalTextureTracker {
  6109. /**
  6110. * Gets or set the previous tracker in the list
  6111. */
  6112. previous: Nullable<IInternalTextureTracker>;
  6113. /**
  6114. * Gets or set the next tracker in the list
  6115. */
  6116. next: Nullable<IInternalTextureTracker>;
  6117. }
  6118. }
  6119. declare module "babylonjs/Materials/Textures/internalTexture" {
  6120. import { Observable } from "babylonjs/Misc/observable";
  6121. import { Nullable, int } from "babylonjs/types";
  6122. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6123. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6124. import { Engine } from "babylonjs/Engines/engine";
  6125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6126. /**
  6127. * Class used to store data associated with WebGL texture data for the engine
  6128. * This class should not be used directly
  6129. */
  6130. export class InternalTexture implements IInternalTextureTracker {
  6131. /** hidden */
  6132. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6133. /**
  6134. * The source of the texture data is unknown
  6135. */
  6136. static DATASOURCE_UNKNOWN: number;
  6137. /**
  6138. * Texture data comes from an URL
  6139. */
  6140. static DATASOURCE_URL: number;
  6141. /**
  6142. * Texture data is only used for temporary storage
  6143. */
  6144. static DATASOURCE_TEMP: number;
  6145. /**
  6146. * Texture data comes from raw data (ArrayBuffer)
  6147. */
  6148. static DATASOURCE_RAW: number;
  6149. /**
  6150. * Texture content is dynamic (video or dynamic texture)
  6151. */
  6152. static DATASOURCE_DYNAMIC: number;
  6153. /**
  6154. * Texture content is generated by rendering to it
  6155. */
  6156. static DATASOURCE_RENDERTARGET: number;
  6157. /**
  6158. * Texture content is part of a multi render target process
  6159. */
  6160. static DATASOURCE_MULTIRENDERTARGET: number;
  6161. /**
  6162. * Texture data comes from a cube data file
  6163. */
  6164. static DATASOURCE_CUBE: number;
  6165. /**
  6166. * Texture data comes from a raw cube data
  6167. */
  6168. static DATASOURCE_CUBERAW: number;
  6169. /**
  6170. * Texture data come from a prefiltered cube data file
  6171. */
  6172. static DATASOURCE_CUBEPREFILTERED: number;
  6173. /**
  6174. * Texture content is raw 3D data
  6175. */
  6176. static DATASOURCE_RAW3D: number;
  6177. /**
  6178. * Texture content is a depth texture
  6179. */
  6180. static DATASOURCE_DEPTHTEXTURE: number;
  6181. /**
  6182. * Texture data comes from a raw cube data encoded with RGBD
  6183. */
  6184. static DATASOURCE_CUBERAW_RGBD: number;
  6185. /**
  6186. * Defines if the texture is ready
  6187. */
  6188. isReady: boolean;
  6189. /**
  6190. * Defines if the texture is a cube texture
  6191. */
  6192. isCube: boolean;
  6193. /**
  6194. * Defines if the texture contains 3D data
  6195. */
  6196. is3D: boolean;
  6197. /**
  6198. * Gets the URL used to load this texture
  6199. */
  6200. url: string;
  6201. /**
  6202. * Gets the sampling mode of the texture
  6203. */
  6204. samplingMode: number;
  6205. /**
  6206. * Gets a boolean indicating if the texture needs mipmaps generation
  6207. */
  6208. generateMipMaps: boolean;
  6209. /**
  6210. * Gets the number of samples used by the texture (WebGL2+ only)
  6211. */
  6212. samples: number;
  6213. /**
  6214. * Gets the type of the texture (int, float...)
  6215. */
  6216. type: number;
  6217. /**
  6218. * Gets the format of the texture (RGB, RGBA...)
  6219. */
  6220. format: number;
  6221. /**
  6222. * Observable called when the texture is loaded
  6223. */
  6224. onLoadedObservable: Observable<InternalTexture>;
  6225. /**
  6226. * Gets the width of the texture
  6227. */
  6228. width: number;
  6229. /**
  6230. * Gets the height of the texture
  6231. */
  6232. height: number;
  6233. /**
  6234. * Gets the depth of the texture
  6235. */
  6236. depth: number;
  6237. /**
  6238. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6239. */
  6240. baseWidth: number;
  6241. /**
  6242. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6243. */
  6244. baseHeight: number;
  6245. /**
  6246. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6247. */
  6248. baseDepth: number;
  6249. /**
  6250. * Gets a boolean indicating if the texture is inverted on Y axis
  6251. */
  6252. invertY: boolean;
  6253. /**
  6254. * Gets or set the previous tracker in the list
  6255. */
  6256. previous: Nullable<IInternalTextureTracker>;
  6257. /**
  6258. * Gets or set the next tracker in the list
  6259. */
  6260. next: Nullable<IInternalTextureTracker>;
  6261. /** @hidden */
  6262. _invertVScale: boolean;
  6263. /** @hidden */
  6264. _initialSlot: number;
  6265. /** @hidden */
  6266. _designatedSlot: number;
  6267. /** @hidden */
  6268. _dataSource: number;
  6269. /** @hidden */
  6270. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6271. /** @hidden */
  6272. _bufferView: Nullable<ArrayBufferView>;
  6273. /** @hidden */
  6274. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6275. /** @hidden */
  6276. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6277. /** @hidden */
  6278. _size: number;
  6279. /** @hidden */
  6280. _extension: string;
  6281. /** @hidden */
  6282. _files: Nullable<string[]>;
  6283. /** @hidden */
  6284. _workingCanvas: HTMLCanvasElement;
  6285. /** @hidden */
  6286. _workingContext: CanvasRenderingContext2D;
  6287. /** @hidden */
  6288. _framebuffer: Nullable<WebGLFramebuffer>;
  6289. /** @hidden */
  6290. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6291. /** @hidden */
  6292. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6293. /** @hidden */
  6294. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6295. /** @hidden */
  6296. _attachments: Nullable<number[]>;
  6297. /** @hidden */
  6298. _cachedCoordinatesMode: Nullable<number>;
  6299. /** @hidden */
  6300. _cachedWrapU: Nullable<number>;
  6301. /** @hidden */
  6302. _cachedWrapV: Nullable<number>;
  6303. /** @hidden */
  6304. _cachedWrapR: Nullable<number>;
  6305. /** @hidden */
  6306. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6307. /** @hidden */
  6308. _isDisabled: boolean;
  6309. /** @hidden */
  6310. _compression: Nullable<string>;
  6311. /** @hidden */
  6312. _generateStencilBuffer: boolean;
  6313. /** @hidden */
  6314. _generateDepthBuffer: boolean;
  6315. /** @hidden */
  6316. _comparisonFunction: number;
  6317. /** @hidden */
  6318. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6319. /** @hidden */
  6320. _lodGenerationScale: number;
  6321. /** @hidden */
  6322. _lodGenerationOffset: number;
  6323. /** @hidden */
  6324. _lodTextureHigh: BaseTexture;
  6325. /** @hidden */
  6326. _lodTextureMid: BaseTexture;
  6327. /** @hidden */
  6328. _lodTextureLow: BaseTexture;
  6329. /** @hidden */
  6330. _isRGBD: boolean;
  6331. /** @hidden */
  6332. _webGLTexture: Nullable<WebGLTexture>;
  6333. /** @hidden */
  6334. _references: number;
  6335. private _engine;
  6336. /**
  6337. * Gets the Engine the texture belongs to.
  6338. * @returns The babylon engine
  6339. */
  6340. getEngine(): Engine;
  6341. /**
  6342. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6343. */
  6344. readonly dataSource: number;
  6345. /**
  6346. * Creates a new InternalTexture
  6347. * @param engine defines the engine to use
  6348. * @param dataSource defines the type of data that will be used
  6349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6350. */
  6351. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6352. /**
  6353. * Increments the number of references (ie. the number of Texture that point to it)
  6354. */
  6355. incrementReferences(): void;
  6356. /**
  6357. * Change the size of the texture (not the size of the content)
  6358. * @param width defines the new width
  6359. * @param height defines the new height
  6360. * @param depth defines the new depth (1 by default)
  6361. */
  6362. updateSize(width: int, height: int, depth?: int): void;
  6363. /** @hidden */
  6364. _rebuild(): void;
  6365. /** @hidden */
  6366. _swapAndDie(target: InternalTexture): void;
  6367. /**
  6368. * Dispose the current allocated resources
  6369. */
  6370. dispose(): void;
  6371. }
  6372. }
  6373. declare module "babylonjs/Animations/easing" {
  6374. /**
  6375. * This represents the main contract an easing function should follow.
  6376. * Easing functions are used throughout the animation system.
  6377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6378. */
  6379. export interface IEasingFunction {
  6380. /**
  6381. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6382. * of the easing function.
  6383. * The link below provides some of the most common examples of easing functions.
  6384. * @see https://easings.net/
  6385. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6386. * @returns the corresponding value on the curve defined by the easing function
  6387. */
  6388. ease(gradient: number): number;
  6389. }
  6390. /**
  6391. * Base class used for every default easing function.
  6392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6393. */
  6394. export class EasingFunction implements IEasingFunction {
  6395. /**
  6396. * Interpolation follows the mathematical formula associated with the easing function.
  6397. */
  6398. static readonly EASINGMODE_EASEIN: number;
  6399. /**
  6400. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6401. */
  6402. static readonly EASINGMODE_EASEOUT: number;
  6403. /**
  6404. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6405. */
  6406. static readonly EASINGMODE_EASEINOUT: number;
  6407. private _easingMode;
  6408. /**
  6409. * Sets the easing mode of the current function.
  6410. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6411. */
  6412. setEasingMode(easingMode: number): void;
  6413. /**
  6414. * Gets the current easing mode.
  6415. * @returns the easing mode
  6416. */
  6417. getEasingMode(): number;
  6418. /**
  6419. * @hidden
  6420. */
  6421. easeInCore(gradient: number): number;
  6422. /**
  6423. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6424. * of the easing function.
  6425. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6426. * @returns the corresponding value on the curve defined by the easing function
  6427. */
  6428. ease(gradient: number): number;
  6429. }
  6430. /**
  6431. * Easing function with a circle shape (see link below).
  6432. * @see https://easings.net/#easeInCirc
  6433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6434. */
  6435. export class CircleEase extends EasingFunction implements IEasingFunction {
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a ease back shape (see link below).
  6441. * @see https://easings.net/#easeInBack
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BackEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the amplitude of the function */
  6446. amplitude: number;
  6447. /**
  6448. * Instantiates a back ease easing
  6449. * @see https://easings.net/#easeInBack
  6450. * @param amplitude Defines the amplitude of the function
  6451. */
  6452. constructor(
  6453. /** Defines the amplitude of the function */
  6454. amplitude?: number);
  6455. /** @hidden */
  6456. easeInCore(gradient: number): number;
  6457. }
  6458. /**
  6459. * Easing function with a bouncing shape (see link below).
  6460. * @see https://easings.net/#easeInBounce
  6461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6462. */
  6463. export class BounceEase extends EasingFunction implements IEasingFunction {
  6464. /** Defines the number of bounces */
  6465. bounces: number;
  6466. /** Defines the amplitude of the bounce */
  6467. bounciness: number;
  6468. /**
  6469. * Instantiates a bounce easing
  6470. * @see https://easings.net/#easeInBounce
  6471. * @param bounces Defines the number of bounces
  6472. * @param bounciness Defines the amplitude of the bounce
  6473. */
  6474. constructor(
  6475. /** Defines the number of bounces */
  6476. bounces?: number,
  6477. /** Defines the amplitude of the bounce */
  6478. bounciness?: number);
  6479. /** @hidden */
  6480. easeInCore(gradient: number): number;
  6481. }
  6482. /**
  6483. * Easing function with a power of 3 shape (see link below).
  6484. * @see https://easings.net/#easeInCubic
  6485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6486. */
  6487. export class CubicEase extends EasingFunction implements IEasingFunction {
  6488. /** @hidden */
  6489. easeInCore(gradient: number): number;
  6490. }
  6491. /**
  6492. * Easing function with an elastic shape (see link below).
  6493. * @see https://easings.net/#easeInElastic
  6494. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6495. */
  6496. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6497. /** Defines the number of oscillations*/
  6498. oscillations: number;
  6499. /** Defines the amplitude of the oscillations*/
  6500. springiness: number;
  6501. /**
  6502. * Instantiates an elastic easing function
  6503. * @see https://easings.net/#easeInElastic
  6504. * @param oscillations Defines the number of oscillations
  6505. * @param springiness Defines the amplitude of the oscillations
  6506. */
  6507. constructor(
  6508. /** Defines the number of oscillations*/
  6509. oscillations?: number,
  6510. /** Defines the amplitude of the oscillations*/
  6511. springiness?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with an exponential shape (see link below).
  6517. * @see https://easings.net/#easeInExpo
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the exponent of the function */
  6522. exponent: number;
  6523. /**
  6524. * Instantiates an exponential easing function
  6525. * @see https://easings.net/#easeInExpo
  6526. * @param exponent Defines the exponent of the function
  6527. */
  6528. constructor(
  6529. /** Defines the exponent of the function */
  6530. exponent?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class PowerEase extends EasingFunction implements IEasingFunction {
  6540. /** Defines the power of the function */
  6541. power: number;
  6542. /**
  6543. * Instantiates an power base easing function
  6544. * @see https://easings.net/#easeInQuad
  6545. * @param power Defines the power of the function
  6546. */
  6547. constructor(
  6548. /** Defines the power of the function */
  6549. power?: number);
  6550. /** @hidden */
  6551. easeInCore(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a power of 2 shape (see link below).
  6555. * @see https://easings.net/#easeInQuad
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6559. /** @hidden */
  6560. easeInCore(gradient: number): number;
  6561. }
  6562. /**
  6563. * Easing function with a power of 4 shape (see link below).
  6564. * @see https://easings.net/#easeInQuart
  6565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6566. */
  6567. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power of 5 shape (see link below).
  6573. * @see https://easings.net/#easeInQuint
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6577. /** @hidden */
  6578. easeInCore(gradient: number): number;
  6579. }
  6580. /**
  6581. * Easing function with a sin shape (see link below).
  6582. * @see https://easings.net/#easeInSine
  6583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6584. */
  6585. export class SineEase extends EasingFunction implements IEasingFunction {
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bezier shape (see link below).
  6591. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the x component of the start tangent in the bezier curve */
  6596. x1: number;
  6597. /** Defines the y component of the start tangent in the bezier curve */
  6598. y1: number;
  6599. /** Defines the x component of the end tangent in the bezier curve */
  6600. x2: number;
  6601. /** Defines the y component of the end tangent in the bezier curve */
  6602. y2: number;
  6603. /**
  6604. * Instantiates a bezier function
  6605. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6606. * @param x1 Defines the x component of the start tangent in the bezier curve
  6607. * @param y1 Defines the y component of the start tangent in the bezier curve
  6608. * @param x2 Defines the x component of the end tangent in the bezier curve
  6609. * @param y2 Defines the y component of the end tangent in the bezier curve
  6610. */
  6611. constructor(
  6612. /** Defines the x component of the start tangent in the bezier curve */
  6613. x1?: number,
  6614. /** Defines the y component of the start tangent in the bezier curve */
  6615. y1?: number,
  6616. /** Defines the x component of the end tangent in the bezier curve */
  6617. x2?: number,
  6618. /** Defines the y component of the end tangent in the bezier curve */
  6619. y2?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. }
  6624. declare module "babylonjs/Behaviors/behavior" {
  6625. import { Nullable } from "babylonjs/types";
  6626. /**
  6627. * Interface used to define a behavior
  6628. */
  6629. export interface Behavior<T> {
  6630. /** gets or sets behavior's name */
  6631. name: string;
  6632. /**
  6633. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6634. */
  6635. init(): void;
  6636. /**
  6637. * Called when the behavior is attached to a target
  6638. * @param target defines the target where the behavior is attached to
  6639. */
  6640. attach(target: T): void;
  6641. /**
  6642. * Called when the behavior is detached from its target
  6643. */
  6644. detach(): void;
  6645. }
  6646. /**
  6647. * Interface implemented by classes supporting behaviors
  6648. */
  6649. export interface IBehaviorAware<T> {
  6650. /**
  6651. * Attach a behavior
  6652. * @param behavior defines the behavior to attach
  6653. * @returns the current host
  6654. */
  6655. addBehavior(behavior: Behavior<T>): T;
  6656. /**
  6657. * Remove a behavior from the current object
  6658. * @param behavior defines the behavior to detach
  6659. * @returns the current host
  6660. */
  6661. removeBehavior(behavior: Behavior<T>): T;
  6662. /**
  6663. * Gets a behavior using its name to search
  6664. * @param name defines the name to search
  6665. * @returns the behavior or null if not found
  6666. */
  6667. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6668. }
  6669. }
  6670. declare module "babylonjs/Animations/runtimeAnimation" {
  6671. import { Animation } from "babylonjs/Animations/animation";
  6672. import { Animatable } from "babylonjs/Animations/animatable";
  6673. import { Scene } from "babylonjs/scene";
  6674. /**
  6675. * Defines a runtime animation
  6676. */
  6677. export class RuntimeAnimation {
  6678. private _events;
  6679. /**
  6680. * The current frame of the runtime animation
  6681. */
  6682. private _currentFrame;
  6683. /**
  6684. * The animation used by the runtime animation
  6685. */
  6686. private _animation;
  6687. /**
  6688. * The target of the runtime animation
  6689. */
  6690. private _target;
  6691. /**
  6692. * The initiating animatable
  6693. */
  6694. private _host;
  6695. /**
  6696. * The original value of the runtime animation
  6697. */
  6698. private _originalValue;
  6699. /**
  6700. * The original blend value of the runtime animation
  6701. */
  6702. private _originalBlendValue;
  6703. /**
  6704. * The offsets cache of the runtime animation
  6705. */
  6706. private _offsetsCache;
  6707. /**
  6708. * The high limits cache of the runtime animation
  6709. */
  6710. private _highLimitsCache;
  6711. /**
  6712. * Specifies if the runtime animation has been stopped
  6713. */
  6714. private _stopped;
  6715. /**
  6716. * The blending factor of the runtime animation
  6717. */
  6718. private _blendingFactor;
  6719. /**
  6720. * The BabylonJS scene
  6721. */
  6722. private _scene;
  6723. /**
  6724. * The current value of the runtime animation
  6725. */
  6726. private _currentValue;
  6727. /** @hidden */
  6728. _workValue: any;
  6729. /**
  6730. * The active target of the runtime animation
  6731. */
  6732. private _activeTarget;
  6733. /**
  6734. * The target path of the runtime animation
  6735. */
  6736. private _targetPath;
  6737. /**
  6738. * The weight of the runtime animation
  6739. */
  6740. private _weight;
  6741. /**
  6742. * The ratio offset of the runtime animation
  6743. */
  6744. private _ratioOffset;
  6745. /**
  6746. * The previous delay of the runtime animation
  6747. */
  6748. private _previousDelay;
  6749. /**
  6750. * The previous ratio of the runtime animation
  6751. */
  6752. private _previousRatio;
  6753. /**
  6754. * Gets the current frame of the runtime animation
  6755. */
  6756. readonly currentFrame: number;
  6757. /**
  6758. * Gets the weight of the runtime animation
  6759. */
  6760. readonly weight: number;
  6761. /**
  6762. * Gets the current value of the runtime animation
  6763. */
  6764. readonly currentValue: any;
  6765. /**
  6766. * Gets the target path of the runtime animation
  6767. */
  6768. readonly targetPath: string;
  6769. /**
  6770. * Gets the actual target of the runtime animation
  6771. */
  6772. readonly target: any;
  6773. /**
  6774. * Create a new RuntimeAnimation object
  6775. * @param target defines the target of the animation
  6776. * @param animation defines the source animation object
  6777. * @param scene defines the hosting scene
  6778. * @param host defines the initiating Animatable
  6779. */
  6780. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6781. /**
  6782. * Gets the animation from the runtime animation
  6783. */
  6784. readonly animation: Animation;
  6785. /**
  6786. * Resets the runtime animation to the beginning
  6787. * @param restoreOriginal defines whether to restore the target property to the original value
  6788. */
  6789. reset(restoreOriginal?: boolean): void;
  6790. /**
  6791. * Specifies if the runtime animation is stopped
  6792. * @returns Boolean specifying if the runtime animation is stopped
  6793. */
  6794. isStopped(): boolean;
  6795. /**
  6796. * Disposes of the runtime animation
  6797. */
  6798. dispose(): void;
  6799. /**
  6800. * Interpolates the animation from the current frame
  6801. * @param currentFrame The frame to interpolate the animation to
  6802. * @param repeatCount The number of times that the animation should loop
  6803. * @param loopMode The type of looping mode to use
  6804. * @param offsetValue Animation offset value
  6805. * @param highLimitValue The high limit value
  6806. * @returns The interpolated value
  6807. */
  6808. private _interpolate;
  6809. /**
  6810. * Apply the interpolated value to the target
  6811. * @param currentValue defines the value computed by the animation
  6812. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6813. */
  6814. setValue(currentValue: any, weight?: number): void;
  6815. private _setValue;
  6816. /**
  6817. * Gets the loop pmode of the runtime animation
  6818. * @returns Loop Mode
  6819. */
  6820. private _getCorrectLoopMode;
  6821. /**
  6822. * Move the current animation to a given frame
  6823. * @param frame defines the frame to move to
  6824. */
  6825. goToFrame(frame: number): void;
  6826. /**
  6827. * @hidden Internal use only
  6828. */
  6829. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6830. /**
  6831. * Execute the current animation
  6832. * @param delay defines the delay to add to the current frame
  6833. * @param from defines the lower bound of the animation range
  6834. * @param to defines the upper bound of the animation range
  6835. * @param loop defines if the current animation must loop
  6836. * @param speedRatio defines the current speed ratio
  6837. * @param weight defines the weight of the animation (default is -1 so no weight)
  6838. * @param onLoop optional callback called when animation loops
  6839. * @returns a boolean indicating if the animation is running
  6840. */
  6841. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6842. }
  6843. }
  6844. declare module "babylonjs/Animations/animatable" {
  6845. import { Animation } from "babylonjs/Animations/animation";
  6846. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  6847. import { Nullable } from "babylonjs/types";
  6848. import { Observable } from "babylonjs/Misc/observable";
  6849. import { Scene } from "babylonjs/scene";
  6850. /**
  6851. * Class used to store an actual running animation
  6852. */
  6853. export class Animatable {
  6854. /** defines the target object */
  6855. target: any;
  6856. /** defines the starting frame number (default is 0) */
  6857. fromFrame: number;
  6858. /** defines the ending frame number (default is 100) */
  6859. toFrame: number;
  6860. /** defines if the animation must loop (default is false) */
  6861. loopAnimation: boolean;
  6862. /** defines a callback to call when animation ends if it is not looping */
  6863. onAnimationEnd?: (() => void) | null | undefined;
  6864. /** defines a callback to call when animation loops */
  6865. onAnimationLoop?: (() => void) | null | undefined;
  6866. private _localDelayOffset;
  6867. private _pausedDelay;
  6868. private _runtimeAnimations;
  6869. private _paused;
  6870. private _scene;
  6871. private _speedRatio;
  6872. private _weight;
  6873. private _syncRoot;
  6874. /**
  6875. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6876. * This will only apply for non looping animation (default is true)
  6877. */
  6878. disposeOnEnd: boolean;
  6879. /**
  6880. * Gets a boolean indicating if the animation has started
  6881. */
  6882. animationStarted: boolean;
  6883. /**
  6884. * Observer raised when the animation ends
  6885. */
  6886. onAnimationEndObservable: Observable<Animatable>;
  6887. /**
  6888. * Observer raised when the animation loops
  6889. */
  6890. onAnimationLoopObservable: Observable<Animatable>;
  6891. /**
  6892. * Gets the root Animatable used to synchronize and normalize animations
  6893. */
  6894. readonly syncRoot: Animatable;
  6895. /**
  6896. * Gets the current frame of the first RuntimeAnimation
  6897. * Used to synchronize Animatables
  6898. */
  6899. readonly masterFrame: number;
  6900. /**
  6901. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6902. */
  6903. weight: number;
  6904. /**
  6905. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6906. */
  6907. speedRatio: number;
  6908. /**
  6909. * Creates a new Animatable
  6910. * @param scene defines the hosting scene
  6911. * @param target defines the target object
  6912. * @param fromFrame defines the starting frame number (default is 0)
  6913. * @param toFrame defines the ending frame number (default is 100)
  6914. * @param loopAnimation defines if the animation must loop (default is false)
  6915. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6916. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6917. * @param animations defines a group of animation to add to the new Animatable
  6918. * @param onAnimationLoop defines a callback to call when animation loops
  6919. */
  6920. constructor(scene: Scene,
  6921. /** defines the target object */
  6922. target: any,
  6923. /** defines the starting frame number (default is 0) */
  6924. fromFrame?: number,
  6925. /** defines the ending frame number (default is 100) */
  6926. toFrame?: number,
  6927. /** defines if the animation must loop (default is false) */
  6928. loopAnimation?: boolean, speedRatio?: number,
  6929. /** defines a callback to call when animation ends if it is not looping */
  6930. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6931. /** defines a callback to call when animation loops */
  6932. onAnimationLoop?: (() => void) | null | undefined);
  6933. /**
  6934. * Synchronize and normalize current Animatable with a source Animatable
  6935. * This is useful when using animation weights and when animations are not of the same length
  6936. * @param root defines the root Animatable to synchronize with
  6937. * @returns the current Animatable
  6938. */
  6939. syncWith(root: Animatable): Animatable;
  6940. /**
  6941. * Gets the list of runtime animations
  6942. * @returns an array of RuntimeAnimation
  6943. */
  6944. getAnimations(): RuntimeAnimation[];
  6945. /**
  6946. * Adds more animations to the current animatable
  6947. * @param target defines the target of the animations
  6948. * @param animations defines the new animations to add
  6949. */
  6950. appendAnimations(target: any, animations: Animation[]): void;
  6951. /**
  6952. * Gets the source animation for a specific property
  6953. * @param property defines the propertyu to look for
  6954. * @returns null or the source animation for the given property
  6955. */
  6956. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6957. /**
  6958. * Gets the runtime animation for a specific property
  6959. * @param property defines the propertyu to look for
  6960. * @returns null or the runtime animation for the given property
  6961. */
  6962. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6963. /**
  6964. * Resets the animatable to its original state
  6965. */
  6966. reset(): void;
  6967. /**
  6968. * Allows the animatable to blend with current running animations
  6969. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6970. * @param blendingSpeed defines the blending speed to use
  6971. */
  6972. enableBlending(blendingSpeed: number): void;
  6973. /**
  6974. * Disable animation blending
  6975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6976. */
  6977. disableBlending(): void;
  6978. /**
  6979. * Jump directly to a given frame
  6980. * @param frame defines the frame to jump to
  6981. */
  6982. goToFrame(frame: number): void;
  6983. /**
  6984. * Pause the animation
  6985. */
  6986. pause(): void;
  6987. /**
  6988. * Restart the animation
  6989. */
  6990. restart(): void;
  6991. private _raiseOnAnimationEnd;
  6992. /**
  6993. * Stop and delete the current animation
  6994. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6995. * @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)
  6996. */
  6997. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6998. /**
  6999. * Wait asynchronously for the animation to end
  7000. * @returns a promise which will be fullfilled when the animation ends
  7001. */
  7002. waitAsync(): Promise<Animatable>;
  7003. /** @hidden */
  7004. _animate(delay: number): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7008. /**
  7009. * Class used to override all child animations of a given target
  7010. */
  7011. export class AnimationPropertiesOverride {
  7012. /**
  7013. * Gets or sets a value indicating if animation blending must be used
  7014. */
  7015. enableBlending: boolean;
  7016. /**
  7017. * Gets or sets the blending speed to use when enableBlending is true
  7018. */
  7019. blendingSpeed: number;
  7020. /**
  7021. * Gets or sets the default loop mode to use
  7022. */
  7023. loopMode: number;
  7024. }
  7025. }
  7026. declare module "babylonjs/Collisions/collider" {
  7027. import { Nullable, IndicesArray } from "babylonjs/types";
  7028. import { Vector3, Plane } from "babylonjs/Maths/math";
  7029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7030. /** @hidden */
  7031. export class Collider {
  7032. /** Define if a collision was found */
  7033. collisionFound: boolean;
  7034. /**
  7035. * Define last intersection point in local space
  7036. */
  7037. intersectionPoint: Vector3;
  7038. /**
  7039. * Define last collided mesh
  7040. */
  7041. collidedMesh: Nullable<AbstractMesh>;
  7042. private _collisionPoint;
  7043. private _planeIntersectionPoint;
  7044. private _tempVector;
  7045. private _tempVector2;
  7046. private _tempVector3;
  7047. private _tempVector4;
  7048. private _edge;
  7049. private _baseToVertex;
  7050. private _destinationPoint;
  7051. private _slidePlaneNormal;
  7052. private _displacementVector;
  7053. /** @hidden */
  7054. _radius: Vector3;
  7055. /** @hidden */
  7056. _retry: number;
  7057. private _velocity;
  7058. private _basePoint;
  7059. private _epsilon;
  7060. /** @hidden */
  7061. _velocityWorldLength: number;
  7062. /** @hidden */
  7063. _basePointWorld: Vector3;
  7064. private _velocityWorld;
  7065. private _normalizedVelocity;
  7066. /** @hidden */
  7067. _initialVelocity: Vector3;
  7068. /** @hidden */
  7069. _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */
  7078. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7079. /** @hidden */
  7080. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7081. /** @hidden */
  7082. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7083. /** @hidden */
  7084. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7085. /** @hidden */
  7086. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7087. /** @hidden */
  7088. _getResponse(pos: Vector3, vel: Vector3): void;
  7089. }
  7090. }
  7091. declare module "babylonjs/Collisions/intersectionInfo" {
  7092. import { Nullable } from "babylonjs/types";
  7093. /**
  7094. * @hidden
  7095. */
  7096. export class IntersectionInfo {
  7097. bu: Nullable<number>;
  7098. bv: Nullable<number>;
  7099. distance: number;
  7100. faceId: number;
  7101. subMeshId: number;
  7102. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7103. }
  7104. }
  7105. declare module "babylonjs/Actions/actionEvent" {
  7106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7107. import { Nullable } from "babylonjs/types";
  7108. import { Sprite } from "babylonjs/Sprites/sprite";
  7109. import { Scene } from "babylonjs/scene";
  7110. import { Vector2 } from "babylonjs/Maths/math";
  7111. /**
  7112. * ActionEvent is the event being sent when an action is triggered.
  7113. */
  7114. export class ActionEvent {
  7115. /** The mesh or sprite that triggered the action */
  7116. source: any;
  7117. /** The X mouse cursor position at the time of the event */
  7118. pointerX: number;
  7119. /** The Y mouse cursor position at the time of the event */
  7120. pointerY: number;
  7121. /** The mesh that is currently pointed at (can be null) */
  7122. meshUnderPointer: Nullable<AbstractMesh>;
  7123. /** the original (browser) event that triggered the ActionEvent */
  7124. sourceEvent?: any;
  7125. /** additional data for the event */
  7126. additionalData?: any;
  7127. /**
  7128. * Creates a new ActionEvent
  7129. * @param source The mesh or sprite that triggered the action
  7130. * @param pointerX The X mouse cursor position at the time of the event
  7131. * @param pointerY The Y mouse cursor position at the time of the event
  7132. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7133. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7134. * @param additionalData additional data for the event
  7135. */
  7136. constructor(
  7137. /** The mesh or sprite that triggered the action */
  7138. source: any,
  7139. /** The X mouse cursor position at the time of the event */
  7140. pointerX: number,
  7141. /** The Y mouse cursor position at the time of the event */
  7142. pointerY: number,
  7143. /** The mesh that is currently pointed at (can be null) */
  7144. meshUnderPointer: Nullable<AbstractMesh>,
  7145. /** the original (browser) event that triggered the ActionEvent */
  7146. sourceEvent?: any,
  7147. /** additional data for the event */
  7148. additionalData?: any);
  7149. /**
  7150. * Helper function to auto-create an ActionEvent from a source mesh.
  7151. * @param source The source mesh that triggered the event
  7152. * @param evt The original (browser) event
  7153. * @param additionalData additional data for the event
  7154. * @returns the new ActionEvent
  7155. */
  7156. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7157. /**
  7158. * Helper function to auto-create an ActionEvent from a source sprite
  7159. * @param source The source sprite that triggered the event
  7160. * @param scene Scene associated with the sprite
  7161. * @param evt The original (browser) event
  7162. * @param additionalData additional data for the event
  7163. * @returns the new ActionEvent
  7164. */
  7165. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7166. /**
  7167. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7168. * @param scene the scene where the event occurred
  7169. * @param evt The original (browser) event
  7170. * @returns the new ActionEvent
  7171. */
  7172. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7173. /**
  7174. * Helper function to auto-create an ActionEvent from a primitive
  7175. * @param prim defines the target primitive
  7176. * @param pointerPos defines the pointer position
  7177. * @param evt The original (browser) event
  7178. * @param additionalData additional data for the event
  7179. * @returns the new ActionEvent
  7180. */
  7181. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingSphere" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7187. /**
  7188. * Class used to store bounding sphere information
  7189. */
  7190. export class BoundingSphere {
  7191. /**
  7192. * Gets the center of the bounding sphere in local space
  7193. */
  7194. readonly center: Vector3;
  7195. /**
  7196. * Radius of the bounding sphere in local space
  7197. */
  7198. radius: number;
  7199. /**
  7200. * Gets the center of the bounding sphere in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Radius of the bounding sphere in world space
  7205. */
  7206. radiusWorld: number;
  7207. /**
  7208. * Gets the minimum vector in local space
  7209. */
  7210. readonly minimum: Vector3;
  7211. /**
  7212. * Gets the maximum vector in local space
  7213. */
  7214. readonly maximum: Vector3;
  7215. private _worldMatrix;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Creates a new bounding sphere
  7219. * @param min defines the minimum vector (in local space)
  7220. * @param max defines the maximum vector (in local space)
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * Scale the current bounding sphere by applying a scale factor
  7233. * @param factor defines the scale factor to apply
  7234. * @returns the current bounding box
  7235. */
  7236. scale(factor: number): BoundingSphere;
  7237. /**
  7238. * Gets the world matrix of the bounding box
  7239. * @returns a matrix
  7240. */
  7241. getWorldMatrix(): DeepImmutable<Matrix>;
  7242. /** @hidden */
  7243. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Tests if the bounding sphere is intersecting the frustum planes
  7246. * @param frustumPlanes defines the frustum planes to test
  7247. * @returns true if there is an intersection
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7250. /**
  7251. * Tests if the bounding sphere center is in between the frustum planes.
  7252. * Used for optimistic fast inclusion.
  7253. * @param frustumPlanes defines the frustum planes to test
  7254. * @returns true if the sphere center is in between the frustum planes
  7255. */
  7256. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7257. /**
  7258. * Tests if a point is inside the bounding sphere
  7259. * @param point defines the point to test
  7260. * @returns true if the point is inside the bounding sphere
  7261. */
  7262. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7263. /**
  7264. * Checks if two sphere intersct
  7265. * @param sphere0 sphere 0
  7266. * @param sphere1 sphere 1
  7267. * @returns true if the speres intersect
  7268. */
  7269. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Culling/boundingBox" {
  7273. import { DeepImmutable } from "babylonjs/types";
  7274. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7275. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7276. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7277. /**
  7278. * Class used to store bounding box information
  7279. */
  7280. export class BoundingBox implements ICullable {
  7281. /**
  7282. * Gets the 8 vectors representing the bounding box in local space
  7283. */
  7284. readonly vectors: Vector3[];
  7285. /**
  7286. * Gets the center of the bounding box in local space
  7287. */
  7288. readonly center: Vector3;
  7289. /**
  7290. * Gets the center of the bounding box in world space
  7291. */
  7292. readonly centerWorld: Vector3;
  7293. /**
  7294. * Gets the extend size in local space
  7295. */
  7296. readonly extendSize: Vector3;
  7297. /**
  7298. * Gets the extend size in world space
  7299. */
  7300. readonly extendSizeWorld: Vector3;
  7301. /**
  7302. * Gets the OBB (object bounding box) directions
  7303. */
  7304. readonly directions: Vector3[];
  7305. /**
  7306. * Gets the 8 vectors representing the bounding box in world space
  7307. */
  7308. readonly vectorsWorld: Vector3[];
  7309. /**
  7310. * Gets the minimum vector in world space
  7311. */
  7312. readonly minimumWorld: Vector3;
  7313. /**
  7314. * Gets the maximum vector in world space
  7315. */
  7316. readonly maximumWorld: Vector3;
  7317. /**
  7318. * Gets the minimum vector in local space
  7319. */
  7320. readonly minimum: Vector3;
  7321. /**
  7322. * Gets the maximum vector in local space
  7323. */
  7324. readonly maximum: Vector3;
  7325. private _worldMatrix;
  7326. private static readonly TmpVector3;
  7327. /**
  7328. * @hidden
  7329. */
  7330. _tag: number;
  7331. /**
  7332. * Creates a new bounding box
  7333. * @param min defines the minimum vector (in local space)
  7334. * @param max defines the maximum vector (in local space)
  7335. * @param worldMatrix defines the new world matrix
  7336. */
  7337. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7338. /**
  7339. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7340. * @param min defines the new minimum vector (in local space)
  7341. * @param max defines the new maximum vector (in local space)
  7342. * @param worldMatrix defines the new world matrix
  7343. */
  7344. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7345. /**
  7346. * Scale the current bounding box by applying a scale factor
  7347. * @param factor defines the scale factor to apply
  7348. * @returns the current bounding box
  7349. */
  7350. scale(factor: number): BoundingBox;
  7351. /**
  7352. * Gets the world matrix of the bounding box
  7353. * @returns a matrix
  7354. */
  7355. getWorldMatrix(): DeepImmutable<Matrix>;
  7356. /** @hidden */
  7357. _update(world: DeepImmutable<Matrix>): void;
  7358. /**
  7359. * Tests if the bounding box is intersecting the frustum planes
  7360. * @param frustumPlanes defines the frustum planes to test
  7361. * @returns true if there is an intersection
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7364. /**
  7365. * Tests if the bounding box is entirely inside the frustum planes
  7366. * @param frustumPlanes defines the frustum planes to test
  7367. * @returns true if there is an inclusion
  7368. */
  7369. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7370. /**
  7371. * Tests if a point is inside the bounding box
  7372. * @param point defines the point to test
  7373. * @returns true if the point is inside the bounding box
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Tests if the bounding box intersects with a bounding sphere
  7378. * @param sphere defines the sphere to test
  7379. * @returns true if there is an intersection
  7380. */
  7381. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7382. /**
  7383. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7384. * @param min defines the min vector to use
  7385. * @param max defines the max vector to use
  7386. * @returns true if there is an intersection
  7387. */
  7388. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7389. /**
  7390. * Tests if two bounding boxes are intersections
  7391. * @param box0 defines the first box to test
  7392. * @param box1 defines the second box to test
  7393. * @returns true if there is an intersection
  7394. */
  7395. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7396. /**
  7397. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7398. * @param minPoint defines the minimum vector of the bounding box
  7399. * @param maxPoint defines the maximum vector of the bounding box
  7400. * @param sphereCenter defines the sphere center
  7401. * @param sphereRadius defines the sphere radius
  7402. * @returns true if there is an intersection
  7403. */
  7404. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7405. /**
  7406. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7407. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7408. * @param frustumPlanes defines the frustum planes to test
  7409. * @return true if there is an inclusion
  7410. */
  7411. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7412. /**
  7413. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7414. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7415. * @param frustumPlanes defines the frustum planes to test
  7416. * @return true if there is an intersection
  7417. */
  7418. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7419. }
  7420. }
  7421. declare module "babylonjs/Culling/boundingInfo" {
  7422. import { DeepImmutable } from "babylonjs/types";
  7423. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7424. import { Collider } from "babylonjs/Collisions/collider";
  7425. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7426. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7427. /**
  7428. * Interface for cullable objects
  7429. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7430. */
  7431. export interface ICullable {
  7432. /**
  7433. * Checks if the object or part of the object is in the frustum
  7434. * @param frustumPlanes Camera near/planes
  7435. * @returns true if the object is in frustum otherwise false
  7436. */
  7437. isInFrustum(frustumPlanes: Plane[]): boolean;
  7438. /**
  7439. * Checks if a cullable object (mesh...) is in the camera frustum
  7440. * Unlike isInFrustum this cheks the full bounding box
  7441. * @param frustumPlanes Camera near/planes
  7442. * @returns true if the object is in frustum otherwise false
  7443. */
  7444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7445. }
  7446. /**
  7447. * Info for a bounding data of a mesh
  7448. */
  7449. export class BoundingInfo implements ICullable {
  7450. /**
  7451. * Bounding box for the mesh
  7452. */
  7453. readonly boundingBox: BoundingBox;
  7454. /**
  7455. * Bounding sphere for the mesh
  7456. */
  7457. readonly boundingSphere: BoundingSphere;
  7458. private _isLocked;
  7459. private static readonly TmpVector3;
  7460. /**
  7461. * Constructs bounding info
  7462. * @param minimum min vector of the bounding box/sphere
  7463. * @param maximum max vector of the bounding box/sphere
  7464. * @param worldMatrix defines the new world matrix
  7465. */
  7466. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7467. /**
  7468. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7469. * @param min defines the new minimum vector (in local space)
  7470. * @param max defines the new maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7474. /**
  7475. * min vector of the bounding box/sphere
  7476. */
  7477. readonly minimum: Vector3;
  7478. /**
  7479. * max vector of the bounding box/sphere
  7480. */
  7481. readonly maximum: Vector3;
  7482. /**
  7483. * If the info is locked and won't be updated to avoid perf overhead
  7484. */
  7485. isLocked: boolean;
  7486. /**
  7487. * Updates the bounding sphere and box
  7488. * @param world world matrix to be used to update
  7489. */
  7490. update(world: DeepImmutable<Matrix>): void;
  7491. /**
  7492. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7493. * @param center New center of the bounding info
  7494. * @param extend New extend of the bounding info
  7495. * @returns the current bounding info
  7496. */
  7497. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7498. /**
  7499. * Scale the current bounding info by applying a scale factor
  7500. * @param factor defines the scale factor to apply
  7501. * @returns the current bounding info
  7502. */
  7503. scale(factor: number): BoundingInfo;
  7504. /**
  7505. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7506. * @param frustumPlanes defines the frustum to test
  7507. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7508. * @returns true if the bounding info is in the frustum planes
  7509. */
  7510. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7511. /**
  7512. * Gets the world distance between the min and max points of the bounding box
  7513. */
  7514. readonly diagonalLength: number;
  7515. /**
  7516. * Checks if a cullable object (mesh...) is in the camera frustum
  7517. * Unlike isInFrustum this cheks the full bounding box
  7518. * @param frustumPlanes Camera near/planes
  7519. * @returns true if the object is in frustum otherwise false
  7520. */
  7521. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7522. /** @hidden */
  7523. _checkCollision(collider: Collider): boolean;
  7524. /**
  7525. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7526. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7527. * @param point the point to check intersection with
  7528. * @returns if the point intersects
  7529. */
  7530. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7531. /**
  7532. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7533. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7534. * @param boundingInfo the bounding info to check intersection with
  7535. * @param precise if the intersection should be done using OBB
  7536. * @returns if the bounding info intersects
  7537. */
  7538. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7539. }
  7540. }
  7541. declare module "babylonjs/Misc/smartArray" {
  7542. /**
  7543. * Defines an array and its length.
  7544. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7545. */
  7546. export interface ISmartArrayLike<T> {
  7547. /**
  7548. * The data of the array.
  7549. */
  7550. data: Array<T>;
  7551. /**
  7552. * The active length of the array.
  7553. */
  7554. length: number;
  7555. }
  7556. /**
  7557. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7558. */
  7559. export class SmartArray<T> implements ISmartArrayLike<T> {
  7560. /**
  7561. * The full set of data from the array.
  7562. */
  7563. data: Array<T>;
  7564. /**
  7565. * The active length of the array.
  7566. */
  7567. length: number;
  7568. protected _id: number;
  7569. /**
  7570. * Instantiates a Smart Array.
  7571. * @param capacity defines the default capacity of the array.
  7572. */
  7573. constructor(capacity: number);
  7574. /**
  7575. * Pushes a value at the end of the active data.
  7576. * @param value defines the object to push in the array.
  7577. */
  7578. push(value: T): void;
  7579. /**
  7580. * Iterates over the active data and apply the lambda to them.
  7581. * @param func defines the action to apply on each value.
  7582. */
  7583. forEach(func: (content: T) => void): void;
  7584. /**
  7585. * Sorts the full sets of data.
  7586. * @param compareFn defines the comparison function to apply.
  7587. */
  7588. sort(compareFn: (a: T, b: T) => number): void;
  7589. /**
  7590. * Resets the active data to an empty array.
  7591. */
  7592. reset(): void;
  7593. /**
  7594. * Releases all the data from the array as well as the array.
  7595. */
  7596. dispose(): void;
  7597. /**
  7598. * Concats the active data with a given array.
  7599. * @param array defines the data to concatenate with.
  7600. */
  7601. concat(array: any): void;
  7602. /**
  7603. * Returns the position of a value in the active data.
  7604. * @param value defines the value to find the index for
  7605. * @returns the index if found in the active data otherwise -1
  7606. */
  7607. indexOf(value: T): number;
  7608. /**
  7609. * Returns whether an element is part of the active data.
  7610. * @param value defines the value to look for
  7611. * @returns true if found in the active data otherwise false
  7612. */
  7613. contains(value: T): boolean;
  7614. private static _GlobalId;
  7615. }
  7616. /**
  7617. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7618. * The data in this array can only be present once
  7619. */
  7620. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7621. private _duplicateId;
  7622. /**
  7623. * Pushes a value at the end of the active data.
  7624. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7625. * @param value defines the object to push in the array.
  7626. */
  7627. push(value: T): void;
  7628. /**
  7629. * Pushes a value at the end of the active data.
  7630. * If the data is already present, it won t be added again
  7631. * @param value defines the object to push in the array.
  7632. * @returns true if added false if it was already present
  7633. */
  7634. pushNoDuplicate(value: T): boolean;
  7635. /**
  7636. * Resets the active data to an empty array.
  7637. */
  7638. reset(): void;
  7639. /**
  7640. * Concats the active data with a given array.
  7641. * This ensures no dupplicate will be present in the result.
  7642. * @param array defines the data to concatenate with.
  7643. */
  7644. concatWithNoDuplicate(array: any): void;
  7645. }
  7646. }
  7647. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7648. import { Nullable } from "babylonjs/types";
  7649. import { Scene } from "babylonjs/scene";
  7650. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. /**
  7675. * Returns the bounding box size
  7676. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7677. */
  7678. boundingBoxSize: Vector3;
  7679. protected _rotationY: number;
  7680. /**
  7681. * Sets texture matrix rotation angle around Y axis in radians.
  7682. */
  7683. /**
  7684. * Gets texture matrix rotation angle around Y axis radians.
  7685. */
  7686. rotationY: number;
  7687. /**
  7688. * Are mip maps generated for this texture or not.
  7689. */
  7690. readonly noMipmap: boolean;
  7691. private _noMipmap;
  7692. private _files;
  7693. private _extensions;
  7694. private _textureMatrix;
  7695. private _format;
  7696. private _createPolynomials;
  7697. /** @hidden */
  7698. _prefiltered: boolean;
  7699. /**
  7700. * Creates a cube texture from an array of image urls
  7701. * @param files defines an array of image urls
  7702. * @param scene defines the hosting scene
  7703. * @param noMipmap specifies if mip maps are not used
  7704. * @returns a cube texture
  7705. */
  7706. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7707. /**
  7708. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7709. * @param url defines the url of the prefiltered texture
  7710. * @param scene defines the scene the texture is attached to
  7711. * @param forcedExtension defines the extension of the file if different from the url
  7712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7713. * @return the prefiltered texture
  7714. */
  7715. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7716. /**
  7717. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7718. * as prefiltered data.
  7719. * @param rootUrl defines the url of the texture or the root name of the six images
  7720. * @param scene defines the scene the texture is attached to
  7721. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7722. * @param noMipmap defines if mipmaps should be created or not
  7723. * @param files defines the six files to load for the different faces
  7724. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7725. * @param onError defines a callback triggered in case of error during load
  7726. * @param format defines the internal format to use for the texture once loaded
  7727. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7728. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7729. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @return the cube texture
  7733. */
  7734. 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);
  7735. /**
  7736. * Get the current class name of the texture useful for serialization or dynamic coding.
  7737. * @returns "CubeTexture"
  7738. */
  7739. getClassName(): string;
  7740. /**
  7741. * Update the url (and optional buffer) of this texture if url was null during construction.
  7742. * @param url the url of the texture
  7743. * @param forcedExtension defines the extension to use
  7744. * @param onLoad callback called when the texture is loaded (defaults to null)
  7745. */
  7746. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7747. /**
  7748. * Delays loading of the cube texture
  7749. * @param forcedExtension defines the extension to use
  7750. */
  7751. delayLoad(forcedExtension?: string): void;
  7752. /**
  7753. * Returns the reflection texture matrix
  7754. * @returns the reflection texture matrix
  7755. */
  7756. getReflectionTextureMatrix(): Matrix;
  7757. /**
  7758. * Sets the reflection texture matrix
  7759. * @param value Reflection texture matrix
  7760. */
  7761. setReflectionTextureMatrix(value: Matrix): void;
  7762. /**
  7763. * Parses text to create a cube texture
  7764. * @param parsedTexture define the serialized text to read from
  7765. * @param scene defines the hosting scene
  7766. * @param rootUrl defines the root url of the cube texture
  7767. * @returns a cube texture
  7768. */
  7769. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7770. /**
  7771. * Makes a clone, or deep copy, of the cube texture
  7772. * @returns a new cube texture
  7773. */
  7774. clone(): CubeTexture;
  7775. }
  7776. }
  7777. declare module "babylonjs/Shaders/postprocess.vertex" {
  7778. /** @hidden */
  7779. export var postprocessVertexShader: {
  7780. name: string;
  7781. shader: string;
  7782. };
  7783. }
  7784. declare module "babylonjs/Cameras/targetCamera" {
  7785. import { Nullable } from "babylonjs/types";
  7786. import { Camera } from "babylonjs/Cameras/camera";
  7787. import { Scene } from "babylonjs/scene";
  7788. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7789. /**
  7790. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7791. * This is the base of the follow, arc rotate cameras and Free camera
  7792. * @see http://doc.babylonjs.com/features/cameras
  7793. */
  7794. export class TargetCamera extends Camera {
  7795. private static _RigCamTransformMatrix;
  7796. private static _TargetTransformMatrix;
  7797. private static _TargetFocalPoint;
  7798. /**
  7799. * Define the current direction the camera is moving to
  7800. */
  7801. cameraDirection: Vector3;
  7802. /**
  7803. * Define the current rotation the camera is rotating to
  7804. */
  7805. cameraRotation: Vector2;
  7806. /**
  7807. * When set, the up vector of the camera will be updated by the rotation of the camera
  7808. */
  7809. updateUpVectorFromRotation: boolean;
  7810. private _tmpQuaternion;
  7811. /**
  7812. * Define the current rotation of the camera
  7813. */
  7814. rotation: Vector3;
  7815. /**
  7816. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7817. */
  7818. rotationQuaternion: Quaternion;
  7819. /**
  7820. * Define the current speed of the camera
  7821. */
  7822. speed: number;
  7823. /**
  7824. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7825. * around all axis.
  7826. */
  7827. noRotationConstraint: boolean;
  7828. /**
  7829. * Define the current target of the camera as an object or a position.
  7830. */
  7831. lockedTarget: any;
  7832. /** @hidden */
  7833. _currentTarget: Vector3;
  7834. /** @hidden */
  7835. _initialFocalDistance: number;
  7836. /** @hidden */
  7837. _viewMatrix: Matrix;
  7838. /** @hidden */
  7839. _camMatrix: Matrix;
  7840. /** @hidden */
  7841. _cameraTransformMatrix: Matrix;
  7842. /** @hidden */
  7843. _cameraRotationMatrix: Matrix;
  7844. /** @hidden */
  7845. _referencePoint: Vector3;
  7846. /** @hidden */
  7847. _transformedReferencePoint: Vector3;
  7848. protected _globalCurrentTarget: Vector3;
  7849. protected _globalCurrentUpVector: Vector3;
  7850. /** @hidden */
  7851. _reset: () => void;
  7852. private _defaultUp;
  7853. /**
  7854. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7855. * This is the base of the follow, arc rotate cameras and Free camera
  7856. * @see http://doc.babylonjs.com/features/cameras
  7857. * @param name Defines the name of the camera in the scene
  7858. * @param position Defines the start position of the camera in the scene
  7859. * @param scene Defines the scene the camera belongs to
  7860. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7861. */
  7862. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7863. /**
  7864. * Gets the position in front of the camera at a given distance.
  7865. * @param distance The distance from the camera we want the position to be
  7866. * @returns the position
  7867. */
  7868. getFrontPosition(distance: number): Vector3;
  7869. /** @hidden */
  7870. _getLockedTargetPosition(): Nullable<Vector3>;
  7871. private _storedPosition;
  7872. private _storedRotation;
  7873. private _storedRotationQuaternion;
  7874. /**
  7875. * Store current camera state of the camera (fov, position, rotation, etc..)
  7876. * @returns the camera
  7877. */
  7878. storeState(): Camera;
  7879. /**
  7880. * Restored camera state. You must call storeState() first
  7881. * @returns whether it was successful or not
  7882. * @hidden
  7883. */
  7884. _restoreStateValues(): boolean;
  7885. /** @hidden */
  7886. _initCache(): void;
  7887. /** @hidden */
  7888. _updateCache(ignoreParentClass?: boolean): void;
  7889. /** @hidden */
  7890. _isSynchronizedViewMatrix(): boolean;
  7891. /** @hidden */
  7892. _computeLocalCameraSpeed(): number;
  7893. /** @hidden */
  7894. setTarget(target: Vector3): void;
  7895. /**
  7896. * Return the current target position of the camera. This value is expressed in local space.
  7897. * @returns the target position
  7898. */
  7899. getTarget(): Vector3;
  7900. /** @hidden */
  7901. _decideIfNeedsToMove(): boolean;
  7902. /** @hidden */
  7903. _updatePosition(): void;
  7904. /** @hidden */
  7905. _checkInputs(): void;
  7906. protected _updateCameraRotationMatrix(): void;
  7907. /**
  7908. * 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)
  7909. * @returns the current camera
  7910. */
  7911. private _rotateUpVectorWithCameraRotationMatrix;
  7912. private _cachedRotationZ;
  7913. private _cachedQuaternionRotationZ;
  7914. /** @hidden */
  7915. _getViewMatrix(): Matrix;
  7916. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7917. /**
  7918. * @hidden
  7919. */
  7920. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7921. /**
  7922. * @hidden
  7923. */
  7924. _updateRigCameras(): void;
  7925. private _getRigCamPositionAndTarget;
  7926. /**
  7927. * Gets the current object class name.
  7928. * @return the class name
  7929. */
  7930. getClassName(): string;
  7931. }
  7932. }
  7933. declare module "babylonjs/Cameras/cameraInputsManager" {
  7934. import { Nullable } from "babylonjs/types";
  7935. import { Camera } from "babylonjs/Cameras/camera";
  7936. /**
  7937. * @ignore
  7938. * This is a list of all the different input types that are available in the application.
  7939. * Fo instance: ArcRotateCameraGamepadInput...
  7940. */
  7941. export var CameraInputTypes: {};
  7942. /**
  7943. * This is the contract to implement in order to create a new input class.
  7944. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7945. */
  7946. export interface ICameraInput<TCamera extends Camera> {
  7947. /**
  7948. * Defines the camera the input is attached to.
  7949. */
  7950. camera: Nullable<TCamera>;
  7951. /**
  7952. * Gets the class name of the current intput.
  7953. * @returns the class name
  7954. */
  7955. getClassName(): string;
  7956. /**
  7957. * Get the friendly name associated with the input class.
  7958. * @returns the input friendly name
  7959. */
  7960. getSimpleName(): string;
  7961. /**
  7962. * Attach the input controls to a specific dom element to get the input from.
  7963. * @param element Defines the element the controls should be listened from
  7964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7965. */
  7966. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7967. /**
  7968. * Detach the current controls from the specified dom element.
  7969. * @param element Defines the element to stop listening the inputs from
  7970. */
  7971. detachControl(element: Nullable<HTMLElement>): void;
  7972. /**
  7973. * Update the current camera state depending on the inputs that have been used this frame.
  7974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7975. */
  7976. checkInputs?: () => void;
  7977. }
  7978. /**
  7979. * Represents a map of input types to input instance or input index to input instance.
  7980. */
  7981. export interface CameraInputsMap<TCamera extends Camera> {
  7982. /**
  7983. * Accessor to the input by input type.
  7984. */
  7985. [name: string]: ICameraInput<TCamera>;
  7986. /**
  7987. * Accessor to the input by input index.
  7988. */
  7989. [idx: number]: ICameraInput<TCamera>;
  7990. }
  7991. /**
  7992. * This represents the input manager used within a camera.
  7993. * It helps dealing with all the different kind of input attached to a camera.
  7994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7995. */
  7996. export class CameraInputsManager<TCamera extends Camera> {
  7997. /**
  7998. * Defines the list of inputs attahed to the camera.
  7999. */
  8000. attached: CameraInputsMap<TCamera>;
  8001. /**
  8002. * Defines the dom element the camera is collecting inputs from.
  8003. * This is null if the controls have not been attached.
  8004. */
  8005. attachedElement: Nullable<HTMLElement>;
  8006. /**
  8007. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8008. */
  8009. noPreventDefault: boolean;
  8010. /**
  8011. * Defined the camera the input manager belongs to.
  8012. */
  8013. camera: TCamera;
  8014. /**
  8015. * Update the current camera state depending on the inputs that have been used this frame.
  8016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8017. */
  8018. checkInputs: () => void;
  8019. /**
  8020. * Instantiate a new Camera Input Manager.
  8021. * @param camera Defines the camera the input manager blongs to
  8022. */
  8023. constructor(camera: TCamera);
  8024. /**
  8025. * Add an input method to a camera
  8026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8027. * @param input camera input method
  8028. */
  8029. add(input: ICameraInput<TCamera>): void;
  8030. /**
  8031. * Remove a specific input method from a camera
  8032. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8033. * @param inputToRemove camera input method
  8034. */
  8035. remove(inputToRemove: ICameraInput<TCamera>): void;
  8036. /**
  8037. * Remove a specific input type from a camera
  8038. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8039. * @param inputType the type of the input to remove
  8040. */
  8041. removeByType(inputType: string): void;
  8042. private _addCheckInputs;
  8043. /**
  8044. * Attach the input controls to the currently attached dom element to listen the events from.
  8045. * @param input Defines the input to attach
  8046. */
  8047. attachInput(input: ICameraInput<TCamera>): void;
  8048. /**
  8049. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8050. * @param element Defines the dom element to collect the events from
  8051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8052. */
  8053. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8054. /**
  8055. * Detach the current manager inputs controls from a specific dom element.
  8056. * @param element Defines the dom element to collect the events from
  8057. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8058. */
  8059. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8060. /**
  8061. * Rebuild the dynamic inputCheck function from the current list of
  8062. * defined inputs in the manager.
  8063. */
  8064. rebuildInputCheck(): void;
  8065. /**
  8066. * Remove all attached input methods from a camera
  8067. */
  8068. clear(): void;
  8069. /**
  8070. * Serialize the current input manager attached to a camera.
  8071. * This ensures than once parsed,
  8072. * the input associated to the camera will be identical to the current ones
  8073. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8074. */
  8075. serialize(serializedCamera: any): void;
  8076. /**
  8077. * Parses an input manager serialized JSON to restore the previous list of inputs
  8078. * and states associated to a camera.
  8079. * @param parsedCamera Defines the JSON to parse
  8080. */
  8081. parse(parsedCamera: any): void;
  8082. }
  8083. }
  8084. declare module "babylonjs/Events/keyboardEvents" {
  8085. /**
  8086. * Gather the list of keyboard event types as constants.
  8087. */
  8088. export class KeyboardEventTypes {
  8089. /**
  8090. * The keydown event is fired when a key becomes active (pressed).
  8091. */
  8092. static readonly KEYDOWN: number;
  8093. /**
  8094. * The keyup event is fired when a key has been released.
  8095. */
  8096. static readonly KEYUP: number;
  8097. }
  8098. /**
  8099. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8100. */
  8101. export class KeyboardInfo {
  8102. /**
  8103. * Defines the type of event (KeyboardEventTypes)
  8104. */
  8105. type: number;
  8106. /**
  8107. * Defines the related dom event
  8108. */
  8109. event: KeyboardEvent;
  8110. /**
  8111. * Instantiates a new keyboard info.
  8112. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8113. * @param type Defines the type of event (KeyboardEventTypes)
  8114. * @param event Defines the related dom event
  8115. */
  8116. constructor(
  8117. /**
  8118. * Defines the type of event (KeyboardEventTypes)
  8119. */
  8120. type: number,
  8121. /**
  8122. * Defines the related dom event
  8123. */
  8124. event: KeyboardEvent);
  8125. }
  8126. /**
  8127. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8128. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8129. */
  8130. export class KeyboardInfoPre extends KeyboardInfo {
  8131. /**
  8132. * Defines the type of event (KeyboardEventTypes)
  8133. */
  8134. type: number;
  8135. /**
  8136. * Defines the related dom event
  8137. */
  8138. event: KeyboardEvent;
  8139. /**
  8140. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8141. */
  8142. skipOnPointerObservable: boolean;
  8143. /**
  8144. * Instantiates a new keyboard pre info.
  8145. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8146. * @param type Defines the type of event (KeyboardEventTypes)
  8147. * @param event Defines the related dom event
  8148. */
  8149. constructor(
  8150. /**
  8151. * Defines the type of event (KeyboardEventTypes)
  8152. */
  8153. type: number,
  8154. /**
  8155. * Defines the related dom event
  8156. */
  8157. event: KeyboardEvent);
  8158. }
  8159. }
  8160. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8161. import { Nullable } from "babylonjs/types";
  8162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8164. /**
  8165. * Manage the keyboard inputs to control the movement of a free camera.
  8166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8167. */
  8168. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8169. /**
  8170. * Defines the camera the input is attached to.
  8171. */
  8172. camera: FreeCamera;
  8173. /**
  8174. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8175. */
  8176. keysUp: number[];
  8177. /**
  8178. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8179. */
  8180. keysDown: number[];
  8181. /**
  8182. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8183. */
  8184. keysLeft: number[];
  8185. /**
  8186. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8187. */
  8188. keysRight: number[];
  8189. private _keys;
  8190. private _onCanvasBlurObserver;
  8191. private _onKeyboardObserver;
  8192. private _engine;
  8193. private _scene;
  8194. /**
  8195. * Attach the input controls to a specific dom element to get the input from.
  8196. * @param element Defines the element the controls should be listened from
  8197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8198. */
  8199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8200. /**
  8201. * Detach the current controls from the specified dom element.
  8202. * @param element Defines the element to stop listening the inputs from
  8203. */
  8204. detachControl(element: Nullable<HTMLElement>): void;
  8205. /**
  8206. * Update the current camera state depending on the inputs that have been used this frame.
  8207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8208. */
  8209. checkInputs(): void;
  8210. /**
  8211. * Gets the class name of the current intput.
  8212. * @returns the class name
  8213. */
  8214. getClassName(): string;
  8215. /** @hidden */
  8216. _onLostFocus(): void;
  8217. /**
  8218. * Get the friendly name associated with the input class.
  8219. * @returns the input friendly name
  8220. */
  8221. getSimpleName(): string;
  8222. }
  8223. }
  8224. declare module "babylonjs/Events/pointerEvents" {
  8225. import { Nullable } from "babylonjs/types";
  8226. import { Vector2 } from "babylonjs/Maths/math";
  8227. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  8228. import { Ray } from "babylonjs/Culling/ray";
  8229. /**
  8230. * Gather the list of pointer event types as constants.
  8231. */
  8232. export class PointerEventTypes {
  8233. /**
  8234. * 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.
  8235. */
  8236. static readonly POINTERDOWN: number;
  8237. /**
  8238. * The pointerup event is fired when a pointer is no longer active.
  8239. */
  8240. static readonly POINTERUP: number;
  8241. /**
  8242. * The pointermove event is fired when a pointer changes coordinates.
  8243. */
  8244. static readonly POINTERMOVE: number;
  8245. /**
  8246. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8247. */
  8248. static readonly POINTERWHEEL: number;
  8249. /**
  8250. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8251. */
  8252. static readonly POINTERPICK: number;
  8253. /**
  8254. * The pointertap event is fired when a the object has been touched and released without drag.
  8255. */
  8256. static readonly POINTERTAP: number;
  8257. /**
  8258. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8259. */
  8260. static readonly POINTERDOUBLETAP: number;
  8261. }
  8262. /**
  8263. * Base class of pointer info types.
  8264. */
  8265. export class PointerInfoBase {
  8266. /**
  8267. * Defines the type of event (PointerEventTypes)
  8268. */
  8269. type: number;
  8270. /**
  8271. * Defines the related dom event
  8272. */
  8273. event: PointerEvent | MouseWheelEvent;
  8274. /**
  8275. * Instantiates the base class of pointers info.
  8276. * @param type Defines the type of event (PointerEventTypes)
  8277. * @param event Defines the related dom event
  8278. */
  8279. constructor(
  8280. /**
  8281. * Defines the type of event (PointerEventTypes)
  8282. */
  8283. type: number,
  8284. /**
  8285. * Defines the related dom event
  8286. */
  8287. event: PointerEvent | MouseWheelEvent);
  8288. }
  8289. /**
  8290. * This class is used to store pointer related info for the onPrePointerObservable event.
  8291. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8292. */
  8293. export class PointerInfoPre extends PointerInfoBase {
  8294. /**
  8295. * Ray from a pointer if availible (eg. 6dof controller)
  8296. */
  8297. ray: Nullable<Ray>;
  8298. /**
  8299. * Defines the local position of the pointer on the canvas.
  8300. */
  8301. localPosition: Vector2;
  8302. /**
  8303. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8304. */
  8305. skipOnPointerObservable: boolean;
  8306. /**
  8307. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8308. * @param type Defines the type of event (PointerEventTypes)
  8309. * @param event Defines the related dom event
  8310. * @param localX Defines the local x coordinates of the pointer when the event occured
  8311. * @param localY Defines the local y coordinates of the pointer when the event occured
  8312. */
  8313. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8314. }
  8315. /**
  8316. * This type contains all the data related to a pointer event in Babylon.js.
  8317. * 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.
  8318. */
  8319. export class PointerInfo extends PointerInfoBase {
  8320. /**
  8321. * Defines the picking info associated to the info (if any)\
  8322. */
  8323. pickInfo: Nullable<PickingInfo>;
  8324. /**
  8325. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8326. * @param type Defines the type of event (PointerEventTypes)
  8327. * @param event Defines the related dom event
  8328. * @param pickInfo Defines the picking info associated to the info (if any)\
  8329. */
  8330. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8331. /**
  8332. * Defines the picking info associated to the info (if any)\
  8333. */
  8334. pickInfo: Nullable<PickingInfo>);
  8335. }
  8336. }
  8337. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  8338. import { Nullable } from "babylonjs/types";
  8339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8341. /**
  8342. * Manage the mouse inputs to control the movement of a free camera.
  8343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8344. */
  8345. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8346. /**
  8347. * Define if touch is enabled in the mouse input
  8348. */
  8349. touchEnabled: boolean;
  8350. /**
  8351. * Defines the camera the input is attached to.
  8352. */
  8353. camera: FreeCamera;
  8354. /**
  8355. * Defines the buttons associated with the input to handle camera move.
  8356. */
  8357. buttons: number[];
  8358. /**
  8359. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8360. */
  8361. angularSensibility: number;
  8362. private _pointerInput;
  8363. private _onMouseMove;
  8364. private _observer;
  8365. private previousPosition;
  8366. /**
  8367. * Manage the mouse inputs to control the movement of a free camera.
  8368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8369. * @param touchEnabled Defines if touch is enabled or not
  8370. */
  8371. constructor(
  8372. /**
  8373. * Define if touch is enabled in the mouse input
  8374. */
  8375. touchEnabled?: boolean);
  8376. /**
  8377. * Attach the input controls to a specific dom element to get the input from.
  8378. * @param element Defines the element the controls should be listened from
  8379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8380. */
  8381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8382. /**
  8383. * Detach the current controls from the specified dom element.
  8384. * @param element Defines the element to stop listening the inputs from
  8385. */
  8386. detachControl(element: Nullable<HTMLElement>): void;
  8387. /**
  8388. * Gets the class name of the current intput.
  8389. * @returns the class name
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Get the friendly name associated with the input class.
  8394. * @returns the input friendly name
  8395. */
  8396. getSimpleName(): string;
  8397. }
  8398. }
  8399. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  8400. import { Nullable } from "babylonjs/types";
  8401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8403. /**
  8404. * Manage the touch inputs to control the movement of a free camera.
  8405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8406. */
  8407. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8408. /**
  8409. * Defines the camera the input is attached to.
  8410. */
  8411. camera: FreeCamera;
  8412. /**
  8413. * Defines the touch sensibility for rotation.
  8414. * The higher the faster.
  8415. */
  8416. touchAngularSensibility: number;
  8417. /**
  8418. * Defines the touch sensibility for move.
  8419. * The higher the faster.
  8420. */
  8421. touchMoveSensibility: number;
  8422. private _offsetX;
  8423. private _offsetY;
  8424. private _pointerPressed;
  8425. private _pointerInput;
  8426. private _observer;
  8427. private _onLostFocus;
  8428. /**
  8429. * Attach the input controls to a specific dom element to get the input from.
  8430. * @param element Defines the element the controls should be listened from
  8431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8432. */
  8433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8434. /**
  8435. * Detach the current controls from the specified dom element.
  8436. * @param element Defines the element to stop listening the inputs from
  8437. */
  8438. detachControl(element: Nullable<HTMLElement>): void;
  8439. /**
  8440. * Update the current camera state depending on the inputs that have been used this frame.
  8441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8442. */
  8443. checkInputs(): void;
  8444. /**
  8445. * Gets the class name of the current intput.
  8446. * @returns the class name
  8447. */
  8448. getClassName(): string;
  8449. /**
  8450. * Get the friendly name associated with the input class.
  8451. * @returns the input friendly name
  8452. */
  8453. getSimpleName(): string;
  8454. }
  8455. }
  8456. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  8457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8458. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  8459. /**
  8460. * Default Inputs manager for the FreeCamera.
  8461. * It groups all the default supported inputs for ease of use.
  8462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8463. */
  8464. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8465. /**
  8466. * Instantiates a new FreeCameraInputsManager.
  8467. * @param camera Defines the camera the inputs belong to
  8468. */
  8469. constructor(camera: FreeCamera);
  8470. /**
  8471. * Add keyboard input support to the input manager.
  8472. * @returns the current input manager
  8473. */
  8474. addKeyboard(): FreeCameraInputsManager;
  8475. /**
  8476. * Add mouse input support to the input manager.
  8477. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8478. * @returns the current input manager
  8479. */
  8480. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8481. /**
  8482. * Add touch input support to the input manager.
  8483. * @returns the current input manager
  8484. */
  8485. addTouch(): FreeCameraInputsManager;
  8486. }
  8487. }
  8488. declare module "babylonjs/Cameras/freeCamera" {
  8489. import { Vector3 } from "babylonjs/Maths/math";
  8490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8491. import { Scene } from "babylonjs/scene";
  8492. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  8493. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  8494. /**
  8495. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8496. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8498. */
  8499. export class FreeCamera extends TargetCamera {
  8500. /**
  8501. * Define the collision ellipsoid of the camera.
  8502. * This is helpful to simulate a camera body like the player body around the camera
  8503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8504. */
  8505. ellipsoid: Vector3;
  8506. /**
  8507. * Define an offset for the position of the ellipsoid around the camera.
  8508. * This can be helpful to determine the center of the body near the gravity center of the body
  8509. * instead of its head.
  8510. */
  8511. ellipsoidOffset: Vector3;
  8512. /**
  8513. * Enable or disable collisions of the camera with the rest of the scene objects.
  8514. */
  8515. checkCollisions: boolean;
  8516. /**
  8517. * Enable or disable gravity on the camera.
  8518. */
  8519. applyGravity: boolean;
  8520. /**
  8521. * Define the input manager associated to the camera.
  8522. */
  8523. inputs: FreeCameraInputsManager;
  8524. /**
  8525. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8526. * Higher values reduce sensitivity.
  8527. */
  8528. /**
  8529. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8530. * Higher values reduce sensitivity.
  8531. */
  8532. angularSensibility: number;
  8533. /**
  8534. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8535. */
  8536. keysUp: number[];
  8537. /**
  8538. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8539. */
  8540. keysDown: number[];
  8541. /**
  8542. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8543. */
  8544. keysLeft: number[];
  8545. /**
  8546. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8547. */
  8548. keysRight: number[];
  8549. /**
  8550. * Event raised when the camera collide with a mesh in the scene.
  8551. */
  8552. onCollide: (collidedMesh: AbstractMesh) => void;
  8553. private _collider;
  8554. private _needMoveForGravity;
  8555. private _oldPosition;
  8556. private _diffPosition;
  8557. private _newPosition;
  8558. /** @hidden */
  8559. _localDirection: Vector3;
  8560. /** @hidden */
  8561. _transformedDirection: Vector3;
  8562. /**
  8563. * Instantiates a Free Camera.
  8564. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8565. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8566. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8567. * @param name Define the name of the camera in the scene
  8568. * @param position Define the start position of the camera in the scene
  8569. * @param scene Define the scene the camera belongs to
  8570. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8571. */
  8572. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8573. /**
  8574. * Attached controls to the current camera.
  8575. * @param element Defines the element the controls should be listened from
  8576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8577. */
  8578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8579. /**
  8580. * Detach the current controls from the camera.
  8581. * The camera will stop reacting to inputs.
  8582. * @param element Defines the element to stop listening the inputs from
  8583. */
  8584. detachControl(element: HTMLElement): void;
  8585. private _collisionMask;
  8586. /**
  8587. * Define a collision mask to limit the list of object the camera can collide with
  8588. */
  8589. collisionMask: number;
  8590. /** @hidden */
  8591. _collideWithWorld(displacement: Vector3): void;
  8592. private _onCollisionPositionChange;
  8593. /** @hidden */
  8594. _checkInputs(): void;
  8595. /** @hidden */
  8596. _decideIfNeedsToMove(): boolean;
  8597. /** @hidden */
  8598. _updatePosition(): void;
  8599. /**
  8600. * Destroy the camera and release the current resources hold by it.
  8601. */
  8602. dispose(): void;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Gamepads/gamepad" {
  8611. import { Observable } from "babylonjs/Misc/observable";
  8612. /**
  8613. * Represents a gamepad control stick position
  8614. */
  8615. export class StickValues {
  8616. /**
  8617. * The x component of the control stick
  8618. */
  8619. x: number;
  8620. /**
  8621. * The y component of the control stick
  8622. */
  8623. y: number;
  8624. /**
  8625. * Initializes the gamepad x and y control stick values
  8626. * @param x The x component of the gamepad control stick value
  8627. * @param y The y component of the gamepad control stick value
  8628. */
  8629. constructor(
  8630. /**
  8631. * The x component of the control stick
  8632. */
  8633. x: number,
  8634. /**
  8635. * The y component of the control stick
  8636. */
  8637. y: number);
  8638. }
  8639. /**
  8640. * An interface which manages callbacks for gamepad button changes
  8641. */
  8642. export interface GamepadButtonChanges {
  8643. /**
  8644. * Called when a gamepad has been changed
  8645. */
  8646. changed: boolean;
  8647. /**
  8648. * Called when a gamepad press event has been triggered
  8649. */
  8650. pressChanged: boolean;
  8651. /**
  8652. * Called when a touch event has been triggered
  8653. */
  8654. touchChanged: boolean;
  8655. /**
  8656. * Called when a value has changed
  8657. */
  8658. valueChanged: boolean;
  8659. }
  8660. /**
  8661. * Represents a gamepad
  8662. */
  8663. export class Gamepad {
  8664. /**
  8665. * The id of the gamepad
  8666. */
  8667. id: string;
  8668. /**
  8669. * The index of the gamepad
  8670. */
  8671. index: number;
  8672. /**
  8673. * The browser gamepad
  8674. */
  8675. browserGamepad: any;
  8676. /**
  8677. * Specifies what type of gamepad this represents
  8678. */
  8679. type: number;
  8680. private _leftStick;
  8681. private _rightStick;
  8682. /** @hidden */
  8683. _isConnected: boolean;
  8684. private _leftStickAxisX;
  8685. private _leftStickAxisY;
  8686. private _rightStickAxisX;
  8687. private _rightStickAxisY;
  8688. /**
  8689. * Triggered when the left control stick has been changed
  8690. */
  8691. private _onleftstickchanged;
  8692. /**
  8693. * Triggered when the right control stick has been changed
  8694. */
  8695. private _onrightstickchanged;
  8696. /**
  8697. * Represents a gamepad controller
  8698. */
  8699. static GAMEPAD: number;
  8700. /**
  8701. * Represents a generic controller
  8702. */
  8703. static GENERIC: number;
  8704. /**
  8705. * Represents an XBox controller
  8706. */
  8707. static XBOX: number;
  8708. /**
  8709. * Represents a pose-enabled controller
  8710. */
  8711. static POSE_ENABLED: number;
  8712. /**
  8713. * Specifies whether the left control stick should be Y-inverted
  8714. */
  8715. protected _invertLeftStickY: boolean;
  8716. /**
  8717. * Specifies if the gamepad has been connected
  8718. */
  8719. readonly isConnected: boolean;
  8720. /**
  8721. * Initializes the gamepad
  8722. * @param id The id of the gamepad
  8723. * @param index The index of the gamepad
  8724. * @param browserGamepad The browser gamepad
  8725. * @param leftStickX The x component of the left joystick
  8726. * @param leftStickY The y component of the left joystick
  8727. * @param rightStickX The x component of the right joystick
  8728. * @param rightStickY The y component of the right joystick
  8729. */
  8730. constructor(
  8731. /**
  8732. * The id of the gamepad
  8733. */
  8734. id: string,
  8735. /**
  8736. * The index of the gamepad
  8737. */
  8738. index: number,
  8739. /**
  8740. * The browser gamepad
  8741. */
  8742. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8743. /**
  8744. * Callback triggered when the left joystick has changed
  8745. * @param callback
  8746. */
  8747. onleftstickchanged(callback: (values: StickValues) => void): void;
  8748. /**
  8749. * Callback triggered when the right joystick has changed
  8750. * @param callback
  8751. */
  8752. onrightstickchanged(callback: (values: StickValues) => void): void;
  8753. /**
  8754. * Gets the left joystick
  8755. */
  8756. /**
  8757. * Sets the left joystick values
  8758. */
  8759. leftStick: StickValues;
  8760. /**
  8761. * Gets the right joystick
  8762. */
  8763. /**
  8764. * Sets the right joystick value
  8765. */
  8766. rightStick: StickValues;
  8767. /**
  8768. * Updates the gamepad joystick positions
  8769. */
  8770. update(): void;
  8771. /**
  8772. * Disposes the gamepad
  8773. */
  8774. dispose(): void;
  8775. }
  8776. /**
  8777. * Represents a generic gamepad
  8778. */
  8779. export class GenericPad extends Gamepad {
  8780. private _buttons;
  8781. private _onbuttondown;
  8782. private _onbuttonup;
  8783. /**
  8784. * Observable triggered when a button has been pressed
  8785. */
  8786. onButtonDownObservable: Observable<number>;
  8787. /**
  8788. * Observable triggered when a button has been released
  8789. */
  8790. onButtonUpObservable: Observable<number>;
  8791. /**
  8792. * Callback triggered when a button has been pressed
  8793. * @param callback Called when a button has been pressed
  8794. */
  8795. onbuttondown(callback: (buttonPressed: number) => void): void;
  8796. /**
  8797. * Callback triggered when a button has been released
  8798. * @param callback Called when a button has been released
  8799. */
  8800. onbuttonup(callback: (buttonReleased: number) => void): void;
  8801. /**
  8802. * Initializes the generic gamepad
  8803. * @param id The id of the generic gamepad
  8804. * @param index The index of the generic gamepad
  8805. * @param browserGamepad The browser gamepad
  8806. */
  8807. constructor(id: string, index: number, browserGamepad: any);
  8808. private _setButtonValue;
  8809. /**
  8810. * Updates the generic gamepad
  8811. */
  8812. update(): void;
  8813. /**
  8814. * Disposes the generic gamepad
  8815. */
  8816. dispose(): void;
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Textures/rawTexture" {
  8820. import { Scene } from "babylonjs/scene";
  8821. import { Texture } from "babylonjs/Materials/Textures/texture";
  8822. /**
  8823. * Raw texture can help creating a texture directly from an array of data.
  8824. * This can be super useful if you either get the data from an uncompressed source or
  8825. * if you wish to create your texture pixel by pixel.
  8826. */
  8827. export class RawTexture extends Texture {
  8828. /**
  8829. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8830. */
  8831. format: number;
  8832. private _engine;
  8833. /**
  8834. * Instantiates a new RawTexture.
  8835. * Raw texture can help creating a texture directly from an array of data.
  8836. * This can be super useful if you either get the data from an uncompressed source or
  8837. * if you wish to create your texture pixel by pixel.
  8838. * @param data define the array of data to use to create the texture
  8839. * @param width define the width of the texture
  8840. * @param height define the height of the texture
  8841. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8842. * @param scene define the scene the texture belongs to
  8843. * @param generateMipMaps define whether mip maps should be generated or not
  8844. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8845. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8846. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8847. */
  8848. constructor(data: ArrayBufferView, width: number, height: number,
  8849. /**
  8850. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8851. */
  8852. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8853. /**
  8854. * Updates the texture underlying data.
  8855. * @param data Define the new data of the texture
  8856. */
  8857. update(data: ArrayBufferView): void;
  8858. /**
  8859. * Creates a luminance texture from some data.
  8860. * @param data Define the texture data
  8861. * @param width Define the width of the texture
  8862. * @param height Define the height of the texture
  8863. * @param scene Define the scene the texture belongs to
  8864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8867. * @returns the luminance texture
  8868. */
  8869. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8870. /**
  8871. * Creates a luminance alpha texture from some data.
  8872. * @param data Define the texture data
  8873. * @param width Define the width of the texture
  8874. * @param height Define the height of the texture
  8875. * @param scene Define the scene the texture belongs to
  8876. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8877. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8878. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8879. * @returns the luminance alpha texture
  8880. */
  8881. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8882. /**
  8883. * Creates an alpha texture from some data.
  8884. * @param data Define the texture data
  8885. * @param width Define the width of the texture
  8886. * @param height Define the height of the texture
  8887. * @param scene Define the scene the texture belongs to
  8888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8891. * @returns the alpha texture
  8892. */
  8893. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8894. /**
  8895. * Creates a RGB texture from some data.
  8896. * @param data Define the texture data
  8897. * @param width Define the width of the texture
  8898. * @param height Define the height of the texture
  8899. * @param scene Define the scene the texture belongs to
  8900. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8901. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8902. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8903. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8904. * @returns the RGB alpha texture
  8905. */
  8906. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8907. /**
  8908. * Creates a RGBA texture from some data.
  8909. * @param data Define the texture data
  8910. * @param width Define the width of the texture
  8911. * @param height Define the height of the texture
  8912. * @param scene Define the scene the texture belongs to
  8913. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8914. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8915. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8916. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8917. * @returns the RGBA texture
  8918. */
  8919. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8920. /**
  8921. * Creates a R texture from some data.
  8922. * @param data Define the texture data
  8923. * @param width Define the width of the texture
  8924. * @param height Define the height of the texture
  8925. * @param scene Define the scene the texture belongs to
  8926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8930. * @returns the R texture
  8931. */
  8932. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8933. }
  8934. }
  8935. declare module "babylonjs/Bones/skeleton" {
  8936. import { Bone } from "babylonjs/Bones/bone";
  8937. import { IAnimatable } from "babylonjs/Misc/tools";
  8938. import { Observable } from "babylonjs/Misc/observable";
  8939. import { Vector3, Matrix } from "babylonjs/Maths/math";
  8940. import { Scene } from "babylonjs/scene";
  8941. import { Nullable } from "babylonjs/types";
  8942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8943. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  8944. import { Animatable } from "babylonjs/Animations/animatable";
  8945. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8946. import { AnimationRange, Animation } from "babylonjs/Animations/animation";
  8947. /**
  8948. * Class used to handle skinning animations
  8949. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8950. */
  8951. export class Skeleton implements IAnimatable {
  8952. /** defines the skeleton name */
  8953. name: string;
  8954. /** defines the skeleton Id */
  8955. id: string;
  8956. /**
  8957. * Defines the list of child bones
  8958. */
  8959. bones: Bone[];
  8960. /**
  8961. * Defines an estimate of the dimension of the skeleton at rest
  8962. */
  8963. dimensionsAtRest: Vector3;
  8964. /**
  8965. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8966. */
  8967. needInitialSkinMatrix: boolean;
  8968. /**
  8969. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8970. */
  8971. overrideMesh: Nullable<AbstractMesh>;
  8972. /**
  8973. * Gets the list of animations attached to this skeleton
  8974. */
  8975. animations: Array<Animation>;
  8976. private _scene;
  8977. private _isDirty;
  8978. private _transformMatrices;
  8979. private _transformMatrixTexture;
  8980. private _meshesWithPoseMatrix;
  8981. private _animatables;
  8982. private _identity;
  8983. private _synchronizedWithMesh;
  8984. private _ranges;
  8985. private _lastAbsoluteTransformsUpdateId;
  8986. private _canUseTextureForBones;
  8987. /** @hidden */
  8988. _numBonesWithLinkedTransformNode: number;
  8989. /**
  8990. * Specifies if the skeleton should be serialized
  8991. */
  8992. doNotSerialize: boolean;
  8993. /**
  8994. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  8995. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  8996. */
  8997. useTextureToStoreBoneMatrices: boolean;
  8998. private _animationPropertiesOverride;
  8999. /**
  9000. * Gets or sets the animation properties override
  9001. */
  9002. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9003. /**
  9004. * An observable triggered before computing the skeleton's matrices
  9005. */
  9006. onBeforeComputeObservable: Observable<Skeleton>;
  9007. /**
  9008. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9009. */
  9010. readonly isUsingTextureForMatrices: boolean;
  9011. /**
  9012. * Creates a new skeleton
  9013. * @param name defines the skeleton name
  9014. * @param id defines the skeleton Id
  9015. * @param scene defines the hosting scene
  9016. */
  9017. constructor(
  9018. /** defines the skeleton name */
  9019. name: string,
  9020. /** defines the skeleton Id */
  9021. id: string, scene: Scene);
  9022. /**
  9023. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9024. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9025. * @returns a Float32Array containing matrices data
  9026. */
  9027. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9028. /**
  9029. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9030. * @returns a raw texture containing the data
  9031. */
  9032. getTransformMatrixTexture(): Nullable<RawTexture>;
  9033. /**
  9034. * Gets the current hosting scene
  9035. * @returns a scene object
  9036. */
  9037. getScene(): Scene;
  9038. /**
  9039. * Gets a string representing the current skeleton data
  9040. * @param fullDetails defines a boolean indicating if we want a verbose version
  9041. * @returns a string representing the current skeleton data
  9042. */
  9043. toString(fullDetails?: boolean): string;
  9044. /**
  9045. * Get bone's index searching by name
  9046. * @param name defines bone's name to search for
  9047. * @return the indice of the bone. Returns -1 if not found
  9048. */
  9049. getBoneIndexByName(name: string): number;
  9050. /**
  9051. * Creater a new animation range
  9052. * @param name defines the name of the range
  9053. * @param from defines the start key
  9054. * @param to defines the end key
  9055. */
  9056. createAnimationRange(name: string, from: number, to: number): void;
  9057. /**
  9058. * Delete a specific animation range
  9059. * @param name defines the name of the range
  9060. * @param deleteFrames defines if frames must be removed as well
  9061. */
  9062. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9063. /**
  9064. * Gets a specific animation range
  9065. * @param name defines the name of the range to look for
  9066. * @returns the requested animation range or null if not found
  9067. */
  9068. getAnimationRange(name: string): Nullable<AnimationRange>;
  9069. /**
  9070. * Gets the list of all animation ranges defined on this skeleton
  9071. * @returns an array
  9072. */
  9073. getAnimationRanges(): Nullable<AnimationRange>[];
  9074. /**
  9075. * Copy animation range from a source skeleton.
  9076. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9077. * @param source defines the source skeleton
  9078. * @param name defines the name of the range to copy
  9079. * @param rescaleAsRequired defines if rescaling must be applied if required
  9080. * @returns true if operation was successful
  9081. */
  9082. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9083. /**
  9084. * Forces the skeleton to go to rest pose
  9085. */
  9086. returnToRest(): void;
  9087. private _getHighestAnimationFrame;
  9088. /**
  9089. * Begin a specific animation range
  9090. * @param name defines the name of the range to start
  9091. * @param loop defines if looping must be turned on (false by default)
  9092. * @param speedRatio defines the speed ratio to apply (1 by default)
  9093. * @param onAnimationEnd defines a callback which will be called when animation will end
  9094. * @returns a new animatable
  9095. */
  9096. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9097. /** @hidden */
  9098. _markAsDirty(): void;
  9099. /** @hidden */
  9100. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9101. /** @hidden */
  9102. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9103. private _computeTransformMatrices;
  9104. /**
  9105. * Build all resources required to render a skeleton
  9106. */
  9107. prepare(): void;
  9108. /**
  9109. * Gets the list of animatables currently running for this skeleton
  9110. * @returns an array of animatables
  9111. */
  9112. getAnimatables(): IAnimatable[];
  9113. /**
  9114. * Clone the current skeleton
  9115. * @param name defines the name of the new skeleton
  9116. * @param id defines the id of the enw skeleton
  9117. * @returns the new skeleton
  9118. */
  9119. clone(name: string, id: string): Skeleton;
  9120. /**
  9121. * Enable animation blending for this skeleton
  9122. * @param blendingSpeed defines the blending speed to apply
  9123. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9124. */
  9125. enableBlending(blendingSpeed?: number): void;
  9126. /**
  9127. * Releases all resources associated with the current skeleton
  9128. */
  9129. dispose(): void;
  9130. /**
  9131. * Serialize the skeleton in a JSON object
  9132. * @returns a JSON object
  9133. */
  9134. serialize(): any;
  9135. /**
  9136. * Creates a new skeleton from serialized data
  9137. * @param parsedSkeleton defines the serialized data
  9138. * @param scene defines the hosting scene
  9139. * @returns a new skeleton
  9140. */
  9141. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9142. /**
  9143. * Compute all node absolute transforms
  9144. * @param forceUpdate defines if computation must be done even if cache is up to date
  9145. */
  9146. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9147. /**
  9148. * Gets the root pose matrix
  9149. * @returns a matrix
  9150. */
  9151. getPoseMatrix(): Nullable<Matrix>;
  9152. /**
  9153. * Sorts bones per internal index
  9154. */
  9155. sortBones(): void;
  9156. private _sortBones;
  9157. }
  9158. }
  9159. declare module "babylonjs/Bones/bone" {
  9160. import { Skeleton } from "babylonjs/Bones/skeleton";
  9161. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  9162. import { Nullable } from "babylonjs/types";
  9163. import { Animation } from "babylonjs/Animations/animation";
  9164. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  9165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9167. import { Node } from "babylonjs/node";
  9168. /**
  9169. * Class used to store bone information
  9170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9171. */
  9172. export class Bone extends Node {
  9173. /**
  9174. * defines the bone name
  9175. */
  9176. name: string;
  9177. private static _tmpVecs;
  9178. private static _tmpQuat;
  9179. private static _tmpMats;
  9180. /**
  9181. * Gets the list of child bones
  9182. */
  9183. children: Bone[];
  9184. /** Gets the animations associated with this bone */
  9185. animations: Animation[];
  9186. /**
  9187. * Gets or sets bone length
  9188. */
  9189. length: number;
  9190. /**
  9191. * @hidden Internal only
  9192. * Set this value to map this bone to a different index in the transform matrices
  9193. * Set this value to -1 to exclude the bone from the transform matrices
  9194. */
  9195. _index: Nullable<number>;
  9196. private _skeleton;
  9197. private _localMatrix;
  9198. private _restPose;
  9199. private _baseMatrix;
  9200. private _absoluteTransform;
  9201. private _invertedAbsoluteTransform;
  9202. private _parent;
  9203. private _scalingDeterminant;
  9204. private _worldTransform;
  9205. private _localScaling;
  9206. private _localRotation;
  9207. private _localPosition;
  9208. private _needToDecompose;
  9209. private _needToCompose;
  9210. /** @hidden */
  9211. _linkedTransformNode: Nullable<TransformNode>;
  9212. /** @hidden */
  9213. /** @hidden */
  9214. _matrix: Matrix;
  9215. /**
  9216. * Create a new bone
  9217. * @param name defines the bone name
  9218. * @param skeleton defines the parent skeleton
  9219. * @param parentBone defines the parent (can be null if the bone is the root)
  9220. * @param localMatrix defines the local matrix
  9221. * @param restPose defines the rest pose matrix
  9222. * @param baseMatrix defines the base matrix
  9223. * @param index defines index of the bone in the hiearchy
  9224. */
  9225. constructor(
  9226. /**
  9227. * defines the bone name
  9228. */
  9229. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9230. /**
  9231. * Gets the parent skeleton
  9232. * @returns a skeleton
  9233. */
  9234. getSkeleton(): Skeleton;
  9235. /**
  9236. * Gets parent bone
  9237. * @returns a bone or null if the bone is the root of the bone hierarchy
  9238. */
  9239. getParent(): Nullable<Bone>;
  9240. /**
  9241. * Sets the parent bone
  9242. * @param parent defines the parent (can be null if the bone is the root)
  9243. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9244. */
  9245. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9246. /**
  9247. * Gets the local matrix
  9248. * @returns a matrix
  9249. */
  9250. getLocalMatrix(): Matrix;
  9251. /**
  9252. * Gets the base matrix (initial matrix which remains unchanged)
  9253. * @returns a matrix
  9254. */
  9255. getBaseMatrix(): Matrix;
  9256. /**
  9257. * Gets the rest pose matrix
  9258. * @returns a matrix
  9259. */
  9260. getRestPose(): Matrix;
  9261. /**
  9262. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9263. */
  9264. getWorldMatrix(): Matrix;
  9265. /**
  9266. * Sets the local matrix to rest pose matrix
  9267. */
  9268. returnToRest(): void;
  9269. /**
  9270. * Gets the inverse of the absolute transform matrix.
  9271. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9272. * @returns a matrix
  9273. */
  9274. getInvertedAbsoluteTransform(): Matrix;
  9275. /**
  9276. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9277. * @returns a matrix
  9278. */
  9279. getAbsoluteTransform(): Matrix;
  9280. /**
  9281. * Links with the given transform node.
  9282. * The local matrix of this bone is copied from the transform node every frame.
  9283. * @param transformNode defines the transform node to link to
  9284. */
  9285. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9286. /** Gets or sets current position (in local space) */
  9287. position: Vector3;
  9288. /** Gets or sets current rotation (in local space) */
  9289. rotation: Vector3;
  9290. /** Gets or sets current rotation quaternion (in local space) */
  9291. rotationQuaternion: Quaternion;
  9292. /** Gets or sets current scaling (in local space) */
  9293. scaling: Vector3;
  9294. /**
  9295. * Gets the animation properties override
  9296. */
  9297. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9298. private _decompose;
  9299. private _compose;
  9300. /**
  9301. * Update the base and local matrices
  9302. * @param matrix defines the new base or local matrix
  9303. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9304. * @param updateLocalMatrix defines if the local matrix should be updated
  9305. */
  9306. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9307. /** @hidden */
  9308. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9309. /**
  9310. * Flag the bone as dirty (Forcing it to update everything)
  9311. */
  9312. markAsDirty(): void;
  9313. private _markAsDirtyAndCompose;
  9314. private _markAsDirtyAndDecompose;
  9315. /**
  9316. * Copy an animation range from another bone
  9317. * @param source defines the source bone
  9318. * @param rangeName defines the range name to copy
  9319. * @param frameOffset defines the frame offset
  9320. * @param rescaleAsRequired defines if rescaling must be applied if required
  9321. * @param skelDimensionsRatio defines the scaling ratio
  9322. * @returns true if operation was successful
  9323. */
  9324. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9325. /**
  9326. * Translate the bone in local or world space
  9327. * @param vec The amount to translate the bone
  9328. * @param space The space that the translation is in
  9329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9330. */
  9331. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9332. /**
  9333. * Set the postion of the bone in local or world space
  9334. * @param position The position to set the bone
  9335. * @param space The space that the position is in
  9336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9337. */
  9338. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9339. /**
  9340. * Set the absolute position of the bone (world space)
  9341. * @param position The position to set the bone
  9342. * @param mesh The mesh that this bone is attached to
  9343. */
  9344. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9345. /**
  9346. * Scale the bone on the x, y and z axes (in local space)
  9347. * @param x The amount to scale the bone on the x axis
  9348. * @param y The amount to scale the bone on the y axis
  9349. * @param z The amount to scale the bone on the z axis
  9350. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9351. */
  9352. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9353. /**
  9354. * Set the bone scaling in local space
  9355. * @param scale defines the scaling vector
  9356. */
  9357. setScale(scale: Vector3): void;
  9358. /**
  9359. * Gets the current scaling in local space
  9360. * @returns the current scaling vector
  9361. */
  9362. getScale(): Vector3;
  9363. /**
  9364. * Gets the current scaling in local space and stores it in a target vector
  9365. * @param result defines the target vector
  9366. */
  9367. getScaleToRef(result: Vector3): void;
  9368. /**
  9369. * Set the yaw, pitch, and roll of the bone in local or world space
  9370. * @param yaw The rotation of the bone on the y axis
  9371. * @param pitch The rotation of the bone on the x axis
  9372. * @param roll The rotation of the bone on the z axis
  9373. * @param space The space that the axes of rotation are in
  9374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9375. */
  9376. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9377. /**
  9378. * Add a rotation to the bone on an axis in local or world space
  9379. * @param axis The axis to rotate the bone on
  9380. * @param amount The amount to rotate the bone
  9381. * @param space The space that the axis is in
  9382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9383. */
  9384. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9385. /**
  9386. * Set the rotation of the bone to a particular axis angle in local or world space
  9387. * @param axis The axis to rotate the bone on
  9388. * @param angle The angle that the bone should be rotated to
  9389. * @param space The space that the axis is in
  9390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9391. */
  9392. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9393. /**
  9394. * Set the euler rotation of the bone in local of world space
  9395. * @param rotation The euler rotation that the bone should be set to
  9396. * @param space The space that the rotation is in
  9397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9398. */
  9399. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9400. /**
  9401. * Set the quaternion rotation of the bone in local of world space
  9402. * @param quat The quaternion rotation that the bone should be set to
  9403. * @param space The space that the rotation is in
  9404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9405. */
  9406. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9407. /**
  9408. * Set the rotation matrix of the bone in local of world space
  9409. * @param rotMat The rotation matrix that the bone should be set to
  9410. * @param space The space that the rotation is in
  9411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9412. */
  9413. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9414. private _rotateWithMatrix;
  9415. private _getNegativeRotationToRef;
  9416. /**
  9417. * Get the position of the bone in local or world space
  9418. * @param space The space that the returned position is in
  9419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9420. * @returns The position of the bone
  9421. */
  9422. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9423. /**
  9424. * Copy the position of the bone to a vector3 in local or world space
  9425. * @param space The space that the returned position is in
  9426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9427. * @param result The vector3 to copy the position to
  9428. */
  9429. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9430. /**
  9431. * Get the absolute position of the bone (world space)
  9432. * @param mesh The mesh that this bone is attached to
  9433. * @returns The absolute position of the bone
  9434. */
  9435. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9436. /**
  9437. * Copy the absolute position of the bone (world space) to the result param
  9438. * @param mesh The mesh that this bone is attached to
  9439. * @param result The vector3 to copy the absolute position to
  9440. */
  9441. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9442. /**
  9443. * Compute the absolute transforms of this bone and its children
  9444. */
  9445. computeAbsoluteTransforms(): void;
  9446. /**
  9447. * Get the world direction from an axis that is in the local space of the bone
  9448. * @param localAxis The local direction that is used to compute the world direction
  9449. * @param mesh The mesh that this bone is attached to
  9450. * @returns The world direction
  9451. */
  9452. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9453. /**
  9454. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9455. * @param localAxis The local direction that is used to compute the world direction
  9456. * @param mesh The mesh that this bone is attached to
  9457. * @param result The vector3 that the world direction will be copied to
  9458. */
  9459. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9460. /**
  9461. * Get the euler rotation of the bone in local or world space
  9462. * @param space The space that the rotation should be in
  9463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9464. * @returns The euler rotation
  9465. */
  9466. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9467. /**
  9468. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9469. * @param space The space that the rotation should be in
  9470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9471. * @param result The vector3 that the rotation should be copied to
  9472. */
  9473. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9474. /**
  9475. * Get the quaternion rotation of the bone in either local or world space
  9476. * @param space The space that the rotation should be in
  9477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9478. * @returns The quaternion rotation
  9479. */
  9480. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9481. /**
  9482. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9483. * @param space The space that the rotation should be in
  9484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9485. * @param result The quaternion that the rotation should be copied to
  9486. */
  9487. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9488. /**
  9489. * Get the rotation matrix of the bone in local or world space
  9490. * @param space The space that the rotation should be in
  9491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9492. * @returns The rotation matrix
  9493. */
  9494. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9495. /**
  9496. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9497. * @param space The space that the rotation should be in
  9498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9499. * @param result The quaternion that the rotation should be copied to
  9500. */
  9501. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9502. /**
  9503. * Get the world position of a point that is in the local space of the bone
  9504. * @param position The local position
  9505. * @param mesh The mesh that this bone is attached to
  9506. * @returns The world position
  9507. */
  9508. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9509. /**
  9510. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9511. * @param position The local position
  9512. * @param mesh The mesh that this bone is attached to
  9513. * @param result The vector3 that the world position should be copied to
  9514. */
  9515. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9516. /**
  9517. * Get the local position of a point that is in world space
  9518. * @param position The world position
  9519. * @param mesh The mesh that this bone is attached to
  9520. * @returns The local position
  9521. */
  9522. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9523. /**
  9524. * Get the local position of a point that is in world space and copy it to the result param
  9525. * @param position The world position
  9526. * @param mesh The mesh that this bone is attached to
  9527. * @param result The vector3 that the local position should be copied to
  9528. */
  9529. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9530. }
  9531. }
  9532. declare module "babylonjs/Meshes/transformNode" {
  9533. import { DeepImmutable } from "babylonjs/types";
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Nullable } from "babylonjs/types";
  9536. import { Camera } from "babylonjs/Cameras/camera";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  9539. import { Node } from "babylonjs/node";
  9540. import { Bone } from "babylonjs/Bones/bone";
  9541. /**
  9542. * 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.
  9543. * @see https://doc.babylonjs.com/how_to/transformnode
  9544. */
  9545. export class TransformNode extends Node {
  9546. /**
  9547. * Object will not rotate to face the camera
  9548. */
  9549. static BILLBOARDMODE_NONE: number;
  9550. /**
  9551. * Object will rotate to face the camera but only on the x axis
  9552. */
  9553. static BILLBOARDMODE_X: number;
  9554. /**
  9555. * Object will rotate to face the camera but only on the y axis
  9556. */
  9557. static BILLBOARDMODE_Y: number;
  9558. /**
  9559. * Object will rotate to face the camera but only on the z axis
  9560. */
  9561. static BILLBOARDMODE_Z: number;
  9562. /**
  9563. * Object will rotate to face the camera
  9564. */
  9565. static BILLBOARDMODE_ALL: number;
  9566. private _forward;
  9567. private _forwardInverted;
  9568. private _up;
  9569. private _right;
  9570. private _rightInverted;
  9571. private _position;
  9572. private _rotation;
  9573. private _rotationQuaternion;
  9574. protected _scaling: Vector3;
  9575. protected _isDirty: boolean;
  9576. private _transformToBoneReferal;
  9577. /**
  9578. * Set the billboard mode. Default is 0.
  9579. *
  9580. * | Value | Type | Description |
  9581. * | --- | --- | --- |
  9582. * | 0 | BILLBOARDMODE_NONE | |
  9583. * | 1 | BILLBOARDMODE_X | |
  9584. * | 2 | BILLBOARDMODE_Y | |
  9585. * | 4 | BILLBOARDMODE_Z | |
  9586. * | 7 | BILLBOARDMODE_ALL | |
  9587. *
  9588. */
  9589. billboardMode: number;
  9590. /**
  9591. * 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
  9592. */
  9593. scalingDeterminant: number;
  9594. /**
  9595. * Sets the distance of the object to max, often used by skybox
  9596. */
  9597. infiniteDistance: boolean;
  9598. /**
  9599. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9600. * By default the system will update normals to compensate
  9601. */
  9602. ignoreNonUniformScaling: boolean;
  9603. /** @hidden */
  9604. _poseMatrix: Matrix;
  9605. /** @hidden */
  9606. _localMatrix: Matrix;
  9607. private _absolutePosition;
  9608. private _pivotMatrix;
  9609. private _pivotMatrixInverse;
  9610. protected _postMultiplyPivotMatrix: boolean;
  9611. protected _isWorldMatrixFrozen: boolean;
  9612. /** @hidden */
  9613. _indexInSceneTransformNodesArray: number;
  9614. /**
  9615. * An event triggered after the world matrix is updated
  9616. */
  9617. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9618. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9619. /**
  9620. * Gets a string identifying the name of the class
  9621. * @returns "TransformNode" string
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9626. */
  9627. position: Vector3;
  9628. /**
  9629. * 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)).
  9630. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9631. */
  9632. rotation: Vector3;
  9633. /**
  9634. * 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)).
  9635. */
  9636. scaling: Vector3;
  9637. /**
  9638. * 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).
  9639. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9640. */
  9641. rotationQuaternion: Nullable<Quaternion>;
  9642. /**
  9643. * The forward direction of that transform in world space.
  9644. */
  9645. readonly forward: Vector3;
  9646. /**
  9647. * The up direction of that transform in world space.
  9648. */
  9649. readonly up: Vector3;
  9650. /**
  9651. * The right direction of that transform in world space.
  9652. */
  9653. readonly right: Vector3;
  9654. /**
  9655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9656. * @param matrix the matrix to copy the pose from
  9657. * @returns this TransformNode.
  9658. */
  9659. updatePoseMatrix(matrix: Matrix): TransformNode;
  9660. /**
  9661. * Returns the mesh Pose matrix.
  9662. * @returns the pose matrix
  9663. */
  9664. getPoseMatrix(): Matrix;
  9665. /** @hidden */
  9666. _isSynchronized(): boolean;
  9667. /** @hidden */
  9668. _initCache(): void;
  9669. /**
  9670. * Flag the transform node as dirty (Forcing it to update everything)
  9671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9672. * @returns this transform node
  9673. */
  9674. markAsDirty(property: string): TransformNode;
  9675. /**
  9676. * Returns the current mesh absolute position.
  9677. * Returns a Vector3.
  9678. */
  9679. readonly absolutePosition: Vector3;
  9680. /**
  9681. * Sets a new matrix to apply before all other transformation
  9682. * @param matrix defines the transform matrix
  9683. * @returns the current TransformNode
  9684. */
  9685. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9686. /**
  9687. * Sets a new pivot matrix to the current node
  9688. * @param matrix defines the new pivot matrix to use
  9689. * @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
  9690. * @returns the current TransformNode
  9691. */
  9692. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9693. /**
  9694. * Returns the mesh pivot matrix.
  9695. * Default : Identity.
  9696. * @returns the matrix
  9697. */
  9698. getPivotMatrix(): Matrix;
  9699. /**
  9700. * Prevents the World matrix to be computed any longer.
  9701. * @returns the TransformNode.
  9702. */
  9703. freezeWorldMatrix(): TransformNode;
  9704. /**
  9705. * Allows back the World matrix computation.
  9706. * @returns the TransformNode.
  9707. */
  9708. unfreezeWorldMatrix(): this;
  9709. /**
  9710. * True if the World matrix has been frozen.
  9711. */
  9712. readonly isWorldMatrixFrozen: boolean;
  9713. /**
  9714. * Retuns the mesh absolute position in the World.
  9715. * @returns a Vector3.
  9716. */
  9717. getAbsolutePosition(): Vector3;
  9718. /**
  9719. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9720. * @param absolutePosition the absolute position to set
  9721. * @returns the TransformNode.
  9722. */
  9723. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9724. /**
  9725. * Sets the mesh position in its local space.
  9726. * @param vector3 the position to set in localspace
  9727. * @returns the TransformNode.
  9728. */
  9729. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9730. /**
  9731. * Returns the mesh position in the local space from the current World matrix values.
  9732. * @returns a new Vector3.
  9733. */
  9734. getPositionExpressedInLocalSpace(): Vector3;
  9735. /**
  9736. * Translates the mesh along the passed Vector3 in its local space.
  9737. * @param vector3 the distance to translate in localspace
  9738. * @returns the TransformNode.
  9739. */
  9740. locallyTranslate(vector3: Vector3): TransformNode;
  9741. private static _lookAtVectorCache;
  9742. /**
  9743. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9744. * @param targetPoint the position (must be in same space as current mesh) to look at
  9745. * @param yawCor optional yaw (y-axis) correction in radians
  9746. * @param pitchCor optional pitch (x-axis) correction in radians
  9747. * @param rollCor optional roll (z-axis) correction in radians
  9748. * @param space the choosen space of the target
  9749. * @returns the TransformNode.
  9750. */
  9751. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9752. /**
  9753. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9754. * This Vector3 is expressed in the World space.
  9755. * @param localAxis axis to rotate
  9756. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9757. */
  9758. getDirection(localAxis: Vector3): Vector3;
  9759. /**
  9760. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9761. * localAxis is expressed in the mesh local space.
  9762. * result is computed in the Wordl space from the mesh World matrix.
  9763. * @param localAxis axis to rotate
  9764. * @param result the resulting transformnode
  9765. * @returns this TransformNode.
  9766. */
  9767. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9768. /**
  9769. * Sets this transform node rotation to the given local axis.
  9770. * @param localAxis the axis in local space
  9771. * @param yawCor optional yaw (y-axis) correction in radians
  9772. * @param pitchCor optional pitch (x-axis) correction in radians
  9773. * @param rollCor optional roll (z-axis) correction in radians
  9774. * @returns this TransformNode
  9775. */
  9776. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9777. /**
  9778. * Sets a new pivot point to the current node
  9779. * @param point defines the new pivot point to use
  9780. * @param space defines if the point is in world or local space (local by default)
  9781. * @returns the current TransformNode
  9782. */
  9783. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9784. /**
  9785. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9786. * @returns the pivot point
  9787. */
  9788. getPivotPoint(): Vector3;
  9789. /**
  9790. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9791. * @param result the vector3 to store the result
  9792. * @returns this TransformNode.
  9793. */
  9794. getPivotPointToRef(result: Vector3): TransformNode;
  9795. /**
  9796. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9797. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9798. */
  9799. getAbsolutePivotPoint(): Vector3;
  9800. /**
  9801. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9802. * @param result vector3 to store the result
  9803. * @returns this TransformNode.
  9804. */
  9805. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9806. /**
  9807. * Defines the passed node as the parent of the current node.
  9808. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9809. * @param node the node ot set as the parent
  9810. * @returns this TransformNode.
  9811. */
  9812. setParent(node: Nullable<Node>): TransformNode;
  9813. private _nonUniformScaling;
  9814. /**
  9815. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9816. */
  9817. readonly nonUniformScaling: boolean;
  9818. /** @hidden */
  9819. _updateNonUniformScalingState(value: boolean): boolean;
  9820. /**
  9821. * Attach the current TransformNode to another TransformNode associated with a bone
  9822. * @param bone Bone affecting the TransformNode
  9823. * @param affectedTransformNode TransformNode associated with the bone
  9824. * @returns this object
  9825. */
  9826. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9827. /**
  9828. * Detach the transform node if its associated with a bone
  9829. * @returns this object
  9830. */
  9831. detachFromBone(): TransformNode;
  9832. private static _rotationAxisCache;
  9833. /**
  9834. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9835. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9837. * The passed axis is also normalized.
  9838. * @param axis the axis to rotate around
  9839. * @param amount the amount to rotate in radians
  9840. * @param space Space to rotate in (Default: local)
  9841. * @returns the TransformNode.
  9842. */
  9843. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9844. /**
  9845. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9846. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9847. * The passed axis is also normalized. .
  9848. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9849. * @param point the point to rotate around
  9850. * @param axis the axis to rotate around
  9851. * @param amount the amount to rotate in radians
  9852. * @returns the TransformNode
  9853. */
  9854. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9855. /**
  9856. * Translates the mesh along the axis vector for the passed distance in the given space.
  9857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9858. * @param axis the axis to translate in
  9859. * @param distance the distance to translate
  9860. * @param space Space to rotate in (Default: local)
  9861. * @returns the TransformNode.
  9862. */
  9863. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9864. /**
  9865. * Adds a rotation step to the mesh current rotation.
  9866. * x, y, z are Euler angles expressed in radians.
  9867. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9868. * This means this rotation is made in the mesh local space only.
  9869. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9870. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9871. * ```javascript
  9872. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9873. * ```
  9874. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9875. * 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.
  9876. * @param x Rotation to add
  9877. * @param y Rotation to add
  9878. * @param z Rotation to add
  9879. * @returns the TransformNode.
  9880. */
  9881. addRotation(x: number, y: number, z: number): TransformNode;
  9882. /**
  9883. * Computes the world matrix of the node
  9884. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9885. * @returns the world matrix
  9886. */
  9887. computeWorldMatrix(force?: boolean): Matrix;
  9888. protected _afterComputeWorldMatrix(): void;
  9889. /**
  9890. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9891. * @param func callback function to add
  9892. *
  9893. * @returns the TransformNode.
  9894. */
  9895. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9896. /**
  9897. * Removes a registered callback function.
  9898. * @param func callback function to remove
  9899. * @returns the TransformNode.
  9900. */
  9901. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9902. /**
  9903. * Gets the position of the current mesh in camera space
  9904. * @param camera defines the camera to use
  9905. * @returns a position
  9906. */
  9907. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9908. /**
  9909. * Returns the distance from the mesh to the active camera
  9910. * @param camera defines the camera to use
  9911. * @returns the distance
  9912. */
  9913. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9914. /**
  9915. * Clone the current transform node
  9916. * @param name Name of the new clone
  9917. * @param newParent New parent for the clone
  9918. * @param doNotCloneChildren Do not clone children hierarchy
  9919. * @returns the new transform node
  9920. */
  9921. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9922. /**
  9923. * Serializes the objects information.
  9924. * @param currentSerializationObject defines the object to serialize in
  9925. * @returns the serialized object
  9926. */
  9927. serialize(currentSerializationObject?: any): any;
  9928. /**
  9929. * Returns a new TransformNode object parsed from the source provided.
  9930. * @param parsedTransformNode is the source.
  9931. * @param scene the scne the object belongs to
  9932. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9933. * @returns a new TransformNode object parsed from the source provided.
  9934. */
  9935. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9936. /**
  9937. * Get all child-transformNodes of this node
  9938. * @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
  9939. * @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
  9940. * @returns an array of TransformNode
  9941. */
  9942. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9943. /**
  9944. * Releases resources associated with this transform node.
  9945. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9946. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9947. */
  9948. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9949. }
  9950. }
  9951. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Nullable } from "babylonjs/types";
  9954. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  9955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9957. import { Ray } from "babylonjs/Culling/ray";
  9958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  9959. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  9960. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  9961. /**
  9962. * Defines the types of pose enabled controllers that are supported
  9963. */
  9964. export enum PoseEnabledControllerType {
  9965. /**
  9966. * HTC Vive
  9967. */
  9968. VIVE = 0,
  9969. /**
  9970. * Oculus Rift
  9971. */
  9972. OCULUS = 1,
  9973. /**
  9974. * Windows mixed reality
  9975. */
  9976. WINDOWS = 2,
  9977. /**
  9978. * Samsung gear VR
  9979. */
  9980. GEAR_VR = 3,
  9981. /**
  9982. * Google Daydream
  9983. */
  9984. DAYDREAM = 4,
  9985. /**
  9986. * Generic
  9987. */
  9988. GENERIC = 5
  9989. }
  9990. /**
  9991. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9992. */
  9993. export interface MutableGamepadButton {
  9994. /**
  9995. * Value of the button/trigger
  9996. */
  9997. value: number;
  9998. /**
  9999. * If the button/trigger is currently touched
  10000. */
  10001. touched: boolean;
  10002. /**
  10003. * If the button/trigger is currently pressed
  10004. */
  10005. pressed: boolean;
  10006. }
  10007. /**
  10008. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  10009. * @hidden
  10010. */
  10011. export interface ExtendedGamepadButton extends GamepadButton {
  10012. /**
  10013. * If the button/trigger is currently pressed
  10014. */
  10015. readonly pressed: boolean;
  10016. /**
  10017. * If the button/trigger is currently touched
  10018. */
  10019. readonly touched: boolean;
  10020. /**
  10021. * Value of the button/trigger
  10022. */
  10023. readonly value: number;
  10024. }
  10025. /** @hidden */
  10026. export interface _GamePadFactory {
  10027. /**
  10028. * Returns wether or not the current gamepad can be created for this type of controller.
  10029. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10030. * @returns true if it can be created, otherwise false
  10031. */
  10032. canCreate(gamepadInfo: any): boolean;
  10033. /**
  10034. * Creates a new instance of the Gamepad.
  10035. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10036. * @returns the new gamepad instance
  10037. */
  10038. create(gamepadInfo: any): Gamepad;
  10039. }
  10040. /**
  10041. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10042. */
  10043. export class PoseEnabledControllerHelper {
  10044. /** @hidden */
  10045. static _ControllerFactories: _GamePadFactory[];
  10046. /** @hidden */
  10047. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  10048. /**
  10049. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10050. * @param vrGamepad the gamepad to initialized
  10051. * @returns a vr controller of the type the gamepad identified as
  10052. */
  10053. static InitiateController(vrGamepad: any): Gamepad;
  10054. }
  10055. /**
  10056. * Defines the PoseEnabledController object that contains state of a vr capable controller
  10057. */
  10058. export class PoseEnabledController extends Gamepad implements PoseControlled {
  10059. private _deviceRoomPosition;
  10060. private _deviceRoomRotationQuaternion;
  10061. /**
  10062. * The device position in babylon space
  10063. */
  10064. devicePosition: Vector3;
  10065. /**
  10066. * The device rotation in babylon space
  10067. */
  10068. deviceRotationQuaternion: Quaternion;
  10069. /**
  10070. * The scale factor of the device in babylon space
  10071. */
  10072. deviceScaleFactor: number;
  10073. /**
  10074. * (Likely devicePosition should be used instead) The device position in its room space
  10075. */
  10076. position: Vector3;
  10077. /**
  10078. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  10079. */
  10080. rotationQuaternion: Quaternion;
  10081. /**
  10082. * The type of controller (Eg. Windows mixed reality)
  10083. */
  10084. controllerType: PoseEnabledControllerType;
  10085. protected _calculatedPosition: Vector3;
  10086. private _calculatedRotation;
  10087. /**
  10088. * The raw pose from the device
  10089. */
  10090. rawPose: DevicePose;
  10091. private _trackPosition;
  10092. private _maxRotationDistFromHeadset;
  10093. private _draggedRoomRotation;
  10094. /**
  10095. * @hidden
  10096. */
  10097. _disableTrackPosition(fixedPosition: Vector3): void;
  10098. /**
  10099. * Internal, the mesh attached to the controller
  10100. * @hidden
  10101. */
  10102. _mesh: Nullable<AbstractMesh>;
  10103. private _poseControlledCamera;
  10104. private _leftHandSystemQuaternion;
  10105. /**
  10106. * Internal, matrix used to convert room space to babylon space
  10107. * @hidden
  10108. */
  10109. _deviceToWorld: Matrix;
  10110. /**
  10111. * Node to be used when casting a ray from the controller
  10112. * @hidden
  10113. */
  10114. _pointingPoseNode: Nullable<TransformNode>;
  10115. /**
  10116. * Name of the child mesh that can be used to cast a ray from the controller
  10117. */
  10118. static readonly POINTING_POSE: string;
  10119. /**
  10120. * Creates a new PoseEnabledController from a gamepad
  10121. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  10122. */
  10123. constructor(browserGamepad: any);
  10124. private _workingMatrix;
  10125. /**
  10126. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10127. */
  10128. update(): void;
  10129. /**
  10130. * Updates only the pose device and mesh without doing any button event checking
  10131. */
  10132. protected _updatePoseAndMesh(): void;
  10133. /**
  10134. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10135. * @param poseData raw pose fromthe device
  10136. */
  10137. updateFromDevice(poseData: DevicePose): void;
  10138. /**
  10139. * @hidden
  10140. */
  10141. _meshAttachedObservable: Observable<AbstractMesh>;
  10142. /**
  10143. * Attaches a mesh to the controller
  10144. * @param mesh the mesh to be attached
  10145. */
  10146. attachToMesh(mesh: AbstractMesh): void;
  10147. /**
  10148. * Attaches the controllers mesh to a camera
  10149. * @param camera the camera the mesh should be attached to
  10150. */
  10151. attachToPoseControlledCamera(camera: TargetCamera): void;
  10152. /**
  10153. * Disposes of the controller
  10154. */
  10155. dispose(): void;
  10156. /**
  10157. * The mesh that is attached to the controller
  10158. */
  10159. readonly mesh: Nullable<AbstractMesh>;
  10160. /**
  10161. * Gets the ray of the controller in the direction the controller is pointing
  10162. * @param length the length the resulting ray should be
  10163. * @returns a ray in the direction the controller is pointing
  10164. */
  10165. getForwardRay(length?: number): Ray;
  10166. }
  10167. }
  10168. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  10169. import { Observable } from "babylonjs/Misc/observable";
  10170. import { Scene } from "babylonjs/scene";
  10171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10172. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  10173. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  10174. /**
  10175. * Defines the WebVRController object that represents controllers tracked in 3D space
  10176. */
  10177. export abstract class WebVRController extends PoseEnabledController {
  10178. /**
  10179. * Internal, the default controller model for the controller
  10180. */
  10181. protected _defaultModel: AbstractMesh;
  10182. /**
  10183. * Fired when the trigger state has changed
  10184. */
  10185. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10186. /**
  10187. * Fired when the main button state has changed
  10188. */
  10189. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10190. /**
  10191. * Fired when the secondary button state has changed
  10192. */
  10193. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10194. /**
  10195. * Fired when the pad state has changed
  10196. */
  10197. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10198. /**
  10199. * Fired when controllers stick values have changed
  10200. */
  10201. onPadValuesChangedObservable: Observable<StickValues>;
  10202. /**
  10203. * Array of button availible on the controller
  10204. */
  10205. protected _buttons: Array<MutableGamepadButton>;
  10206. private _onButtonStateChange;
  10207. /**
  10208. * Fired when a controller button's state has changed
  10209. * @param callback the callback containing the button that was modified
  10210. */
  10211. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10212. /**
  10213. * X and Y axis corrisponding to the controllers joystick
  10214. */
  10215. pad: StickValues;
  10216. /**
  10217. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10218. */
  10219. hand: string;
  10220. /**
  10221. * The default controller model for the controller
  10222. */
  10223. readonly defaultModel: AbstractMesh;
  10224. /**
  10225. * Creates a new WebVRController from a gamepad
  10226. * @param vrGamepad the gamepad that the WebVRController should be created from
  10227. */
  10228. constructor(vrGamepad: any);
  10229. /**
  10230. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10231. */
  10232. update(): void;
  10233. /**
  10234. * Function to be called when a button is modified
  10235. */
  10236. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10237. /**
  10238. * Loads a mesh and attaches it to the controller
  10239. * @param scene the scene the mesh should be added to
  10240. * @param meshLoaded callback for when the mesh has been loaded
  10241. */
  10242. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10243. private _setButtonValue;
  10244. private _changes;
  10245. private _checkChanges;
  10246. /**
  10247. * Disposes of th webVRCOntroller
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Lights/shadowLight" {
  10253. import { Camera } from "babylonjs/Cameras/camera";
  10254. import { Scene } from "babylonjs/scene";
  10255. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10257. import { Light } from "babylonjs/Lights/light";
  10258. /**
  10259. * Interface describing all the common properties and methods a shadow light needs to implement.
  10260. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10261. * as well as binding the different shadow properties to the effects.
  10262. */
  10263. export interface IShadowLight extends Light {
  10264. /**
  10265. * The light id in the scene (used in scene.findLighById for instance)
  10266. */
  10267. id: string;
  10268. /**
  10269. * The position the shdow will be casted from.
  10270. */
  10271. position: Vector3;
  10272. /**
  10273. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10274. */
  10275. direction: Vector3;
  10276. /**
  10277. * The transformed position. Position of the light in world space taking parenting in account.
  10278. */
  10279. transformedPosition: Vector3;
  10280. /**
  10281. * The transformed direction. Direction of the light in world space taking parenting in account.
  10282. */
  10283. transformedDirection: Vector3;
  10284. /**
  10285. * The friendly name of the light in the scene.
  10286. */
  10287. name: string;
  10288. /**
  10289. * Defines the shadow projection clipping minimum z value.
  10290. */
  10291. shadowMinZ: number;
  10292. /**
  10293. * Defines the shadow projection clipping maximum z value.
  10294. */
  10295. shadowMaxZ: number;
  10296. /**
  10297. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10298. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10299. */
  10300. computeTransformedInformation(): boolean;
  10301. /**
  10302. * Gets the scene the light belongs to.
  10303. * @returns The scene
  10304. */
  10305. getScene(): Scene;
  10306. /**
  10307. * Callback defining a custom Projection Matrix Builder.
  10308. * This can be used to override the default projection matrix computation.
  10309. */
  10310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10311. /**
  10312. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10313. * @param matrix The materix to updated with the projection information
  10314. * @param viewMatrix The transform matrix of the light
  10315. * @param renderList The list of mesh to render in the map
  10316. * @returns The current light
  10317. */
  10318. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10319. /**
  10320. * Gets the current depth scale used in ESM.
  10321. * @returns The scale
  10322. */
  10323. getDepthScale(): number;
  10324. /**
  10325. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10326. * @returns true if a cube texture needs to be use
  10327. */
  10328. needCube(): boolean;
  10329. /**
  10330. * Detects if the projection matrix requires to be recomputed this frame.
  10331. * @returns true if it requires to be recomputed otherwise, false.
  10332. */
  10333. needProjectionMatrixCompute(): boolean;
  10334. /**
  10335. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10336. */
  10337. forceProjectionMatrixCompute(): void;
  10338. /**
  10339. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10340. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10341. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10342. */
  10343. getShadowDirection(faceIndex?: number): Vector3;
  10344. /**
  10345. * Gets the minZ used for shadow according to both the scene and the light.
  10346. * @param activeCamera The camera we are returning the min for
  10347. * @returns the depth min z
  10348. */
  10349. getDepthMinZ(activeCamera: Camera): number;
  10350. /**
  10351. * Gets the maxZ used for shadow according to both the scene and the light.
  10352. * @param activeCamera The camera we are returning the max for
  10353. * @returns the depth max z
  10354. */
  10355. getDepthMaxZ(activeCamera: Camera): number;
  10356. }
  10357. /**
  10358. * Base implementation IShadowLight
  10359. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10360. */
  10361. export abstract class ShadowLight extends Light implements IShadowLight {
  10362. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10363. protected _position: Vector3;
  10364. protected _setPosition(value: Vector3): void;
  10365. /**
  10366. * Sets the position the shadow will be casted from. Also use as the light position for both
  10367. * point and spot lights.
  10368. */
  10369. /**
  10370. * Sets the position the shadow will be casted from. Also use as the light position for both
  10371. * point and spot lights.
  10372. */
  10373. position: Vector3;
  10374. protected _direction: Vector3;
  10375. protected _setDirection(value: Vector3): void;
  10376. /**
  10377. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10378. * Also use as the light direction on spot and directional lights.
  10379. */
  10380. /**
  10381. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10382. * Also use as the light direction on spot and directional lights.
  10383. */
  10384. direction: Vector3;
  10385. private _shadowMinZ;
  10386. /**
  10387. * Gets the shadow projection clipping minimum z value.
  10388. */
  10389. /**
  10390. * Sets the shadow projection clipping minimum z value.
  10391. */
  10392. shadowMinZ: number;
  10393. private _shadowMaxZ;
  10394. /**
  10395. * Sets the shadow projection clipping maximum z value.
  10396. */
  10397. /**
  10398. * Gets the shadow projection clipping maximum z value.
  10399. */
  10400. shadowMaxZ: number;
  10401. /**
  10402. * Callback defining a custom Projection Matrix Builder.
  10403. * This can be used to override the default projection matrix computation.
  10404. */
  10405. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10406. /**
  10407. * The transformed position. Position of the light in world space taking parenting in account.
  10408. */
  10409. transformedPosition: Vector3;
  10410. /**
  10411. * The transformed direction. Direction of the light in world space taking parenting in account.
  10412. */
  10413. transformedDirection: Vector3;
  10414. private _needProjectionMatrixCompute;
  10415. /**
  10416. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10417. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10418. */
  10419. computeTransformedInformation(): boolean;
  10420. /**
  10421. * Return the depth scale used for the shadow map.
  10422. * @returns the depth scale.
  10423. */
  10424. getDepthScale(): number;
  10425. /**
  10426. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10427. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10428. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10429. */
  10430. getShadowDirection(faceIndex?: number): Vector3;
  10431. /**
  10432. * Returns the ShadowLight absolute position in the World.
  10433. * @returns the position vector in world space
  10434. */
  10435. getAbsolutePosition(): Vector3;
  10436. /**
  10437. * Sets the ShadowLight direction toward the passed target.
  10438. * @param target The point tot target in local space
  10439. * @returns the updated ShadowLight direction
  10440. */
  10441. setDirectionToTarget(target: Vector3): Vector3;
  10442. /**
  10443. * Returns the light rotation in euler definition.
  10444. * @returns the x y z rotation in local space.
  10445. */
  10446. getRotation(): Vector3;
  10447. /**
  10448. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10449. * @returns true if a cube texture needs to be use
  10450. */
  10451. needCube(): boolean;
  10452. /**
  10453. * Detects if the projection matrix requires to be recomputed this frame.
  10454. * @returns true if it requires to be recomputed otherwise, false.
  10455. */
  10456. needProjectionMatrixCompute(): boolean;
  10457. /**
  10458. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10459. */
  10460. forceProjectionMatrixCompute(): void;
  10461. /** @hidden */
  10462. _initCache(): void;
  10463. /** @hidden */
  10464. _isSynchronized(): boolean;
  10465. /**
  10466. * Computes the world matrix of the node
  10467. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10468. * @returns the world matrix
  10469. */
  10470. computeWorldMatrix(force?: boolean): Matrix;
  10471. /**
  10472. * Gets the minZ used for shadow according to both the scene and the light.
  10473. * @param activeCamera The camera we are returning the min for
  10474. * @returns the depth min z
  10475. */
  10476. getDepthMinZ(activeCamera: Camera): number;
  10477. /**
  10478. * Gets the maxZ used for shadow according to both the scene and the light.
  10479. * @param activeCamera The camera we are returning the max for
  10480. * @returns the depth max z
  10481. */
  10482. getDepthMaxZ(activeCamera: Camera): number;
  10483. /**
  10484. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10485. * @param matrix The materix to updated with the projection information
  10486. * @param viewMatrix The transform matrix of the light
  10487. * @param renderList The list of mesh to render in the map
  10488. * @returns The current light
  10489. */
  10490. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10491. }
  10492. }
  10493. declare module "babylonjs/Materials/materialHelper" {
  10494. import { Nullable } from "babylonjs/types";
  10495. import { Scene } from "babylonjs/scene";
  10496. import { Engine } from "babylonjs/Engines/engine";
  10497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10498. import { Light } from "babylonjs/Lights/light";
  10499. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10500. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  10501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10502. /**
  10503. * "Static Class" containing the most commonly used helper while dealing with material for
  10504. * rendering purpose.
  10505. *
  10506. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10507. *
  10508. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10509. */
  10510. export class MaterialHelper {
  10511. /**
  10512. * Bind the current view position to an effect.
  10513. * @param effect The effect to be bound
  10514. * @param scene The scene the eyes position is used from
  10515. */
  10516. static BindEyePosition(effect: Effect, scene: Scene): void;
  10517. /**
  10518. * Helps preparing the defines values about the UVs in used in the effect.
  10519. * UVs are shared as much as we can accross channels in the shaders.
  10520. * @param texture The texture we are preparing the UVs for
  10521. * @param defines The defines to update
  10522. * @param key The channel key "diffuse", "specular"... used in the shader
  10523. */
  10524. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10525. /**
  10526. * Binds a texture matrix value to its corrsponding uniform
  10527. * @param texture The texture to bind the matrix for
  10528. * @param uniformBuffer The uniform buffer receivin the data
  10529. * @param key The channel key "diffuse", "specular"... used in the shader
  10530. */
  10531. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10532. /**
  10533. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10534. * @param mesh defines the current mesh
  10535. * @param scene defines the current scene
  10536. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10537. * @param pointsCloud defines if point cloud rendering has to be turned on
  10538. * @param fogEnabled defines if fog has to be turned on
  10539. * @param alphaTest defines if alpha testing has to be turned on
  10540. * @param defines defines the current list of defines
  10541. */
  10542. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10543. /**
  10544. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10545. * @param scene defines the current scene
  10546. * @param engine defines the current engine
  10547. * @param defines specifies the list of active defines
  10548. * @param useInstances defines if instances have to be turned on
  10549. * @param useClipPlane defines if clip plane have to be turned on
  10550. */
  10551. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10552. /**
  10553. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10554. * @param mesh The mesh containing the geometry data we will draw
  10555. * @param defines The defines to update
  10556. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10557. * @param useBones Precise whether bones should be used or not (override mesh info)
  10558. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10559. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10560. * @returns false if defines are considered not dirty and have not been checked
  10561. */
  10562. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10563. /**
  10564. * Prepares the defines related to the light information passed in parameter
  10565. * @param scene The scene we are intending to draw
  10566. * @param mesh The mesh the effect is compiling for
  10567. * @param defines The defines to update
  10568. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10569. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10570. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10571. * @returns true if normals will be required for the rest of the effect
  10572. */
  10573. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10574. /**
  10575. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10576. * that won t be acctive due to defines being turned off.
  10577. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10578. * @param samplersList The samplers list
  10579. * @param defines The defines helping in the list generation
  10580. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10581. */
  10582. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10583. /**
  10584. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10585. * @param defines The defines to update while falling back
  10586. * @param fallbacks The authorized effect fallbacks
  10587. * @param maxSimultaneousLights The maximum number of lights allowed
  10588. * @param rank the current rank of the Effect
  10589. * @returns The newly affected rank
  10590. */
  10591. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10592. /**
  10593. * Prepares the list of attributes required for morph targets according to the effect defines.
  10594. * @param attribs The current list of supported attribs
  10595. * @param mesh The mesh to prepare the morph targets attributes for
  10596. * @param defines The current Defines of the effect
  10597. */
  10598. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10599. /**
  10600. * Prepares the list of attributes required for bones according to the effect defines.
  10601. * @param attribs The current list of supported attribs
  10602. * @param mesh The mesh to prepare the bones attributes for
  10603. * @param defines The current Defines of the effect
  10604. * @param fallbacks The current efffect fallback strategy
  10605. */
  10606. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10607. /**
  10608. * Prepares the list of attributes required for instances according to the effect defines.
  10609. * @param attribs The current list of supported attribs
  10610. * @param defines The current Defines of the effect
  10611. */
  10612. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10613. /**
  10614. * Binds the light shadow information to the effect for the given mesh.
  10615. * @param light The light containing the generator
  10616. * @param scene The scene the lights belongs to
  10617. * @param mesh The mesh we are binding the information to render
  10618. * @param lightIndex The light index in the effect used to render the mesh
  10619. * @param effect The effect we are binding the data to
  10620. */
  10621. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10622. /**
  10623. * Binds the light information to the effect.
  10624. * @param light The light containing the generator
  10625. * @param effect The effect we are binding the data to
  10626. * @param lightIndex The light index in the effect used to render
  10627. */
  10628. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10629. /**
  10630. * Binds the lights information from the scene to the effect for the given mesh.
  10631. * @param scene The scene the lights belongs to
  10632. * @param mesh The mesh we are binding the information to render
  10633. * @param effect The effect we are binding the data to
  10634. * @param defines The generated defines for the effect
  10635. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10636. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10637. */
  10638. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10639. private static _tempFogColor;
  10640. /**
  10641. * Binds the fog information from the scene to the effect for the given mesh.
  10642. * @param scene The scene the lights belongs to
  10643. * @param mesh The mesh we are binding the information to render
  10644. * @param effect The effect we are binding the data to
  10645. * @param linearSpace Defines if the fog effect is applied in linear space
  10646. */
  10647. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10648. /**
  10649. * Binds the bones information from the mesh to the effect.
  10650. * @param mesh The mesh we are binding the information to render
  10651. * @param effect The effect we are binding the data to
  10652. */
  10653. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10654. /**
  10655. * Binds the morph targets information from the mesh to the effect.
  10656. * @param abstractMesh The mesh we are binding the information to render
  10657. * @param effect The effect we are binding the data to
  10658. */
  10659. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10660. /**
  10661. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10662. * @param defines The generated defines used in the effect
  10663. * @param effect The effect we are binding the data to
  10664. * @param scene The scene we are willing to render with logarithmic scale for
  10665. */
  10666. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10667. /**
  10668. * Binds the clip plane information from the scene to the effect.
  10669. * @param scene The scene the clip plane information are extracted from
  10670. * @param effect The effect we are binding the data to
  10671. */
  10672. static BindClipPlane(effect: Effect, scene: Scene): void;
  10673. }
  10674. }
  10675. declare module "babylonjs/Shaders/shadowMap.fragment" {
  10676. /** @hidden */
  10677. export var shadowMapPixelShader: {
  10678. name: string;
  10679. shader: string;
  10680. };
  10681. }
  10682. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  10683. /** @hidden */
  10684. export var bonesDeclaration: {
  10685. name: string;
  10686. shader: string;
  10687. };
  10688. }
  10689. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  10690. /** @hidden */
  10691. export var morphTargetsVertexGlobalDeclaration: {
  10692. name: string;
  10693. shader: string;
  10694. };
  10695. }
  10696. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  10697. /** @hidden */
  10698. export var morphTargetsVertexDeclaration: {
  10699. name: string;
  10700. shader: string;
  10701. };
  10702. }
  10703. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  10704. /** @hidden */
  10705. export var instancesDeclaration: {
  10706. name: string;
  10707. shader: string;
  10708. };
  10709. }
  10710. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  10711. /** @hidden */
  10712. export var helperFunctions: {
  10713. name: string;
  10714. shader: string;
  10715. };
  10716. }
  10717. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  10718. /** @hidden */
  10719. export var morphTargetsVertex: {
  10720. name: string;
  10721. shader: string;
  10722. };
  10723. }
  10724. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  10725. /** @hidden */
  10726. export var instancesVertex: {
  10727. name: string;
  10728. shader: string;
  10729. };
  10730. }
  10731. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  10732. /** @hidden */
  10733. export var bonesVertex: {
  10734. name: string;
  10735. shader: string;
  10736. };
  10737. }
  10738. declare module "babylonjs/Shaders/shadowMap.vertex" {
  10739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  10740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  10741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  10742. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  10743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  10744. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  10745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  10746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  10747. /** @hidden */
  10748. export var shadowMapVertexShader: {
  10749. name: string;
  10750. shader: string;
  10751. };
  10752. }
  10753. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10754. /** @hidden */
  10755. export var depthBoxBlurPixelShader: {
  10756. name: string;
  10757. shader: string;
  10758. };
  10759. }
  10760. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10761. import { Nullable } from "babylonjs/types";
  10762. import { Scene } from "babylonjs/scene";
  10763. import { Matrix } from "babylonjs/Maths/math";
  10764. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10766. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10767. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10768. import { Effect } from "babylonjs/Materials/effect";
  10769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10770. import "babylonjs/Shaders/shadowMap.fragment";
  10771. import "babylonjs/Shaders/shadowMap.vertex";
  10772. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10773. import { Observable } from "babylonjs/Misc/observable";
  10774. /**
  10775. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10776. */
  10777. export interface ICustomShaderOptions {
  10778. /**
  10779. * Gets or sets the custom shader name to use
  10780. */
  10781. shaderName: string;
  10782. /**
  10783. * The list of attribute names used in the shader
  10784. */
  10785. attributes?: string[];
  10786. /**
  10787. * The list of unifrom names used in the shader
  10788. */
  10789. uniforms?: string[];
  10790. /**
  10791. * The list of sampler names used in the shader
  10792. */
  10793. samplers?: string[];
  10794. /**
  10795. * The list of defines used in the shader
  10796. */
  10797. defines?: string[];
  10798. }
  10799. /**
  10800. * Interface to implement to create a shadow generator compatible with BJS.
  10801. */
  10802. export interface IShadowGenerator {
  10803. /**
  10804. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10805. * @returns The render target texture if present otherwise, null
  10806. */
  10807. getShadowMap(): Nullable<RenderTargetTexture>;
  10808. /**
  10809. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10810. * @returns The render target texture if the shadow map is present otherwise, null
  10811. */
  10812. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10813. /**
  10814. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10815. * @param subMesh The submesh we want to render in the shadow map
  10816. * @param useInstances Defines wether will draw in the map using instances
  10817. * @returns true if ready otherwise, false
  10818. */
  10819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10820. /**
  10821. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10822. * @param defines Defines of the material we want to update
  10823. * @param lightIndex Index of the light in the enabled light list of the material
  10824. */
  10825. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10826. /**
  10827. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10828. * defined in the generator but impacting the effect).
  10829. * It implies the unifroms available on the materials are the standard BJS ones.
  10830. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10831. * @param effect The effect we are binfing the information for
  10832. */
  10833. bindShadowLight(lightIndex: string, effect: Effect): void;
  10834. /**
  10835. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10836. * (eq to shadow prjection matrix * light transform matrix)
  10837. * @returns The transform matrix used to create the shadow map
  10838. */
  10839. getTransformMatrix(): Matrix;
  10840. /**
  10841. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10842. * Cube and 2D textures for instance.
  10843. */
  10844. recreateShadowMap(): void;
  10845. /**
  10846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10847. * @param onCompiled Callback triggered at the and of the effects compilation
  10848. * @param options Sets of optional options forcing the compilation with different modes
  10849. */
  10850. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10851. useInstances: boolean;
  10852. }>): void;
  10853. /**
  10854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10855. * @param options Sets of optional options forcing the compilation with different modes
  10856. * @returns A promise that resolves when the compilation completes
  10857. */
  10858. forceCompilationAsync(options?: Partial<{
  10859. useInstances: boolean;
  10860. }>): Promise<void>;
  10861. /**
  10862. * Serializes the shadow generator setup to a json object.
  10863. * @returns The serialized JSON object
  10864. */
  10865. serialize(): any;
  10866. /**
  10867. * Disposes the Shadow map and related Textures and effects.
  10868. */
  10869. dispose(): void;
  10870. }
  10871. /**
  10872. * Default implementation IShadowGenerator.
  10873. * This is the main object responsible of generating shadows in the framework.
  10874. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10875. */
  10876. export class ShadowGenerator implements IShadowGenerator {
  10877. /**
  10878. * Shadow generator mode None: no filtering applied.
  10879. */
  10880. static readonly FILTER_NONE: number;
  10881. /**
  10882. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10883. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10884. */
  10885. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10886. /**
  10887. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10888. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10889. */
  10890. static readonly FILTER_POISSONSAMPLING: number;
  10891. /**
  10892. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10893. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10894. */
  10895. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10896. /**
  10897. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10898. * edge artifacts on steep falloff.
  10899. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10900. */
  10901. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10902. /**
  10903. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10904. * edge artifacts on steep falloff.
  10905. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10906. */
  10907. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10908. /**
  10909. * Shadow generator mode PCF: Percentage Closer Filtering
  10910. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10911. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10912. */
  10913. static readonly FILTER_PCF: number;
  10914. /**
  10915. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10916. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10917. * Contact Hardening
  10918. */
  10919. static readonly FILTER_PCSS: number;
  10920. /**
  10921. * Reserved for PCF and PCSS
  10922. * Highest Quality.
  10923. *
  10924. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10925. *
  10926. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10927. */
  10928. static readonly QUALITY_HIGH: number;
  10929. /**
  10930. * Reserved for PCF and PCSS
  10931. * Good tradeoff for quality/perf cross devices
  10932. *
  10933. * Execute PCF on a 3*3 kernel.
  10934. *
  10935. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10936. */
  10937. static readonly QUALITY_MEDIUM: number;
  10938. /**
  10939. * Reserved for PCF and PCSS
  10940. * The lowest quality but the fastest.
  10941. *
  10942. * Execute PCF on a 1*1 kernel.
  10943. *
  10944. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10945. */
  10946. static readonly QUALITY_LOW: number;
  10947. /** Gets or sets the custom shader name to use */
  10948. customShaderOptions: ICustomShaderOptions;
  10949. /**
  10950. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10951. */
  10952. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10953. private _bias;
  10954. /**
  10955. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10956. */
  10957. /**
  10958. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10959. */
  10960. bias: number;
  10961. private _normalBias;
  10962. /**
  10963. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10964. */
  10965. /**
  10966. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10967. */
  10968. normalBias: number;
  10969. private _blurBoxOffset;
  10970. /**
  10971. * Gets the blur box offset: offset applied during the blur pass.
  10972. * Only useful if useKernelBlur = false
  10973. */
  10974. /**
  10975. * Sets the blur box offset: offset applied during the blur pass.
  10976. * Only useful if useKernelBlur = false
  10977. */
  10978. blurBoxOffset: number;
  10979. private _blurScale;
  10980. /**
  10981. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10982. * 2 means half of the size.
  10983. */
  10984. /**
  10985. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10986. * 2 means half of the size.
  10987. */
  10988. blurScale: number;
  10989. private _blurKernel;
  10990. /**
  10991. * Gets the blur kernel: kernel size of the blur pass.
  10992. * Only useful if useKernelBlur = true
  10993. */
  10994. /**
  10995. * Sets the blur kernel: kernel size of the blur pass.
  10996. * Only useful if useKernelBlur = true
  10997. */
  10998. blurKernel: number;
  10999. private _useKernelBlur;
  11000. /**
  11001. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11002. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11003. */
  11004. /**
  11005. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11006. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11007. */
  11008. useKernelBlur: boolean;
  11009. private _depthScale;
  11010. /**
  11011. * Gets the depth scale used in ESM mode.
  11012. */
  11013. /**
  11014. * Sets the depth scale used in ESM mode.
  11015. * This can override the scale stored on the light.
  11016. */
  11017. depthScale: number;
  11018. private _filter;
  11019. /**
  11020. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11021. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11022. */
  11023. /**
  11024. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11025. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11026. */
  11027. filter: number;
  11028. /**
  11029. * Gets if the current filter is set to Poisson Sampling.
  11030. */
  11031. /**
  11032. * Sets the current filter to Poisson Sampling.
  11033. */
  11034. usePoissonSampling: boolean;
  11035. /**
  11036. * Gets if the current filter is set to ESM.
  11037. */
  11038. /**
  11039. * Sets the current filter is to ESM.
  11040. */
  11041. useExponentialShadowMap: boolean;
  11042. /**
  11043. * Gets if the current filter is set to filtered ESM.
  11044. */
  11045. /**
  11046. * Gets if the current filter is set to filtered ESM.
  11047. */
  11048. useBlurExponentialShadowMap: boolean;
  11049. /**
  11050. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11051. * exponential to prevent steep falloff artifacts).
  11052. */
  11053. /**
  11054. * Sets the current filter to "close ESM" (using the inverse of the
  11055. * exponential to prevent steep falloff artifacts).
  11056. */
  11057. useCloseExponentialShadowMap: boolean;
  11058. /**
  11059. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11060. * exponential to prevent steep falloff artifacts).
  11061. */
  11062. /**
  11063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11064. * exponential to prevent steep falloff artifacts).
  11065. */
  11066. useBlurCloseExponentialShadowMap: boolean;
  11067. /**
  11068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11069. */
  11070. /**
  11071. * Sets the current filter to "PCF" (percentage closer filtering).
  11072. */
  11073. usePercentageCloserFiltering: boolean;
  11074. private _filteringQuality;
  11075. /**
  11076. * Gets the PCF or PCSS Quality.
  11077. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11078. */
  11079. /**
  11080. * Sets the PCF or PCSS Quality.
  11081. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11082. */
  11083. filteringQuality: number;
  11084. /**
  11085. * Gets if the current filter is set to "PCSS" (contact hardening).
  11086. */
  11087. /**
  11088. * Sets the current filter to "PCSS" (contact hardening).
  11089. */
  11090. useContactHardeningShadow: boolean;
  11091. private _contactHardeningLightSizeUVRatio;
  11092. /**
  11093. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11094. * Using a ratio helps keeping shape stability independently of the map size.
  11095. *
  11096. * It does not account for the light projection as it was having too much
  11097. * instability during the light setup or during light position changes.
  11098. *
  11099. * Only valid if useContactHardeningShadow is true.
  11100. */
  11101. /**
  11102. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11103. * Using a ratio helps keeping shape stability independently of the map size.
  11104. *
  11105. * It does not account for the light projection as it was having too much
  11106. * instability during the light setup or during light position changes.
  11107. *
  11108. * Only valid if useContactHardeningShadow is true.
  11109. */
  11110. contactHardeningLightSizeUVRatio: number;
  11111. private _darkness;
  11112. /**
  11113. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11114. * 0 means strongest and 1 would means no shadow.
  11115. * @returns the darkness.
  11116. */
  11117. getDarkness(): number;
  11118. /**
  11119. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11120. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11121. * @returns the shadow generator allowing fluent coding.
  11122. */
  11123. setDarkness(darkness: number): ShadowGenerator;
  11124. private _transparencyShadow;
  11125. /**
  11126. * Sets the ability to have transparent shadow (boolean).
  11127. * @param transparent True if transparent else False
  11128. * @returns the shadow generator allowing fluent coding
  11129. */
  11130. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11131. private _shadowMap;
  11132. private _shadowMap2;
  11133. /**
  11134. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11135. * @returns The render target texture if present otherwise, null
  11136. */
  11137. getShadowMap(): Nullable<RenderTargetTexture>;
  11138. /**
  11139. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11140. * @returns The render target texture if the shadow map is present otherwise, null
  11141. */
  11142. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11143. /**
  11144. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11145. * @param mesh Mesh to add
  11146. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11147. * @returns the Shadow Generator itself
  11148. */
  11149. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11150. /**
  11151. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11152. * @param mesh Mesh to remove
  11153. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11154. * @returns the Shadow Generator itself
  11155. */
  11156. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11157. /**
  11158. * Controls the extent to which the shadows fade out at the edge of the frustum
  11159. * Used only by directionals and spots
  11160. */
  11161. frustumEdgeFalloff: number;
  11162. private _light;
  11163. /**
  11164. * Returns the associated light object.
  11165. * @returns the light generating the shadow
  11166. */
  11167. getLight(): IShadowLight;
  11168. /**
  11169. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11170. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11171. * It might on the other hand introduce peter panning.
  11172. */
  11173. forceBackFacesOnly: boolean;
  11174. private _scene;
  11175. private _lightDirection;
  11176. private _effect;
  11177. private _viewMatrix;
  11178. private _projectionMatrix;
  11179. private _transformMatrix;
  11180. private _cachedPosition;
  11181. private _cachedDirection;
  11182. private _cachedDefines;
  11183. private _currentRenderID;
  11184. private _boxBlurPostprocess;
  11185. private _kernelBlurXPostprocess;
  11186. private _kernelBlurYPostprocess;
  11187. private _blurPostProcesses;
  11188. private _mapSize;
  11189. private _currentFaceIndex;
  11190. private _currentFaceIndexCache;
  11191. private _textureType;
  11192. private _defaultTextureMatrix;
  11193. /** @hidden */
  11194. static _SceneComponentInitialization: (scene: Scene) => void;
  11195. /**
  11196. * Creates a ShadowGenerator object.
  11197. * A ShadowGenerator is the required tool to use the shadows.
  11198. * Each light casting shadows needs to use its own ShadowGenerator.
  11199. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11200. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11201. * @param light The light object generating the shadows.
  11202. * @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.
  11203. */
  11204. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11205. private _initializeGenerator;
  11206. private _initializeShadowMap;
  11207. private _initializeBlurRTTAndPostProcesses;
  11208. private _renderForShadowMap;
  11209. private _renderSubMeshForShadowMap;
  11210. private _applyFilterValues;
  11211. /**
  11212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11213. * @param onCompiled Callback triggered at the and of the effects compilation
  11214. * @param options Sets of optional options forcing the compilation with different modes
  11215. */
  11216. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11217. useInstances: boolean;
  11218. }>): void;
  11219. /**
  11220. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11221. * @param options Sets of optional options forcing the compilation with different modes
  11222. * @returns A promise that resolves when the compilation completes
  11223. */
  11224. forceCompilationAsync(options?: Partial<{
  11225. useInstances: boolean;
  11226. }>): Promise<void>;
  11227. /**
  11228. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11229. * @param subMesh The submesh we want to render in the shadow map
  11230. * @param useInstances Defines wether will draw in the map using instances
  11231. * @returns true if ready otherwise, false
  11232. */
  11233. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11234. /**
  11235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11236. * @param defines Defines of the material we want to update
  11237. * @param lightIndex Index of the light in the enabled light list of the material
  11238. */
  11239. prepareDefines(defines: any, lightIndex: number): void;
  11240. /**
  11241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11242. * defined in the generator but impacting the effect).
  11243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11244. * @param effect The effect we are binfing the information for
  11245. */
  11246. bindShadowLight(lightIndex: string, effect: Effect): void;
  11247. /**
  11248. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11249. * (eq to shadow prjection matrix * light transform matrix)
  11250. * @returns The transform matrix used to create the shadow map
  11251. */
  11252. getTransformMatrix(): Matrix;
  11253. /**
  11254. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11255. * Cube and 2D textures for instance.
  11256. */
  11257. recreateShadowMap(): void;
  11258. private _disposeBlurPostProcesses;
  11259. private _disposeRTTandPostProcesses;
  11260. /**
  11261. * Disposes the ShadowGenerator.
  11262. * Returns nothing.
  11263. */
  11264. dispose(): void;
  11265. /**
  11266. * Serializes the shadow generator setup to a json object.
  11267. * @returns The serialized JSON object
  11268. */
  11269. serialize(): any;
  11270. /**
  11271. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11272. * @param parsedShadowGenerator The JSON object to parse
  11273. * @param scene The scene to create the shadow map for
  11274. * @returns The parsed shadow generator
  11275. */
  11276. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11277. }
  11278. }
  11279. declare module "babylonjs/Lights/light" {
  11280. import { Nullable } from "babylonjs/types";
  11281. import { Scene } from "babylonjs/scene";
  11282. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11283. import { Node } from "babylonjs/node";
  11284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11285. import { Effect } from "babylonjs/Materials/effect";
  11286. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11287. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11288. /**
  11289. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11290. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11291. * 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.
  11292. */
  11293. export abstract class Light extends Node {
  11294. /**
  11295. * Falloff Default: light is falling off following the material specification:
  11296. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11297. */
  11298. static readonly FALLOFF_DEFAULT: number;
  11299. /**
  11300. * Falloff Physical: light is falling off following the inverse squared distance law.
  11301. */
  11302. static readonly FALLOFF_PHYSICAL: number;
  11303. /**
  11304. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11305. * to enhance interoperability with other engines.
  11306. */
  11307. static readonly FALLOFF_GLTF: number;
  11308. /**
  11309. * Falloff Standard: light is falling off like in the standard material
  11310. * to enhance interoperability with other materials.
  11311. */
  11312. static readonly FALLOFF_STANDARD: number;
  11313. /**
  11314. * If every light affecting the material is in this lightmapMode,
  11315. * material.lightmapTexture adds or multiplies
  11316. * (depends on material.useLightmapAsShadowmap)
  11317. * after every other light calculations.
  11318. */
  11319. static readonly LIGHTMAP_DEFAULT: number;
  11320. /**
  11321. * material.lightmapTexture as only diffuse lighting from this light
  11322. * adds only specular lighting from this light
  11323. * adds dynamic shadows
  11324. */
  11325. static readonly LIGHTMAP_SPECULAR: number;
  11326. /**
  11327. * material.lightmapTexture as only lighting
  11328. * no light calculation from this light
  11329. * only adds dynamic shadows from this light
  11330. */
  11331. static readonly LIGHTMAP_SHADOWSONLY: number;
  11332. /**
  11333. * Each light type uses the default quantity according to its type:
  11334. * point/spot lights use luminous intensity
  11335. * directional lights use illuminance
  11336. */
  11337. static readonly INTENSITYMODE_AUTOMATIC: number;
  11338. /**
  11339. * lumen (lm)
  11340. */
  11341. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11342. /**
  11343. * candela (lm/sr)
  11344. */
  11345. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11346. /**
  11347. * lux (lm/m^2)
  11348. */
  11349. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11350. /**
  11351. * nit (cd/m^2)
  11352. */
  11353. static readonly INTENSITYMODE_LUMINANCE: number;
  11354. /**
  11355. * Light type const id of the point light.
  11356. */
  11357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11358. /**
  11359. * Light type const id of the directional light.
  11360. */
  11361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11362. /**
  11363. * Light type const id of the spot light.
  11364. */
  11365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11366. /**
  11367. * Light type const id of the hemispheric light.
  11368. */
  11369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11370. /**
  11371. * Diffuse gives the basic color to an object.
  11372. */
  11373. diffuse: Color3;
  11374. /**
  11375. * Specular produces a highlight color on an object.
  11376. * Note: This is note affecting PBR materials.
  11377. */
  11378. specular: Color3;
  11379. /**
  11380. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11381. * falling off base on range or angle.
  11382. * This can be set to any values in Light.FALLOFF_x.
  11383. *
  11384. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11385. * other types of materials.
  11386. */
  11387. falloffType: number;
  11388. /**
  11389. * Strength of the light.
  11390. * Note: By default it is define in the framework own unit.
  11391. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11392. */
  11393. intensity: number;
  11394. private _range;
  11395. protected _inverseSquaredRange: number;
  11396. /**
  11397. * Defines how far from the source the light is impacting in scene units.
  11398. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11399. */
  11400. /**
  11401. * Defines how far from the source the light is impacting in scene units.
  11402. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11403. */
  11404. range: number;
  11405. /**
  11406. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11407. * of light.
  11408. */
  11409. private _photometricScale;
  11410. private _intensityMode;
  11411. /**
  11412. * Gets the photometric scale used to interpret the intensity.
  11413. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11414. */
  11415. /**
  11416. * Sets the photometric scale used to interpret the intensity.
  11417. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11418. */
  11419. intensityMode: number;
  11420. private _radius;
  11421. /**
  11422. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11423. */
  11424. /**
  11425. * sets the light radius used by PBR Materials to simulate soft area lights.
  11426. */
  11427. radius: number;
  11428. private _renderPriority;
  11429. /**
  11430. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11431. * exceeding the number allowed of the materials.
  11432. */
  11433. renderPriority: number;
  11434. private _shadowEnabled;
  11435. /**
  11436. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11437. * the current shadow generator.
  11438. */
  11439. /**
  11440. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11441. * the current shadow generator.
  11442. */
  11443. shadowEnabled: boolean;
  11444. private _includedOnlyMeshes;
  11445. /**
  11446. * Gets the only meshes impacted by this light.
  11447. */
  11448. /**
  11449. * Sets the only meshes impacted by this light.
  11450. */
  11451. includedOnlyMeshes: AbstractMesh[];
  11452. private _excludedMeshes;
  11453. /**
  11454. * Gets the meshes not impacted by this light.
  11455. */
  11456. /**
  11457. * Sets the meshes not impacted by this light.
  11458. */
  11459. excludedMeshes: AbstractMesh[];
  11460. private _excludeWithLayerMask;
  11461. /**
  11462. * Gets the layer id use to find what meshes are not impacted by the light.
  11463. * Inactive if 0
  11464. */
  11465. /**
  11466. * Sets the layer id use to find what meshes are not impacted by the light.
  11467. * Inactive if 0
  11468. */
  11469. excludeWithLayerMask: number;
  11470. private _includeOnlyWithLayerMask;
  11471. /**
  11472. * Gets the layer id use to find what meshes are impacted by the light.
  11473. * Inactive if 0
  11474. */
  11475. /**
  11476. * Sets the layer id use to find what meshes are impacted by the light.
  11477. * Inactive if 0
  11478. */
  11479. includeOnlyWithLayerMask: number;
  11480. private _lightmapMode;
  11481. /**
  11482. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11483. */
  11484. /**
  11485. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11486. */
  11487. lightmapMode: number;
  11488. /**
  11489. * Shadow generator associted to the light.
  11490. * @hidden Internal use only.
  11491. */
  11492. _shadowGenerator: Nullable<IShadowGenerator>;
  11493. /**
  11494. * @hidden Internal use only.
  11495. */
  11496. _excludedMeshesIds: string[];
  11497. /**
  11498. * @hidden Internal use only.
  11499. */
  11500. _includedOnlyMeshesIds: string[];
  11501. /**
  11502. * The current light unifom buffer.
  11503. * @hidden Internal use only.
  11504. */
  11505. _uniformBuffer: UniformBuffer;
  11506. /**
  11507. * Creates a Light object in the scene.
  11508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11509. * @param name The firendly name of the light
  11510. * @param scene The scene the light belongs too
  11511. */
  11512. constructor(name: string, scene: Scene);
  11513. protected abstract _buildUniformLayout(): void;
  11514. /**
  11515. * Sets the passed Effect "effect" with the Light information.
  11516. * @param effect The effect to update
  11517. * @param lightIndex The index of the light in the effect to update
  11518. * @returns The light
  11519. */
  11520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11521. /**
  11522. * Returns the string "Light".
  11523. * @returns the class name
  11524. */
  11525. getClassName(): string;
  11526. /** @hidden */
  11527. readonly _isLight: boolean;
  11528. /**
  11529. * Converts the light information to a readable string for debug purpose.
  11530. * @param fullDetails Supports for multiple levels of logging within scene loading
  11531. * @returns the human readable light info
  11532. */
  11533. toString(fullDetails?: boolean): string;
  11534. /** @hidden */
  11535. protected _syncParentEnabledState(): void;
  11536. /**
  11537. * Set the enabled state of this node.
  11538. * @param value - the new enabled state
  11539. */
  11540. setEnabled(value: boolean): void;
  11541. /**
  11542. * Returns the Light associated shadow generator if any.
  11543. * @return the associated shadow generator.
  11544. */
  11545. getShadowGenerator(): Nullable<IShadowGenerator>;
  11546. /**
  11547. * Returns a Vector3, the absolute light position in the World.
  11548. * @returns the world space position of the light
  11549. */
  11550. getAbsolutePosition(): Vector3;
  11551. /**
  11552. * Specifies if the light will affect the passed mesh.
  11553. * @param mesh The mesh to test against the light
  11554. * @return true the mesh is affected otherwise, false.
  11555. */
  11556. canAffectMesh(mesh: AbstractMesh): boolean;
  11557. /**
  11558. * Sort function to order lights for rendering.
  11559. * @param a First Light object to compare to second.
  11560. * @param b Second Light object to compare first.
  11561. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11562. */
  11563. static CompareLightsPriority(a: Light, b: Light): number;
  11564. /**
  11565. * Releases resources associated with this node.
  11566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11568. */
  11569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11570. /**
  11571. * Returns the light type ID (integer).
  11572. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11573. */
  11574. getTypeID(): number;
  11575. /**
  11576. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11577. * @returns the scaled intensity in intensity mode unit
  11578. */
  11579. getScaledIntensity(): number;
  11580. /**
  11581. * Returns a new Light object, named "name", from the current one.
  11582. * @param name The name of the cloned light
  11583. * @returns the new created light
  11584. */
  11585. clone(name: string): Nullable<Light>;
  11586. /**
  11587. * Serializes the current light into a Serialization object.
  11588. * @returns the serialized object.
  11589. */
  11590. serialize(): any;
  11591. /**
  11592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11593. * This new light is named "name" and added to the passed scene.
  11594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11595. * @param name The friendly name of the light
  11596. * @param scene The scene the new light will belong to
  11597. * @returns the constructor function
  11598. */
  11599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11600. /**
  11601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11602. * @param parsedLight The JSON representation of the light
  11603. * @param scene The scene to create the parsed light in
  11604. * @returns the created light after parsing
  11605. */
  11606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11607. private _hookArrayForExcluded;
  11608. private _hookArrayForIncludedOnly;
  11609. private _resyncMeshes;
  11610. /**
  11611. * Forces the meshes to update their light related information in their rendering used effects
  11612. * @hidden Internal Use Only
  11613. */
  11614. _markMeshesAsLightDirty(): void;
  11615. /**
  11616. * Recomputes the cached photometric scale if needed.
  11617. */
  11618. private _computePhotometricScale;
  11619. /**
  11620. * Returns the Photometric Scale according to the light type and intensity mode.
  11621. */
  11622. private _getPhotometricScale;
  11623. /**
  11624. * Reorder the light in the scene according to their defined priority.
  11625. * @hidden Internal Use Only
  11626. */
  11627. _reorderLightsInScene(): void;
  11628. /**
  11629. * Prepares the list of defines specific to the light type.
  11630. * @param defines the list of defines
  11631. * @param lightIndex defines the index of the light for the effect
  11632. */
  11633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11634. }
  11635. }
  11636. declare module "babylonjs/Lights/hemisphericLight" {
  11637. import { Nullable } from "babylonjs/types";
  11638. import { Scene } from "babylonjs/scene";
  11639. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  11640. import { Effect } from "babylonjs/Materials/effect";
  11641. import { Light } from "babylonjs/Lights/light";
  11642. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11643. /**
  11644. * The HemisphericLight simulates the ambient environment light,
  11645. * so the passed direction is the light reflection direction, not the incoming direction.
  11646. */
  11647. export class HemisphericLight extends Light {
  11648. /**
  11649. * The groundColor is the light in the opposite direction to the one specified during creation.
  11650. * 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.
  11651. */
  11652. groundColor: Color3;
  11653. /**
  11654. * The light reflection direction, not the incoming direction.
  11655. */
  11656. direction: Vector3;
  11657. /**
  11658. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11659. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11660. * The HemisphericLight can't cast shadows.
  11661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11662. * @param name The friendly name of the light
  11663. * @param direction The direction of the light reflection
  11664. * @param scene The scene the light belongs to
  11665. */
  11666. constructor(name: string, direction: Vector3, scene: Scene);
  11667. protected _buildUniformLayout(): void;
  11668. /**
  11669. * Returns the string "HemisphericLight".
  11670. * @return The class name
  11671. */
  11672. getClassName(): string;
  11673. /**
  11674. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11675. * Returns the updated direction.
  11676. * @param target The target the direction should point to
  11677. * @return The computed direction
  11678. */
  11679. setDirectionToTarget(target: Vector3): Vector3;
  11680. /**
  11681. * Returns the shadow generator associated to the light.
  11682. * @returns Always null for hemispheric lights because it does not support shadows.
  11683. */
  11684. getShadowGenerator(): Nullable<IShadowGenerator>;
  11685. /**
  11686. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11687. * @param effect The effect to update
  11688. * @param lightIndex The index of the light in the effect to update
  11689. * @returns The hemispheric light
  11690. */
  11691. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11692. /**
  11693. * Computes the world matrix of the node
  11694. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11695. * @param useWasUpdatedFlag defines a reserved property
  11696. * @returns the world matrix
  11697. */
  11698. computeWorldMatrix(): Matrix;
  11699. /**
  11700. * Returns the integer 3.
  11701. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11702. */
  11703. getTypeID(): number;
  11704. /**
  11705. * Prepares the list of defines specific to the light type.
  11706. * @param defines the list of defines
  11707. * @param lightIndex defines the index of the light for the effect
  11708. */
  11709. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  11713. declare module "babylonjs/Cameras/VR/webVRCamera" {
  11714. import { Nullable } from "babylonjs/types";
  11715. import { Observable } from "babylonjs/Misc/observable";
  11716. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11717. import { Scene } from "babylonjs/scene";
  11718. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  11720. import { Node } from "babylonjs/node";
  11721. import { Ray } from "babylonjs/Culling/ray";
  11722. import "babylonjs/Cameras/RigModes/webVRRigMode";
  11723. /**
  11724. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11725. * IMPORTANT!! The data is right-hand data.
  11726. * @export
  11727. * @interface DevicePose
  11728. */
  11729. export interface DevicePose {
  11730. /**
  11731. * The position of the device, values in array are [x,y,z].
  11732. */
  11733. readonly position: Nullable<Float32Array>;
  11734. /**
  11735. * The linearVelocity of the device, values in array are [x,y,z].
  11736. */
  11737. readonly linearVelocity: Nullable<Float32Array>;
  11738. /**
  11739. * The linearAcceleration of the device, values in array are [x,y,z].
  11740. */
  11741. readonly linearAcceleration: Nullable<Float32Array>;
  11742. /**
  11743. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11744. */
  11745. readonly orientation: Nullable<Float32Array>;
  11746. /**
  11747. * The angularVelocity of the device, values in array are [x,y,z].
  11748. */
  11749. readonly angularVelocity: Nullable<Float32Array>;
  11750. /**
  11751. * The angularAcceleration of the device, values in array are [x,y,z].
  11752. */
  11753. readonly angularAcceleration: Nullable<Float32Array>;
  11754. }
  11755. /**
  11756. * Interface representing a pose controlled object in Babylon.
  11757. * A pose controlled object has both regular pose values as well as pose values
  11758. * from an external device such as a VR head mounted display
  11759. */
  11760. export interface PoseControlled {
  11761. /**
  11762. * The position of the object in babylon space.
  11763. */
  11764. position: Vector3;
  11765. /**
  11766. * The rotation quaternion of the object in babylon space.
  11767. */
  11768. rotationQuaternion: Quaternion;
  11769. /**
  11770. * The position of the device in babylon space.
  11771. */
  11772. devicePosition?: Vector3;
  11773. /**
  11774. * The rotation quaternion of the device in babylon space.
  11775. */
  11776. deviceRotationQuaternion: Quaternion;
  11777. /**
  11778. * The raw pose coming from the device.
  11779. */
  11780. rawPose: Nullable<DevicePose>;
  11781. /**
  11782. * The scale of the device to be used when translating from device space to babylon space.
  11783. */
  11784. deviceScaleFactor: number;
  11785. /**
  11786. * Updates the poseControlled values based on the input device pose.
  11787. * @param poseData the pose data to update the object with
  11788. */
  11789. updateFromDevice(poseData: DevicePose): void;
  11790. }
  11791. /**
  11792. * Set of options to customize the webVRCamera
  11793. */
  11794. export interface WebVROptions {
  11795. /**
  11796. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11797. */
  11798. trackPosition?: boolean;
  11799. /**
  11800. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11801. */
  11802. positionScale?: number;
  11803. /**
  11804. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11805. */
  11806. displayName?: string;
  11807. /**
  11808. * Should the native controller meshes be initialized. (default: true)
  11809. */
  11810. controllerMeshes?: boolean;
  11811. /**
  11812. * Creating a default HemiLight only on controllers. (default: true)
  11813. */
  11814. defaultLightingOnControllers?: boolean;
  11815. /**
  11816. * If you don't want to use the default VR button of the helper. (default: false)
  11817. */
  11818. useCustomVRButton?: boolean;
  11819. /**
  11820. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11821. */
  11822. customVRButton?: HTMLButtonElement;
  11823. /**
  11824. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11825. */
  11826. rayLength?: number;
  11827. /**
  11828. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11829. */
  11830. defaultHeight?: number;
  11831. }
  11832. /**
  11833. * This represents a WebVR camera.
  11834. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11835. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11836. */
  11837. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11838. private webVROptions;
  11839. /**
  11840. * @hidden
  11841. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11842. */
  11843. _vrDevice: any;
  11844. /**
  11845. * The rawPose of the vrDevice.
  11846. */
  11847. rawPose: Nullable<DevicePose>;
  11848. private _onVREnabled;
  11849. private _specsVersion;
  11850. private _attached;
  11851. private _frameData;
  11852. protected _descendants: Array<Node>;
  11853. private _deviceRoomPosition;
  11854. /** @hidden */
  11855. _deviceRoomRotationQuaternion: Quaternion;
  11856. private _standingMatrix;
  11857. /**
  11858. * Represents device position in babylon space.
  11859. */
  11860. devicePosition: Vector3;
  11861. /**
  11862. * Represents device rotation in babylon space.
  11863. */
  11864. deviceRotationQuaternion: Quaternion;
  11865. /**
  11866. * The scale of the device to be used when translating from device space to babylon space.
  11867. */
  11868. deviceScaleFactor: number;
  11869. private _deviceToWorld;
  11870. private _worldToDevice;
  11871. /**
  11872. * References to the webVR controllers for the vrDevice.
  11873. */
  11874. controllers: Array<WebVRController>;
  11875. /**
  11876. * Emits an event when a controller is attached.
  11877. */
  11878. onControllersAttachedObservable: Observable<WebVRController[]>;
  11879. /**
  11880. * Emits an event when a controller's mesh has been loaded;
  11881. */
  11882. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11883. /**
  11884. * Emits an event when the HMD's pose has been updated.
  11885. */
  11886. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11887. private _poseSet;
  11888. /**
  11889. * If the rig cameras be used as parent instead of this camera.
  11890. */
  11891. rigParenting: boolean;
  11892. private _lightOnControllers;
  11893. private _defaultHeight?;
  11894. /**
  11895. * Instantiates a WebVRFreeCamera.
  11896. * @param name The name of the WebVRFreeCamera
  11897. * @param position The starting anchor position for the camera
  11898. * @param scene The scene the camera belongs to
  11899. * @param webVROptions a set of customizable options for the webVRCamera
  11900. */
  11901. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11902. /**
  11903. * Gets the device distance from the ground in meters.
  11904. * @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.
  11905. */
  11906. deviceDistanceToRoomGround(): number;
  11907. /**
  11908. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11909. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11910. */
  11911. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11912. /**
  11913. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11914. * @returns A promise with a boolean set to if the standing matrix is supported.
  11915. */
  11916. useStandingMatrixAsync(): Promise<boolean>;
  11917. /**
  11918. * Disposes the camera
  11919. */
  11920. dispose(): void;
  11921. /**
  11922. * Gets a vrController by name.
  11923. * @param name The name of the controller to retreive
  11924. * @returns the controller matching the name specified or null if not found
  11925. */
  11926. getControllerByName(name: string): Nullable<WebVRController>;
  11927. private _leftController;
  11928. /**
  11929. * The controller corrisponding to the users left hand.
  11930. */
  11931. readonly leftController: Nullable<WebVRController>;
  11932. private _rightController;
  11933. /**
  11934. * The controller corrisponding to the users right hand.
  11935. */
  11936. readonly rightController: Nullable<WebVRController>;
  11937. /**
  11938. * Casts a ray forward from the vrCamera's gaze.
  11939. * @param length Length of the ray (default: 100)
  11940. * @returns the ray corrisponding to the gaze
  11941. */
  11942. getForwardRay(length?: number): Ray;
  11943. /**
  11944. * @hidden
  11945. * Updates the camera based on device's frame data
  11946. */
  11947. _checkInputs(): void;
  11948. /**
  11949. * Updates the poseControlled values based on the input device pose.
  11950. * @param poseData Pose coming from the device
  11951. */
  11952. updateFromDevice(poseData: DevicePose): void;
  11953. private _htmlElementAttached;
  11954. private _detachIfAttached;
  11955. /**
  11956. * WebVR's attach control will start broadcasting frames to the device.
  11957. * Note that in certain browsers (chrome for example) this function must be called
  11958. * within a user-interaction callback. Example:
  11959. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11960. *
  11961. * @param element html element to attach the vrDevice to
  11962. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11963. */
  11964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11965. /**
  11966. * Detaches the camera from the html element and disables VR
  11967. *
  11968. * @param element html element to detach from
  11969. */
  11970. detachControl(element: HTMLElement): void;
  11971. /**
  11972. * @returns the name of this class
  11973. */
  11974. getClassName(): string;
  11975. /**
  11976. * Calls resetPose on the vrDisplay
  11977. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11978. */
  11979. resetToCurrentRotation(): void;
  11980. /**
  11981. * @hidden
  11982. * Updates the rig cameras (left and right eye)
  11983. */
  11984. _updateRigCameras(): void;
  11985. private _workingVector;
  11986. private _oneVector;
  11987. private _workingMatrix;
  11988. private updateCacheCalled;
  11989. private _correctPositionIfNotTrackPosition;
  11990. /**
  11991. * @hidden
  11992. * Updates the cached values of the camera
  11993. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11994. */
  11995. _updateCache(ignoreParentClass?: boolean): void;
  11996. /**
  11997. * @hidden
  11998. * Get current device position in babylon world
  11999. */
  12000. _computeDevicePosition(): void;
  12001. /**
  12002. * Updates the current device position and rotation in the babylon world
  12003. */
  12004. update(): void;
  12005. /**
  12006. * @hidden
  12007. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12008. * @returns an identity matrix
  12009. */
  12010. _getViewMatrix(): Matrix;
  12011. private _tmpMatrix;
  12012. /**
  12013. * This function is called by the two RIG cameras.
  12014. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12015. * @hidden
  12016. */
  12017. _getWebVRViewMatrix(): Matrix;
  12018. /** @hidden */
  12019. _getWebVRProjectionMatrix(): Matrix;
  12020. private _onGamepadConnectedObserver;
  12021. private _onGamepadDisconnectedObserver;
  12022. private _updateCacheWhenTrackingDisabledObserver;
  12023. /**
  12024. * Initializes the controllers and their meshes
  12025. */
  12026. initControllers(): void;
  12027. }
  12028. }
  12029. declare module "babylonjs/PostProcesses/postProcess" {
  12030. import { Nullable } from "babylonjs/types";
  12031. import { SmartArray } from "babylonjs/Misc/smartArray";
  12032. import { Observable } from "babylonjs/Misc/observable";
  12033. import { Color4, Vector2 } from "babylonjs/Maths/math";
  12034. import { Camera } from "babylonjs/Cameras/camera";
  12035. import { Effect } from "babylonjs/Materials/effect";
  12036. import { Animation } from "babylonjs/Animations/animation";
  12037. import "babylonjs/Shaders/postprocess.vertex";
  12038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12039. import { Engine } from "babylonjs/Engines/engine";
  12040. /**
  12041. * Size options for a post process
  12042. */
  12043. export type PostProcessOptions = {
  12044. width: number;
  12045. height: number;
  12046. };
  12047. /**
  12048. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12049. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12050. */
  12051. export class PostProcess {
  12052. /** Name of the PostProcess. */
  12053. name: string;
  12054. /**
  12055. * Width of the texture to apply the post process on
  12056. */
  12057. width: number;
  12058. /**
  12059. * Height of the texture to apply the post process on
  12060. */
  12061. height: number;
  12062. /**
  12063. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  12064. * @hidden
  12065. */
  12066. _outputTexture: Nullable<InternalTexture>;
  12067. /**
  12068. * Sampling mode used by the shader
  12069. * See https://doc.babylonjs.com/classes/3.1/texture
  12070. */
  12071. renderTargetSamplingMode: number;
  12072. /**
  12073. * Clear color to use when screen clearing
  12074. */
  12075. clearColor: Color4;
  12076. /**
  12077. * If the buffer needs to be cleared before applying the post process. (default: true)
  12078. * Should be set to false if shader will overwrite all previous pixels.
  12079. */
  12080. autoClear: boolean;
  12081. /**
  12082. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  12083. */
  12084. alphaMode: number;
  12085. /**
  12086. * Sets the setAlphaBlendConstants of the babylon engine
  12087. */
  12088. alphaConstants: Color4;
  12089. /**
  12090. * Animations to be used for the post processing
  12091. */
  12092. animations: Animation[];
  12093. /**
  12094. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  12095. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  12096. */
  12097. enablePixelPerfectMode: boolean;
  12098. /**
  12099. * Force the postprocess to be applied without taking in account viewport
  12100. */
  12101. forceFullscreenViewport: boolean;
  12102. /**
  12103. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  12104. *
  12105. * | Value | Type | Description |
  12106. * | ----- | ----------------------------------- | ----------- |
  12107. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  12108. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  12109. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  12110. *
  12111. */
  12112. scaleMode: number;
  12113. /**
  12114. * Force textures to be a power of two (default: false)
  12115. */
  12116. alwaysForcePOT: boolean;
  12117. private _samples;
  12118. /**
  12119. * Number of sample textures (default: 1)
  12120. */
  12121. samples: number;
  12122. /**
  12123. * Modify the scale of the post process to be the same as the viewport (default: false)
  12124. */
  12125. adaptScaleToCurrentViewport: boolean;
  12126. private _camera;
  12127. private _scene;
  12128. private _engine;
  12129. private _options;
  12130. private _reusable;
  12131. private _textureType;
  12132. /**
  12133. * Smart array of input and output textures for the post process.
  12134. * @hidden
  12135. */
  12136. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  12137. /**
  12138. * The index in _textures that corresponds to the output texture.
  12139. * @hidden
  12140. */
  12141. _currentRenderTextureInd: number;
  12142. private _effect;
  12143. private _samplers;
  12144. private _fragmentUrl;
  12145. private _vertexUrl;
  12146. private _parameters;
  12147. private _scaleRatio;
  12148. protected _indexParameters: any;
  12149. private _shareOutputWithPostProcess;
  12150. private _texelSize;
  12151. private _forcedOutputTexture;
  12152. /**
  12153. * Returns the fragment url or shader name used in the post process.
  12154. * @returns the fragment url or name in the shader store.
  12155. */
  12156. getEffectName(): string;
  12157. /**
  12158. * An event triggered when the postprocess is activated.
  12159. */
  12160. onActivateObservable: Observable<Camera>;
  12161. private _onActivateObserver;
  12162. /**
  12163. * A function that is added to the onActivateObservable
  12164. */
  12165. onActivate: Nullable<(camera: Camera) => void>;
  12166. /**
  12167. * An event triggered when the postprocess changes its size.
  12168. */
  12169. onSizeChangedObservable: Observable<PostProcess>;
  12170. private _onSizeChangedObserver;
  12171. /**
  12172. * A function that is added to the onSizeChangedObservable
  12173. */
  12174. onSizeChanged: (postProcess: PostProcess) => void;
  12175. /**
  12176. * An event triggered when the postprocess applies its effect.
  12177. */
  12178. onApplyObservable: Observable<Effect>;
  12179. private _onApplyObserver;
  12180. /**
  12181. * A function that is added to the onApplyObservable
  12182. */
  12183. onApply: (effect: Effect) => void;
  12184. /**
  12185. * An event triggered before rendering the postprocess
  12186. */
  12187. onBeforeRenderObservable: Observable<Effect>;
  12188. private _onBeforeRenderObserver;
  12189. /**
  12190. * A function that is added to the onBeforeRenderObservable
  12191. */
  12192. onBeforeRender: (effect: Effect) => void;
  12193. /**
  12194. * An event triggered after rendering the postprocess
  12195. */
  12196. onAfterRenderObservable: Observable<Effect>;
  12197. private _onAfterRenderObserver;
  12198. /**
  12199. * A function that is added to the onAfterRenderObservable
  12200. */
  12201. onAfterRender: (efect: Effect) => void;
  12202. /**
  12203. * 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
  12204. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12205. */
  12206. inputTexture: InternalTexture;
  12207. /**
  12208. * Gets the camera which post process is applied to.
  12209. * @returns The camera the post process is applied to.
  12210. */
  12211. getCamera(): Camera;
  12212. /**
  12213. * Gets the texel size of the postprocess.
  12214. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12215. */
  12216. readonly texelSize: Vector2;
  12217. /**
  12218. * Creates a new instance PostProcess
  12219. * @param name The name of the PostProcess.
  12220. * @param fragmentUrl The url of the fragment shader to be used.
  12221. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12222. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12223. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12224. * @param camera The camera to apply the render pass to.
  12225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12226. * @param engine The engine which the post process will be applied. (default: current engine)
  12227. * @param reusable If the post process can be reused on the same frame. (default: false)
  12228. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12229. * @param textureType Type of textures used when performing the post process. (default: 0)
  12230. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12231. * @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
  12232. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12233. */
  12234. constructor(
  12235. /** Name of the PostProcess. */
  12236. 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);
  12237. /**
  12238. * Gets the engine which this post process belongs to.
  12239. * @returns The engine the post process was enabled with.
  12240. */
  12241. getEngine(): Engine;
  12242. /**
  12243. * The effect that is created when initializing the post process.
  12244. * @returns The created effect corrisponding the the postprocess.
  12245. */
  12246. getEffect(): Effect;
  12247. /**
  12248. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12249. * @param postProcess The post process to share the output with.
  12250. * @returns This post process.
  12251. */
  12252. shareOutputWith(postProcess: PostProcess): PostProcess;
  12253. /**
  12254. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12255. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12256. */
  12257. useOwnOutput(): void;
  12258. /**
  12259. * Updates the effect with the current post process compile time values and recompiles the shader.
  12260. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12261. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12262. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12263. * @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
  12264. * @param onCompiled Called when the shader has been compiled.
  12265. * @param onError Called if there is an error when compiling a shader.
  12266. */
  12267. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12268. /**
  12269. * The post process is reusable if it can be used multiple times within one frame.
  12270. * @returns If the post process is reusable
  12271. */
  12272. isReusable(): boolean;
  12273. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12274. markTextureDirty(): void;
  12275. /**
  12276. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12277. * 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.
  12278. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12279. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12280. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12281. * @returns The target texture that was bound to be written to.
  12282. */
  12283. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12284. /**
  12285. * If the post process is supported.
  12286. */
  12287. readonly isSupported: boolean;
  12288. /**
  12289. * The aspect ratio of the output texture.
  12290. */
  12291. readonly aspectRatio: number;
  12292. /**
  12293. * Get a value indicating if the post-process is ready to be used
  12294. * @returns true if the post-process is ready (shader is compiled)
  12295. */
  12296. isReady(): boolean;
  12297. /**
  12298. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12299. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12300. */
  12301. apply(): Nullable<Effect>;
  12302. private _disposeTextures;
  12303. /**
  12304. * Disposes the post process.
  12305. * @param camera The camera to dispose the post process on.
  12306. */
  12307. dispose(camera?: Camera): void;
  12308. }
  12309. }
  12310. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  12311. /** @hidden */
  12312. export var kernelBlurVaryingDeclaration: {
  12313. name: string;
  12314. shader: string;
  12315. };
  12316. }
  12317. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  12318. /** @hidden */
  12319. export var kernelBlurFragment: {
  12320. name: string;
  12321. shader: string;
  12322. };
  12323. }
  12324. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  12325. /** @hidden */
  12326. export var kernelBlurFragment2: {
  12327. name: string;
  12328. shader: string;
  12329. };
  12330. }
  12331. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  12332. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12333. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  12334. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  12335. /** @hidden */
  12336. export var kernelBlurPixelShader: {
  12337. name: string;
  12338. shader: string;
  12339. };
  12340. }
  12341. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  12342. /** @hidden */
  12343. export var kernelBlurVertex: {
  12344. name: string;
  12345. shader: string;
  12346. };
  12347. }
  12348. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  12349. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12350. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  12351. /** @hidden */
  12352. export var kernelBlurVertexShader: {
  12353. name: string;
  12354. shader: string;
  12355. };
  12356. }
  12357. declare module "babylonjs/PostProcesses/blurPostProcess" {
  12358. import { Vector2 } from "babylonjs/Maths/math";
  12359. import { Nullable } from "babylonjs/types";
  12360. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  12361. import { Camera } from "babylonjs/Cameras/camera";
  12362. import { Effect } from "babylonjs/Materials/effect";
  12363. import { Engine } from "babylonjs/Engines/engine";
  12364. import "babylonjs/Shaders/kernelBlur.fragment";
  12365. import "babylonjs/Shaders/kernelBlur.vertex";
  12366. /**
  12367. * The Blur Post Process which blurs an image based on a kernel and direction.
  12368. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12369. */
  12370. export class BlurPostProcess extends PostProcess {
  12371. /** The direction in which to blur the image. */
  12372. direction: Vector2;
  12373. private blockCompilation;
  12374. protected _kernel: number;
  12375. protected _idealKernel: number;
  12376. protected _packedFloat: boolean;
  12377. private _staticDefines;
  12378. /**
  12379. * Sets the length in pixels of the blur sample region
  12380. */
  12381. /**
  12382. * Gets the length in pixels of the blur sample region
  12383. */
  12384. kernel: number;
  12385. /**
  12386. * Sets wether or not the blur needs to unpack/repack floats
  12387. */
  12388. /**
  12389. * Gets wether or not the blur is unpacking/repacking floats
  12390. */
  12391. packedFloat: boolean;
  12392. /**
  12393. * Creates a new instance BlurPostProcess
  12394. * @param name The name of the effect.
  12395. * @param direction The direction in which to blur the image.
  12396. * @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.
  12397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12398. * @param camera The camera to apply the render pass to.
  12399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12400. * @param engine The engine which the post process will be applied. (default: current engine)
  12401. * @param reusable If the post process can be reused on the same frame. (default: false)
  12402. * @param textureType Type of textures used when performing the post process. (default: 0)
  12403. * @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)
  12404. */
  12405. constructor(name: string,
  12406. /** The direction in which to blur the image. */
  12407. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12408. /**
  12409. * Updates the effect with the current post process compile time values and recompiles the shader.
  12410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12413. * @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
  12414. * @param onCompiled Called when the shader has been compiled.
  12415. * @param onError Called if there is an error when compiling a shader.
  12416. */
  12417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12418. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12419. /**
  12420. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12421. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12422. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12423. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12424. * The gaps between physical kernels are compensated for in the weighting of the samples
  12425. * @param idealKernel Ideal blur kernel.
  12426. * @return Nearest best kernel.
  12427. */
  12428. protected _nearestBestKernel(idealKernel: number): number;
  12429. /**
  12430. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12431. * @param x The point on the Gaussian distribution to sample.
  12432. * @return the value of the Gaussian function at x.
  12433. */
  12434. protected _gaussianWeight(x: number): number;
  12435. /**
  12436. * Generates a string that can be used as a floating point number in GLSL.
  12437. * @param x Value to print.
  12438. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12439. * @return GLSL float string.
  12440. */
  12441. protected _glslFloat(x: number, decimalFigures?: number): string;
  12442. }
  12443. }
  12444. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  12445. import { Scene } from "babylonjs/scene";
  12446. import { Plane } from "babylonjs/Maths/math";
  12447. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12448. /**
  12449. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12450. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12451. * You can then easily use it as a reflectionTexture on a flat surface.
  12452. * In case the surface is not a plane, please consider relying on reflection probes.
  12453. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12454. */
  12455. export class MirrorTexture extends RenderTargetTexture {
  12456. private scene;
  12457. /**
  12458. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12459. * 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.
  12460. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12461. */
  12462. mirrorPlane: Plane;
  12463. /**
  12464. * Define the blur ratio used to blur the reflection if needed.
  12465. */
  12466. blurRatio: number;
  12467. /**
  12468. * Define the adaptive blur kernel used to blur the reflection if needed.
  12469. * This will autocompute the closest best match for the `blurKernel`
  12470. */
  12471. adaptiveBlurKernel: number;
  12472. /**
  12473. * Define the blur kernel used to blur the reflection if needed.
  12474. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12475. */
  12476. blurKernel: number;
  12477. /**
  12478. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12479. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12480. */
  12481. blurKernelX: number;
  12482. /**
  12483. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12485. */
  12486. blurKernelY: number;
  12487. private _autoComputeBlurKernel;
  12488. protected _onRatioRescale(): void;
  12489. private _updateGammaSpace;
  12490. private _imageProcessingConfigChangeObserver;
  12491. private _transformMatrix;
  12492. private _mirrorMatrix;
  12493. private _savedViewMatrix;
  12494. private _blurX;
  12495. private _blurY;
  12496. private _adaptiveBlurKernel;
  12497. private _blurKernelX;
  12498. private _blurKernelY;
  12499. private _blurRatio;
  12500. /**
  12501. * Instantiates a Mirror Texture.
  12502. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12503. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12504. * You can then easily use it as a reflectionTexture on a flat surface.
  12505. * In case the surface is not a plane, please consider relying on reflection probes.
  12506. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12507. * @param name
  12508. * @param size
  12509. * @param scene
  12510. * @param generateMipMaps
  12511. * @param type
  12512. * @param samplingMode
  12513. * @param generateDepthBuffer
  12514. */
  12515. constructor(name: string, size: number | {
  12516. width: number;
  12517. height: number;
  12518. } | {
  12519. ratio: number;
  12520. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12521. private _preparePostProcesses;
  12522. /**
  12523. * Clone the mirror texture.
  12524. * @returns the cloned texture
  12525. */
  12526. clone(): MirrorTexture;
  12527. /**
  12528. * Serialize the texture to a JSON representation you could use in Parse later on
  12529. * @returns the serialized JSON representation
  12530. */
  12531. serialize(): any;
  12532. /**
  12533. * Dispose the texture and release its associated resources.
  12534. */
  12535. dispose(): void;
  12536. }
  12537. }
  12538. declare module "babylonjs/Materials/Textures/texture" {
  12539. import { Observable } from "babylonjs/Misc/observable";
  12540. import { Nullable } from "babylonjs/types";
  12541. import { Scene } from "babylonjs/scene";
  12542. import { Matrix } from "babylonjs/Maths/math";
  12543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12544. /**
  12545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12547. */
  12548. export class Texture extends BaseTexture {
  12549. /** @hidden */
  12550. static _AnimationParser: (jsonAnimation: any) => import("babylonjs/Animations/animation").Animation;
  12551. /** @hidden */
  12552. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  12553. /** @hidden */
  12554. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  12555. /** @hidden */
  12556. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  12557. /** nearest is mag = nearest and min = nearest and mip = linear */
  12558. static readonly NEAREST_SAMPLINGMODE: number;
  12559. /** nearest is mag = nearest and min = nearest and mip = linear */
  12560. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12562. static readonly BILINEAR_SAMPLINGMODE: number;
  12563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12564. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12565. /** Trilinear is mag = linear and min = linear and mip = linear */
  12566. static readonly TRILINEAR_SAMPLINGMODE: number;
  12567. /** Trilinear is mag = linear and min = linear and mip = linear */
  12568. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12569. /** mag = nearest and min = nearest and mip = nearest */
  12570. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12571. /** mag = nearest and min = linear and mip = nearest */
  12572. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12573. /** mag = nearest and min = linear and mip = linear */
  12574. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12575. /** mag = nearest and min = linear and mip = none */
  12576. static readonly NEAREST_LINEAR: number;
  12577. /** mag = nearest and min = nearest and mip = none */
  12578. static readonly NEAREST_NEAREST: number;
  12579. /** mag = linear and min = nearest and mip = nearest */
  12580. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12581. /** mag = linear and min = nearest and mip = linear */
  12582. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12583. /** mag = linear and min = linear and mip = none */
  12584. static readonly LINEAR_LINEAR: number;
  12585. /** mag = linear and min = nearest and mip = none */
  12586. static readonly LINEAR_NEAREST: number;
  12587. /** Explicit coordinates mode */
  12588. static readonly EXPLICIT_MODE: number;
  12589. /** Spherical coordinates mode */
  12590. static readonly SPHERICAL_MODE: number;
  12591. /** Planar coordinates mode */
  12592. static readonly PLANAR_MODE: number;
  12593. /** Cubic coordinates mode */
  12594. static readonly CUBIC_MODE: number;
  12595. /** Projection coordinates mode */
  12596. static readonly PROJECTION_MODE: number;
  12597. /** Inverse Cubic coordinates mode */
  12598. static readonly SKYBOX_MODE: number;
  12599. /** Inverse Cubic coordinates mode */
  12600. static readonly INVCUBIC_MODE: number;
  12601. /** Equirectangular coordinates mode */
  12602. static readonly EQUIRECTANGULAR_MODE: number;
  12603. /** Equirectangular Fixed coordinates mode */
  12604. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12605. /** Equirectangular Fixed Mirrored coordinates mode */
  12606. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12607. /** Texture is not repeating outside of 0..1 UVs */
  12608. static readonly CLAMP_ADDRESSMODE: number;
  12609. /** Texture is repeating outside of 0..1 UVs */
  12610. static readonly WRAP_ADDRESSMODE: number;
  12611. /** Texture is repeating and mirrored */
  12612. static readonly MIRROR_ADDRESSMODE: number;
  12613. /**
  12614. * 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
  12615. */
  12616. static UseSerializedUrlIfAny: boolean;
  12617. /**
  12618. * Define the url of the texture.
  12619. */
  12620. url: Nullable<string>;
  12621. /**
  12622. * Define an offset on the texture to offset the u coordinates of the UVs
  12623. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12624. */
  12625. uOffset: number;
  12626. /**
  12627. * Define an offset on the texture to offset the v coordinates of the UVs
  12628. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12629. */
  12630. vOffset: number;
  12631. /**
  12632. * Define an offset on the texture to scale the u coordinates of the UVs
  12633. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12634. */
  12635. uScale: number;
  12636. /**
  12637. * Define an offset on the texture to scale the v coordinates of the UVs
  12638. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12639. */
  12640. vScale: number;
  12641. /**
  12642. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12643. * @see http://doc.babylonjs.com/how_to/more_materials
  12644. */
  12645. uAng: number;
  12646. /**
  12647. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12648. * @see http://doc.babylonjs.com/how_to/more_materials
  12649. */
  12650. vAng: number;
  12651. /**
  12652. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12653. * @see http://doc.babylonjs.com/how_to/more_materials
  12654. */
  12655. wAng: number;
  12656. /**
  12657. * Defines the center of rotation (U)
  12658. */
  12659. uRotationCenter: number;
  12660. /**
  12661. * Defines the center of rotation (V)
  12662. */
  12663. vRotationCenter: number;
  12664. /**
  12665. * Defines the center of rotation (W)
  12666. */
  12667. wRotationCenter: number;
  12668. /**
  12669. * Are mip maps generated for this texture or not.
  12670. */
  12671. readonly noMipmap: boolean;
  12672. private _noMipmap;
  12673. /** @hidden */
  12674. _invertY: boolean;
  12675. private _rowGenerationMatrix;
  12676. private _cachedTextureMatrix;
  12677. private _projectionModeMatrix;
  12678. private _t0;
  12679. private _t1;
  12680. private _t2;
  12681. private _cachedUOffset;
  12682. private _cachedVOffset;
  12683. private _cachedUScale;
  12684. private _cachedVScale;
  12685. private _cachedUAng;
  12686. private _cachedVAng;
  12687. private _cachedWAng;
  12688. private _cachedProjectionMatrixId;
  12689. private _cachedCoordinatesMode;
  12690. /** @hidden */
  12691. protected _initialSamplingMode: number;
  12692. /** @hidden */
  12693. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12694. private _deleteBuffer;
  12695. protected _format: Nullable<number>;
  12696. private _delayedOnLoad;
  12697. private _delayedOnError;
  12698. /**
  12699. * Observable triggered once the texture has been loaded.
  12700. */
  12701. onLoadObservable: Observable<Texture>;
  12702. protected _isBlocking: boolean;
  12703. /**
  12704. * Is the texture preventing material to render while loading.
  12705. * If false, a default texture will be used instead of the loading one during the preparation step.
  12706. */
  12707. isBlocking: boolean;
  12708. /**
  12709. * Get the current sampling mode associated with the texture.
  12710. */
  12711. readonly samplingMode: number;
  12712. /**
  12713. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12714. */
  12715. readonly invertY: boolean;
  12716. /**
  12717. * Instantiates a new texture.
  12718. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12719. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12720. * @param url define the url of the picture to load as a texture
  12721. * @param scene define the scene the texture will belong to
  12722. * @param noMipmap define if the texture will require mip maps or not
  12723. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12724. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12725. * @param onLoad define a callback triggered when the texture has been loaded
  12726. * @param onError define a callback triggered when an error occurred during the loading session
  12727. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12728. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12729. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12730. */
  12731. 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);
  12732. /**
  12733. * Update the url (and optional buffer) of this texture if url was null during construction.
  12734. * @param url the url of the texture
  12735. * @param buffer the buffer of the texture (defaults to null)
  12736. * @param onLoad callback called when the texture is loaded (defaults to null)
  12737. */
  12738. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12739. /**
  12740. * Finish the loading sequence of a texture flagged as delayed load.
  12741. * @hidden
  12742. */
  12743. delayLoad(): void;
  12744. private _prepareRowForTextureGeneration;
  12745. /**
  12746. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12747. * @returns the transform matrix of the texture.
  12748. */
  12749. getTextureMatrix(): Matrix;
  12750. /**
  12751. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12752. * @returns The reflection texture transform
  12753. */
  12754. getReflectionTextureMatrix(): Matrix;
  12755. /**
  12756. * Clones the texture.
  12757. * @returns the cloned texture
  12758. */
  12759. clone(): Texture;
  12760. /**
  12761. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12762. * @returns The JSON representation of the texture
  12763. */
  12764. serialize(): any;
  12765. /**
  12766. * Get the current class name of the texture useful for serialization or dynamic coding.
  12767. * @returns "Texture"
  12768. */
  12769. getClassName(): string;
  12770. /**
  12771. * Dispose the texture and release its associated resources.
  12772. */
  12773. dispose(): void;
  12774. /**
  12775. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12776. * @param parsedTexture Define the JSON representation of the texture
  12777. * @param scene Define the scene the parsed texture should be instantiated in
  12778. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12779. * @returns The parsed texture if successful
  12780. */
  12781. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12782. /**
  12783. * Creates a texture from its base 64 representation.
  12784. * @param data Define the base64 payload without the data: prefix
  12785. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12786. * @param scene Define the scene the texture should belong to
  12787. * @param noMipmap Forces the texture to not create mip map information if true
  12788. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12789. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12790. * @param onLoad define a callback triggered when the texture has been loaded
  12791. * @param onError define a callback triggered when an error occurred during the loading session
  12792. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12793. * @returns the created texture
  12794. */
  12795. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12796. /**
  12797. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12798. * @param data Define the base64 payload without the data: prefix
  12799. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12800. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12801. * @param scene Define the scene the texture should belong to
  12802. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12803. * @param noMipmap Forces the texture to not create mip map information if true
  12804. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12805. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12806. * @param onLoad define a callback triggered when the texture has been loaded
  12807. * @param onError define a callback triggered when an error occurred during the loading session
  12808. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12809. * @returns the created texture
  12810. */
  12811. 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;
  12812. }
  12813. }
  12814. declare module "babylonjs/PostProcesses/postProcessManager" {
  12815. import { Nullable } from "babylonjs/types";
  12816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12818. import { Scene } from "babylonjs/scene";
  12819. /**
  12820. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12821. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12822. */
  12823. export class PostProcessManager {
  12824. private _scene;
  12825. private _indexBuffer;
  12826. private _vertexBuffers;
  12827. /**
  12828. * Creates a new instance PostProcess
  12829. * @param scene The scene that the post process is associated with.
  12830. */
  12831. constructor(scene: Scene);
  12832. private _prepareBuffers;
  12833. private _buildIndexBuffer;
  12834. /**
  12835. * Rebuilds the vertex buffers of the manager.
  12836. * @hidden
  12837. */
  12838. _rebuild(): void;
  12839. /**
  12840. * Prepares a frame to be run through a post process.
  12841. * @param sourceTexture The input texture to the post procesess. (default: null)
  12842. * @param postProcesses An array of post processes to be run. (default: null)
  12843. * @returns True if the post processes were able to be run.
  12844. * @hidden
  12845. */
  12846. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12847. /**
  12848. * Manually render a set of post processes to a texture.
  12849. * @param postProcesses An array of post processes to be run.
  12850. * @param targetTexture The target texture to render to.
  12851. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12852. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12853. * @param lodLevel defines which lod of the texture to render to
  12854. */
  12855. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12856. /**
  12857. * Finalize the result of the output of the postprocesses.
  12858. * @param doNotPresent If true the result will not be displayed to the screen.
  12859. * @param targetTexture The target texture to render to.
  12860. * @param faceIndex The index of the face to bind the target texture to.
  12861. * @param postProcesses The array of post processes to render.
  12862. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12863. * @hidden
  12864. */
  12865. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12866. /**
  12867. * Disposes of the post process manager.
  12868. */
  12869. dispose(): void;
  12870. }
  12871. }
  12872. declare module "babylonjs/sceneComponent" {
  12873. import { Scene } from "babylonjs/scene";
  12874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12876. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  12877. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  12878. import { Nullable } from "babylonjs/types";
  12879. import { Camera } from "babylonjs/Cameras/camera";
  12880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12881. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12882. import { AbstractScene } from "babylonjs/abstractScene";
  12883. /**
  12884. * Groups all the scene component constants in one place to ease maintenance.
  12885. * @hidden
  12886. */
  12887. export class SceneComponentConstants {
  12888. static readonly NAME_EFFECTLAYER: string;
  12889. static readonly NAME_LAYER: string;
  12890. static readonly NAME_LENSFLARESYSTEM: string;
  12891. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12892. static readonly NAME_PARTICLESYSTEM: string;
  12893. static readonly NAME_GAMEPAD: string;
  12894. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12895. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12896. static readonly NAME_DEPTHRENDERER: string;
  12897. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12898. static readonly NAME_SPRITE: string;
  12899. static readonly NAME_OUTLINERENDERER: string;
  12900. static readonly NAME_PROCEDURALTEXTURE: string;
  12901. static readonly NAME_SHADOWGENERATOR: string;
  12902. static readonly NAME_OCTREE: string;
  12903. static readonly NAME_PHYSICSENGINE: string;
  12904. static readonly NAME_AUDIO: string;
  12905. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12906. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12907. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12908. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12909. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12910. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12911. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12912. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12913. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12914. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12915. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12916. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12917. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12918. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12919. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12920. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12921. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12922. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12923. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12924. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12925. static readonly STEP_AFTERRENDER_AUDIO: number;
  12926. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12927. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12928. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12929. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12930. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12931. static readonly STEP_POINTERMOVE_SPRITE: number;
  12932. static readonly STEP_POINTERDOWN_SPRITE: number;
  12933. static readonly STEP_POINTERUP_SPRITE: number;
  12934. }
  12935. /**
  12936. * This represents a scene component.
  12937. *
  12938. * This is used to decouple the dependency the scene is having on the different workloads like
  12939. * layers, post processes...
  12940. */
  12941. export interface ISceneComponent {
  12942. /**
  12943. * The name of the component. Each component must have a unique name.
  12944. */
  12945. name: string;
  12946. /**
  12947. * The scene the component belongs to.
  12948. */
  12949. scene: Scene;
  12950. /**
  12951. * Register the component to one instance of a scene.
  12952. */
  12953. register(): void;
  12954. /**
  12955. * Rebuilds the elements related to this component in case of
  12956. * context lost for instance.
  12957. */
  12958. rebuild(): void;
  12959. /**
  12960. * Disposes the component and the associated ressources.
  12961. */
  12962. dispose(): void;
  12963. }
  12964. /**
  12965. * This represents a SERIALIZABLE scene component.
  12966. *
  12967. * This extends Scene Component to add Serialization methods on top.
  12968. */
  12969. export interface ISceneSerializableComponent extends ISceneComponent {
  12970. /**
  12971. * Adds all the element from the container to the scene
  12972. * @param container the container holding the elements
  12973. */
  12974. addFromContainer(container: AbstractScene): void;
  12975. /**
  12976. * Removes all the elements in the container from the scene
  12977. * @param container contains the elements to remove
  12978. */
  12979. removeFromContainer(container: AbstractScene): void;
  12980. /**
  12981. * Serializes the component data to the specified json object
  12982. * @param serializationObject The object to serialize to
  12983. */
  12984. serialize(serializationObject: any): void;
  12985. }
  12986. /**
  12987. * Strong typing of a Mesh related stage step action
  12988. */
  12989. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12990. /**
  12991. * Strong typing of a Evaluate Sub Mesh related stage step action
  12992. */
  12993. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12994. /**
  12995. * Strong typing of a Active Mesh related stage step action
  12996. */
  12997. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12998. /**
  12999. * Strong typing of a Camera related stage step action
  13000. */
  13001. export type CameraStageAction = (camera: Camera) => void;
  13002. /**
  13003. * Strong typing of a Render Target related stage step action
  13004. */
  13005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  13006. /**
  13007. * Strong typing of a RenderingGroup related stage step action
  13008. */
  13009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  13010. /**
  13011. * Strong typing of a Mesh Render related stage step action
  13012. */
  13013. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  13014. /**
  13015. * Strong typing of a simple stage step action
  13016. */
  13017. export type SimpleStageAction = () => void;
  13018. /**
  13019. * Strong typing of a render target action.
  13020. */
  13021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  13022. /**
  13023. * Strong typing of a pointer move action.
  13024. */
  13025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  13026. /**
  13027. * Strong typing of a pointer up/down action.
  13028. */
  13029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  13030. /**
  13031. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  13032. * @hidden
  13033. */
  13034. export class Stage<T extends Function> extends Array<{
  13035. index: number;
  13036. component: ISceneComponent;
  13037. action: T;
  13038. }> {
  13039. /**
  13040. * Hide ctor from the rest of the world.
  13041. * @param items The items to add.
  13042. */
  13043. private constructor();
  13044. /**
  13045. * Creates a new Stage.
  13046. * @returns A new instance of a Stage
  13047. */
  13048. static Create<T extends Function>(): Stage<T>;
  13049. /**
  13050. * Registers a step in an ordered way in the targeted stage.
  13051. * @param index Defines the position to register the step in
  13052. * @param component Defines the component attached to the step
  13053. * @param action Defines the action to launch during the step
  13054. */
  13055. registerStep(index: number, component: ISceneComponent, action: T): void;
  13056. /**
  13057. * Clears all the steps from the stage.
  13058. */
  13059. clear(): void;
  13060. }
  13061. }
  13062. declare module "babylonjs/Sprites/spriteSceneComponent" {
  13063. import { Nullable } from "babylonjs/types";
  13064. import { Observable } from "babylonjs/Misc/observable";
  13065. import { Scene } from "babylonjs/scene";
  13066. import { Sprite } from "babylonjs/Sprites/sprite";
  13067. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  13068. import { Ray } from "babylonjs/Culling/ray";
  13069. import { Camera } from "babylonjs/Cameras/camera";
  13070. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13071. import { ISceneComponent } from "babylonjs/sceneComponent";
  13072. module "babylonjs/scene" {
  13073. interface Scene {
  13074. /** @hidden */
  13075. _pointerOverSprite: Nullable<Sprite>;
  13076. /** @hidden */
  13077. _pickedDownSprite: Nullable<Sprite>;
  13078. /** @hidden */
  13079. _tempSpritePickingRay: Nullable<Ray>;
  13080. /**
  13081. * All of the sprite managers added to this scene
  13082. * @see http://doc.babylonjs.com/babylon101/sprites
  13083. */
  13084. spriteManagers: Array<ISpriteManager>;
  13085. /**
  13086. * An event triggered when sprites rendering is about to start
  13087. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13088. */
  13089. onBeforeSpritesRenderingObservable: Observable<Scene>;
  13090. /**
  13091. * An event triggered when sprites rendering is done
  13092. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13093. */
  13094. onAfterSpritesRenderingObservable: Observable<Scene>;
  13095. /** @hidden */
  13096. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13097. /** Launch a ray to try to pick a sprite in the scene
  13098. * @param x position on screen
  13099. * @param y position on screen
  13100. * @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
  13101. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13102. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  13103. * @returns a PickingInfo
  13104. */
  13105. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13106. /** Use the given ray to pick a sprite in the scene
  13107. * @param ray The ray (in world space) to use to pick meshes
  13108. * @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
  13109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13110. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  13111. * @returns a PickingInfo
  13112. */
  13113. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13114. /**
  13115. * Force the sprite under the pointer
  13116. * @param sprite defines the sprite to use
  13117. */
  13118. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  13119. /**
  13120. * Gets the sprite under the pointer
  13121. * @returns a Sprite or null if no sprite is under the pointer
  13122. */
  13123. getPointerOverSprite(): Nullable<Sprite>;
  13124. }
  13125. }
  13126. /**
  13127. * Defines the sprite scene component responsible to manage sprites
  13128. * in a given scene.
  13129. */
  13130. export class SpriteSceneComponent implements ISceneComponent {
  13131. /**
  13132. * The component name helpfull to identify the component in the list of scene components.
  13133. */
  13134. readonly name: string;
  13135. /**
  13136. * The scene the component belongs to.
  13137. */
  13138. scene: Scene;
  13139. /** @hidden */
  13140. private _spritePredicate;
  13141. /**
  13142. * Creates a new instance of the component for the given scene
  13143. * @param scene Defines the scene to register the component in
  13144. */
  13145. constructor(scene: Scene);
  13146. /**
  13147. * Registers the component in a given scene
  13148. */
  13149. register(): void;
  13150. /**
  13151. * Rebuilds the elements related to this component in case of
  13152. * context lost for instance.
  13153. */
  13154. rebuild(): void;
  13155. /**
  13156. * Disposes the component and the associated ressources.
  13157. */
  13158. dispose(): void;
  13159. private _pickSpriteButKeepRay;
  13160. private _pointerMove;
  13161. private _pointerDown;
  13162. private _pointerUp;
  13163. }
  13164. }
  13165. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  13166. /** @hidden */
  13167. export var fogFragmentDeclaration: {
  13168. name: string;
  13169. shader: string;
  13170. };
  13171. }
  13172. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  13173. /** @hidden */
  13174. export var fogFragment: {
  13175. name: string;
  13176. shader: string;
  13177. };
  13178. }
  13179. declare module "babylonjs/Shaders/sprites.fragment" {
  13180. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  13181. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  13182. /** @hidden */
  13183. export var spritesPixelShader: {
  13184. name: string;
  13185. shader: string;
  13186. };
  13187. }
  13188. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  13189. /** @hidden */
  13190. export var fogVertexDeclaration: {
  13191. name: string;
  13192. shader: string;
  13193. };
  13194. }
  13195. declare module "babylonjs/Shaders/sprites.vertex" {
  13196. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  13197. /** @hidden */
  13198. export var spritesVertexShader: {
  13199. name: string;
  13200. shader: string;
  13201. };
  13202. }
  13203. declare module "babylonjs/Sprites/spriteManager" {
  13204. import { IDisposable, Scene } from "babylonjs/scene";
  13205. import { Nullable } from "babylonjs/types";
  13206. import { Observable } from "babylonjs/Misc/observable";
  13207. import { Sprite } from "babylonjs/Sprites/sprite";
  13208. import { Ray } from "babylonjs/Culling/ray";
  13209. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13210. import { Camera } from "babylonjs/Cameras/camera";
  13211. import { Texture } from "babylonjs/Materials/Textures/texture";
  13212. import "babylonjs/Shaders/sprites.fragment";
  13213. import "babylonjs/Shaders/sprites.vertex";
  13214. /**
  13215. * Defines the minimum interface to fullfil in order to be a sprite manager.
  13216. */
  13217. export interface ISpriteManager extends IDisposable {
  13218. /**
  13219. * Restricts the camera to viewing objects with the same layerMask.
  13220. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  13221. */
  13222. layerMask: number;
  13223. /**
  13224. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  13225. */
  13226. isPickable: boolean;
  13227. /**
  13228. * Specifies the rendering group id for this mesh (0 by default)
  13229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  13230. */
  13231. renderingGroupId: number;
  13232. /**
  13233. * Defines the list of sprites managed by the manager.
  13234. */
  13235. sprites: Array<Sprite>;
  13236. /**
  13237. * Tests the intersection of a sprite with a specific ray.
  13238. * @param ray The ray we are sending to test the collision
  13239. * @param camera The camera space we are sending rays in
  13240. * @param predicate A predicate allowing excluding sprites from the list of object to test
  13241. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  13242. * @returns picking info or null.
  13243. */
  13244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13245. /**
  13246. * Renders the list of sprites on screen.
  13247. */
  13248. render(): void;
  13249. }
  13250. /**
  13251. * Class used to manage multiple sprites on the same spritesheet
  13252. * @see http://doc.babylonjs.com/babylon101/sprites
  13253. */
  13254. export class SpriteManager implements ISpriteManager {
  13255. /** defines the manager's name */
  13256. name: string;
  13257. /** Gets the list of sprites */
  13258. sprites: Sprite[];
  13259. /** Gets or sets the rendering group id (0 by default) */
  13260. renderingGroupId: number;
  13261. /** Gets or sets camera layer mask */
  13262. layerMask: number;
  13263. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13264. fogEnabled: boolean;
  13265. /** Gets or sets a boolean indicating if the sprites are pickable */
  13266. isPickable: boolean;
  13267. /** Defines the default width of a cell in the spritesheet */
  13268. cellWidth: number;
  13269. /** Defines the default height of a cell in the spritesheet */
  13270. cellHeight: number;
  13271. /**
  13272. * An event triggered when the manager is disposed.
  13273. */
  13274. onDisposeObservable: Observable<SpriteManager>;
  13275. private _onDisposeObserver;
  13276. /**
  13277. * Callback called when the manager is disposed
  13278. */
  13279. onDispose: () => void;
  13280. private _capacity;
  13281. private _spriteTexture;
  13282. private _epsilon;
  13283. private _scene;
  13284. private _vertexData;
  13285. private _buffer;
  13286. private _vertexBuffers;
  13287. private _indexBuffer;
  13288. private _effectBase;
  13289. private _effectFog;
  13290. /**
  13291. * Gets or sets the spritesheet texture
  13292. */
  13293. texture: Texture;
  13294. /**
  13295. * Creates a new sprite manager
  13296. * @param name defines the manager's name
  13297. * @param imgUrl defines the sprite sheet url
  13298. * @param capacity defines the maximum allowed number of sprites
  13299. * @param cellSize defines the size of a sprite cell
  13300. * @param scene defines the hosting scene
  13301. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13302. * @param samplingMode defines the smapling mode to use with spritesheet
  13303. */
  13304. constructor(
  13305. /** defines the manager's name */
  13306. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13307. private _appendSpriteVertex;
  13308. /**
  13309. * Intersects the sprites with a ray
  13310. * @param ray defines the ray to intersect with
  13311. * @param camera defines the current active camera
  13312. * @param predicate defines a predicate used to select candidate sprites
  13313. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13314. * @returns null if no hit or a PickingInfo
  13315. */
  13316. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13317. /**
  13318. * Render all child sprites
  13319. */
  13320. render(): void;
  13321. /**
  13322. * Release associated resources
  13323. */
  13324. dispose(): void;
  13325. }
  13326. }
  13327. declare module "babylonjs/Layers/layerSceneComponent" {
  13328. import { Scene } from "babylonjs/scene";
  13329. import { ISceneComponent } from "babylonjs/sceneComponent";
  13330. import { Layer } from "babylonjs/Layers/layer";
  13331. module "babylonjs/abstractScene" {
  13332. interface AbstractScene {
  13333. /**
  13334. * The list of layers (background and foreground) of the scene
  13335. */
  13336. layers: Array<Layer>;
  13337. }
  13338. }
  13339. /**
  13340. * Defines the layer scene component responsible to manage any layers
  13341. * in a given scene.
  13342. */
  13343. export class LayerSceneComponent implements ISceneComponent {
  13344. /**
  13345. * The component name helpfull to identify the component in the list of scene components.
  13346. */
  13347. readonly name: string;
  13348. /**
  13349. * The scene the component belongs to.
  13350. */
  13351. scene: Scene;
  13352. private _engine;
  13353. /**
  13354. * Creates a new instance of the component for the given scene
  13355. * @param scene Defines the scene to register the component in
  13356. */
  13357. constructor(scene: Scene);
  13358. /**
  13359. * Registers the component in a given scene
  13360. */
  13361. register(): void;
  13362. /**
  13363. * Rebuilds the elements related to this component in case of
  13364. * context lost for instance.
  13365. */
  13366. rebuild(): void;
  13367. /**
  13368. * Disposes the component and the associated ressources.
  13369. */
  13370. dispose(): void;
  13371. private _draw;
  13372. private _drawCameraPredicate;
  13373. private _drawCameraBackground;
  13374. private _drawCameraForeground;
  13375. private _drawRenderTargetPredicate;
  13376. private _drawRenderTargetBackground;
  13377. private _drawRenderTargetForeground;
  13378. }
  13379. }
  13380. declare module "babylonjs/Shaders/layer.fragment" {
  13381. /** @hidden */
  13382. export var layerPixelShader: {
  13383. name: string;
  13384. shader: string;
  13385. };
  13386. }
  13387. declare module "babylonjs/Shaders/layer.vertex" {
  13388. /** @hidden */
  13389. export var layerVertexShader: {
  13390. name: string;
  13391. shader: string;
  13392. };
  13393. }
  13394. declare module "babylonjs/Layers/layer" {
  13395. import { Observable } from "babylonjs/Misc/observable";
  13396. import { Nullable } from "babylonjs/types";
  13397. import { Scene } from "babylonjs/scene";
  13398. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13399. import { Texture } from "babylonjs/Materials/Textures/texture";
  13400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13401. import "babylonjs/Shaders/layer.fragment";
  13402. import "babylonjs/Shaders/layer.vertex";
  13403. /**
  13404. * This represents a full screen 2d layer.
  13405. * This can be useful to display a picture in the background of your scene for instance.
  13406. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13407. */
  13408. export class Layer {
  13409. /**
  13410. * Define the name of the layer.
  13411. */
  13412. name: string;
  13413. /**
  13414. * Define the texture the layer should display.
  13415. */
  13416. texture: Nullable<Texture>;
  13417. /**
  13418. * Is the layer in background or foreground.
  13419. */
  13420. isBackground: boolean;
  13421. /**
  13422. * Define the color of the layer (instead of texture).
  13423. */
  13424. color: Color4;
  13425. /**
  13426. * Define the scale of the layer in order to zoom in out of the texture.
  13427. */
  13428. scale: Vector2;
  13429. /**
  13430. * Define an offset for the layer in order to shift the texture.
  13431. */
  13432. offset: Vector2;
  13433. /**
  13434. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13435. */
  13436. alphaBlendingMode: number;
  13437. /**
  13438. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13439. * Alpha test will not mix with the background color in case of transparency.
  13440. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13441. */
  13442. alphaTest: boolean;
  13443. /**
  13444. * Define a mask to restrict the layer to only some of the scene cameras.
  13445. */
  13446. layerMask: number;
  13447. /**
  13448. * Define the list of render target the layer is visible into.
  13449. */
  13450. renderTargetTextures: RenderTargetTexture[];
  13451. /**
  13452. * Define if the layer is only used in renderTarget or if it also
  13453. * renders in the main frame buffer of the canvas.
  13454. */
  13455. renderOnlyInRenderTargetTextures: boolean;
  13456. private _scene;
  13457. private _vertexBuffers;
  13458. private _indexBuffer;
  13459. private _effect;
  13460. private _alphaTestEffect;
  13461. /**
  13462. * An event triggered when the layer is disposed.
  13463. */
  13464. onDisposeObservable: Observable<Layer>;
  13465. private _onDisposeObserver;
  13466. /**
  13467. * Back compatibility with callback before the onDisposeObservable existed.
  13468. * The set callback will be triggered when the layer has been disposed.
  13469. */
  13470. onDispose: () => void;
  13471. /**
  13472. * An event triggered before rendering the scene
  13473. */
  13474. onBeforeRenderObservable: Observable<Layer>;
  13475. private _onBeforeRenderObserver;
  13476. /**
  13477. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13478. * The set callback will be triggered just before rendering the layer.
  13479. */
  13480. onBeforeRender: () => void;
  13481. /**
  13482. * An event triggered after rendering the scene
  13483. */
  13484. onAfterRenderObservable: Observable<Layer>;
  13485. private _onAfterRenderObserver;
  13486. /**
  13487. * Back compatibility with callback before the onAfterRenderObservable existed.
  13488. * The set callback will be triggered just after rendering the layer.
  13489. */
  13490. onAfterRender: () => void;
  13491. /**
  13492. * Instantiates a new layer.
  13493. * This represents a full screen 2d layer.
  13494. * This can be useful to display a picture in the background of your scene for instance.
  13495. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13496. * @param name Define the name of the layer in the scene
  13497. * @param imgUrl Define the url of the texture to display in the layer
  13498. * @param scene Define the scene the layer belongs to
  13499. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13500. * @param color Defines a color for the layer
  13501. */
  13502. constructor(
  13503. /**
  13504. * Define the name of the layer.
  13505. */
  13506. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13507. private _createIndexBuffer;
  13508. /** @hidden */
  13509. _rebuild(): void;
  13510. /**
  13511. * Renders the layer in the scene.
  13512. */
  13513. render(): void;
  13514. /**
  13515. * Disposes and releases the associated ressources.
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13521. import { Scene } from "babylonjs/scene";
  13522. import { ISceneComponent } from "babylonjs/sceneComponent";
  13523. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13524. module "babylonjs/abstractScene" {
  13525. interface AbstractScene {
  13526. /**
  13527. * The list of procedural textures added to the scene
  13528. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13529. */
  13530. proceduralTextures: Array<ProceduralTexture>;
  13531. }
  13532. }
  13533. /**
  13534. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13535. * in a given scene.
  13536. */
  13537. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13538. /**
  13539. * The component name helpfull to identify the component in the list of scene components.
  13540. */
  13541. readonly name: string;
  13542. /**
  13543. * The scene the component belongs to.
  13544. */
  13545. scene: Scene;
  13546. /**
  13547. * Creates a new instance of the component for the given scene
  13548. * @param scene Defines the scene to register the component in
  13549. */
  13550. constructor(scene: Scene);
  13551. /**
  13552. * Registers the component in a given scene
  13553. */
  13554. register(): void;
  13555. /**
  13556. * Rebuilds the elements related to this component in case of
  13557. * context lost for instance.
  13558. */
  13559. rebuild(): void;
  13560. /**
  13561. * Disposes the component and the associated ressources.
  13562. */
  13563. dispose(): void;
  13564. private _beforeClear;
  13565. }
  13566. }
  13567. declare module "babylonjs/Shaders/procedural.vertex" {
  13568. /** @hidden */
  13569. export var proceduralVertexShader: {
  13570. name: string;
  13571. shader: string;
  13572. };
  13573. }
  13574. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13575. import { Observable } from "babylonjs/Misc/observable";
  13576. import { Nullable } from "babylonjs/types";
  13577. import { Scene } from "babylonjs/scene";
  13578. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13579. import { Effect } from "babylonjs/Materials/effect";
  13580. import { Texture } from "babylonjs/Materials/Textures/texture";
  13581. import "babylonjs/Shaders/procedural.vertex";
  13582. /**
  13583. * 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.
  13584. * This is the base class of any Procedural texture and contains most of the shareable code.
  13585. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13586. */
  13587. export class ProceduralTexture extends Texture {
  13588. isCube: boolean;
  13589. /**
  13590. * Define if the texture is enabled or not (disabled texture will not render)
  13591. */
  13592. isEnabled: boolean;
  13593. /**
  13594. * Define if the texture must be cleared before rendering (default is true)
  13595. */
  13596. autoClear: boolean;
  13597. /**
  13598. * Callback called when the texture is generated
  13599. */
  13600. onGenerated: () => void;
  13601. /**
  13602. * Event raised when the texture is generated
  13603. */
  13604. onGeneratedObservable: Observable<ProceduralTexture>;
  13605. /** @hidden */
  13606. _generateMipMaps: boolean;
  13607. /** @hidden **/
  13608. _effect: Effect;
  13609. /** @hidden */
  13610. _textures: {
  13611. [key: string]: Texture;
  13612. };
  13613. private _size;
  13614. private _currentRefreshId;
  13615. private _refreshRate;
  13616. private _vertexBuffers;
  13617. private _indexBuffer;
  13618. private _uniforms;
  13619. private _samplers;
  13620. private _fragment;
  13621. private _floats;
  13622. private _ints;
  13623. private _floatsArrays;
  13624. private _colors3;
  13625. private _colors4;
  13626. private _vectors2;
  13627. private _vectors3;
  13628. private _matrices;
  13629. private _fallbackTexture;
  13630. private _fallbackTextureUsed;
  13631. private _engine;
  13632. private _cachedDefines;
  13633. private _contentUpdateId;
  13634. private _contentData;
  13635. /**
  13636. * Instantiates a new procedural texture.
  13637. * 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.
  13638. * This is the base class of any Procedural texture and contains most of the shareable code.
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13640. * @param name Define the name of the texture
  13641. * @param size Define the size of the texture to create
  13642. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13643. * @param scene Define the scene the texture belongs to
  13644. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13645. * @param generateMipMaps Define if the texture should creates mip maps or not
  13646. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13647. */
  13648. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13649. /**
  13650. * The effect that is created when initializing the post process.
  13651. * @returns The created effect corrisponding the the postprocess.
  13652. */
  13653. getEffect(): Effect;
  13654. /**
  13655. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13656. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13657. */
  13658. getContent(): Nullable<ArrayBufferView>;
  13659. private _createIndexBuffer;
  13660. /** @hidden */
  13661. _rebuild(): void;
  13662. /**
  13663. * Resets the texture in order to recreate its associated resources.
  13664. * This can be called in case of context loss
  13665. */
  13666. reset(): void;
  13667. protected _getDefines(): string;
  13668. /**
  13669. * Is the texture ready to be used ? (rendered at least once)
  13670. * @returns true if ready, otherwise, false.
  13671. */
  13672. isReady(): boolean;
  13673. /**
  13674. * Resets the refresh counter of the texture and start bak from scratch.
  13675. * Could be useful to regenerate the texture if it is setup to render only once.
  13676. */
  13677. resetRefreshCounter(): void;
  13678. /**
  13679. * Set the fragment shader to use in order to render the texture.
  13680. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13681. */
  13682. setFragment(fragment: any): void;
  13683. /**
  13684. * Define the refresh rate of the texture or the rendering frequency.
  13685. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13686. */
  13687. refreshRate: number;
  13688. /** @hidden */
  13689. _shouldRender(): boolean;
  13690. /**
  13691. * Get the size the texture is rendering at.
  13692. * @returns the size (texture is always squared)
  13693. */
  13694. getRenderSize(): number;
  13695. /**
  13696. * Resize the texture to new value.
  13697. * @param size Define the new size the texture should have
  13698. * @param generateMipMaps Define whether the new texture should create mip maps
  13699. */
  13700. resize(size: number, generateMipMaps: boolean): void;
  13701. private _checkUniform;
  13702. /**
  13703. * Set a texture in the shader program used to render.
  13704. * @param name Define the name of the uniform samplers as defined in the shader
  13705. * @param texture Define the texture to bind to this sampler
  13706. * @return the texture itself allowing "fluent" like uniform updates
  13707. */
  13708. setTexture(name: string, texture: Texture): ProceduralTexture;
  13709. /**
  13710. * Set a float in the shader.
  13711. * @param name Define the name of the uniform as defined in the shader
  13712. * @param value Define the value to give to the uniform
  13713. * @return the texture itself allowing "fluent" like uniform updates
  13714. */
  13715. setFloat(name: string, value: number): ProceduralTexture;
  13716. /**
  13717. * Set a int in the shader.
  13718. * @param name Define the name of the uniform as defined in the shader
  13719. * @param value Define the value to give to the uniform
  13720. * @return the texture itself allowing "fluent" like uniform updates
  13721. */
  13722. setInt(name: string, value: number): ProceduralTexture;
  13723. /**
  13724. * Set an array of floats in the shader.
  13725. * @param name Define the name of the uniform as defined in the shader
  13726. * @param value Define the value to give to the uniform
  13727. * @return the texture itself allowing "fluent" like uniform updates
  13728. */
  13729. setFloats(name: string, value: number[]): ProceduralTexture;
  13730. /**
  13731. * Set a vec3 in the shader from a Color3.
  13732. * @param name Define the name of the uniform as defined in the shader
  13733. * @param value Define the value to give to the uniform
  13734. * @return the texture itself allowing "fluent" like uniform updates
  13735. */
  13736. setColor3(name: string, value: Color3): ProceduralTexture;
  13737. /**
  13738. * Set a vec4 in the shader from a Color4.
  13739. * @param name Define the name of the uniform as defined in the shader
  13740. * @param value Define the value to give to the uniform
  13741. * @return the texture itself allowing "fluent" like uniform updates
  13742. */
  13743. setColor4(name: string, value: Color4): ProceduralTexture;
  13744. /**
  13745. * Set a vec2 in the shader from a Vector2.
  13746. * @param name Define the name of the uniform as defined in the shader
  13747. * @param value Define the value to give to the uniform
  13748. * @return the texture itself allowing "fluent" like uniform updates
  13749. */
  13750. setVector2(name: string, value: Vector2): ProceduralTexture;
  13751. /**
  13752. * Set a vec3 in the shader from a Vector3.
  13753. * @param name Define the name of the uniform as defined in the shader
  13754. * @param value Define the value to give to the uniform
  13755. * @return the texture itself allowing "fluent" like uniform updates
  13756. */
  13757. setVector3(name: string, value: Vector3): ProceduralTexture;
  13758. /**
  13759. * Set a mat4 in the shader from a MAtrix.
  13760. * @param name Define the name of the uniform as defined in the shader
  13761. * @param value Define the value to give to the uniform
  13762. * @return the texture itself allowing "fluent" like uniform updates
  13763. */
  13764. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13765. /**
  13766. * Render the texture to its associated render target.
  13767. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13768. */
  13769. render(useCameraPostProcess?: boolean): void;
  13770. /**
  13771. * Clone the texture.
  13772. * @returns the cloned texture
  13773. */
  13774. clone(): ProceduralTexture;
  13775. /**
  13776. * Dispose the texture and release its asoociated resources.
  13777. */
  13778. dispose(): void;
  13779. }
  13780. }
  13781. declare module "babylonjs/Particles/baseParticleSystem" {
  13782. import { Nullable } from "babylonjs/types";
  13783. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  13784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13785. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  13786. import { Texture } from "babylonjs/Materials/Textures/texture";
  13787. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13788. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13789. import { Scene } from "babylonjs/scene";
  13790. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  13791. import { Animation } from "babylonjs/Animations/animation";
  13792. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13793. /**
  13794. * This represents the base class for particle system in Babylon.
  13795. * 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.
  13796. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13797. * @example https://doc.babylonjs.com/babylon101/particles
  13798. */
  13799. export class BaseParticleSystem {
  13800. /**
  13801. * Source color is added to the destination color without alpha affecting the result
  13802. */
  13803. static BLENDMODE_ONEONE: number;
  13804. /**
  13805. * Blend current color and particle color using particle’s alpha
  13806. */
  13807. static BLENDMODE_STANDARD: number;
  13808. /**
  13809. * Add current color and particle color multiplied by particle’s alpha
  13810. */
  13811. static BLENDMODE_ADD: number;
  13812. /**
  13813. * Multiply current color with particle color
  13814. */
  13815. static BLENDMODE_MULTIPLY: number;
  13816. /**
  13817. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13818. */
  13819. static BLENDMODE_MULTIPLYADD: number;
  13820. /**
  13821. * List of animations used by the particle system.
  13822. */
  13823. animations: Animation[];
  13824. /**
  13825. * The id of the Particle system.
  13826. */
  13827. id: string;
  13828. /**
  13829. * The friendly name of the Particle system.
  13830. */
  13831. name: string;
  13832. /**
  13833. * The rendering group used by the Particle system to chose when to render.
  13834. */
  13835. renderingGroupId: number;
  13836. /**
  13837. * The emitter represents the Mesh or position we are attaching the particle system to.
  13838. */
  13839. emitter: Nullable<AbstractMesh | Vector3>;
  13840. /**
  13841. * The maximum number of particles to emit per frame
  13842. */
  13843. emitRate: number;
  13844. /**
  13845. * If you want to launch only a few particles at once, that can be done, as well.
  13846. */
  13847. manualEmitCount: number;
  13848. /**
  13849. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13850. */
  13851. updateSpeed: number;
  13852. /**
  13853. * The amount of time the particle system is running (depends of the overall update speed).
  13854. */
  13855. targetStopDuration: number;
  13856. /**
  13857. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13858. */
  13859. disposeOnStop: boolean;
  13860. /**
  13861. * Minimum power of emitting particles.
  13862. */
  13863. minEmitPower: number;
  13864. /**
  13865. * Maximum power of emitting particles.
  13866. */
  13867. maxEmitPower: number;
  13868. /**
  13869. * Minimum life time of emitting particles.
  13870. */
  13871. minLifeTime: number;
  13872. /**
  13873. * Maximum life time of emitting particles.
  13874. */
  13875. maxLifeTime: number;
  13876. /**
  13877. * Minimum Size of emitting particles.
  13878. */
  13879. minSize: number;
  13880. /**
  13881. * Maximum Size of emitting particles.
  13882. */
  13883. maxSize: number;
  13884. /**
  13885. * Minimum scale of emitting particles on X axis.
  13886. */
  13887. minScaleX: number;
  13888. /**
  13889. * Maximum scale of emitting particles on X axis.
  13890. */
  13891. maxScaleX: number;
  13892. /**
  13893. * Minimum scale of emitting particles on Y axis.
  13894. */
  13895. minScaleY: number;
  13896. /**
  13897. * Maximum scale of emitting particles on Y axis.
  13898. */
  13899. maxScaleY: number;
  13900. /**
  13901. * Gets or sets the minimal initial rotation in radians.
  13902. */
  13903. minInitialRotation: number;
  13904. /**
  13905. * Gets or sets the maximal initial rotation in radians.
  13906. */
  13907. maxInitialRotation: number;
  13908. /**
  13909. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13910. */
  13911. minAngularSpeed: number;
  13912. /**
  13913. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13914. */
  13915. maxAngularSpeed: number;
  13916. /**
  13917. * The texture used to render each particle. (this can be a spritesheet)
  13918. */
  13919. particleTexture: Nullable<Texture>;
  13920. /**
  13921. * The layer mask we are rendering the particles through.
  13922. */
  13923. layerMask: number;
  13924. /**
  13925. * This can help using your own shader to render the particle system.
  13926. * The according effect will be created
  13927. */
  13928. customShader: any;
  13929. /**
  13930. * By default particle system starts as soon as they are created. This prevents the
  13931. * automatic start to happen and let you decide when to start emitting particles.
  13932. */
  13933. preventAutoStart: boolean;
  13934. private _noiseTexture;
  13935. /**
  13936. * Gets or sets a texture used to add random noise to particle positions
  13937. */
  13938. noiseTexture: Nullable<ProceduralTexture>;
  13939. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13940. noiseStrength: Vector3;
  13941. /**
  13942. * Callback triggered when the particle animation is ending.
  13943. */
  13944. onAnimationEnd: Nullable<() => void>;
  13945. /**
  13946. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13947. */
  13948. blendMode: number;
  13949. /**
  13950. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13951. * to override the particles.
  13952. */
  13953. forceDepthWrite: boolean;
  13954. /** 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 */
  13955. preWarmCycles: number;
  13956. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13957. preWarmStepOffset: number;
  13958. /**
  13959. * 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)
  13960. */
  13961. spriteCellChangeSpeed: number;
  13962. /**
  13963. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13964. */
  13965. startSpriteCellID: number;
  13966. /**
  13967. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13968. */
  13969. endSpriteCellID: number;
  13970. /**
  13971. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13972. */
  13973. spriteCellWidth: number;
  13974. /**
  13975. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13976. */
  13977. spriteCellHeight: number;
  13978. /**
  13979. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13980. */
  13981. spriteRandomStartCell: boolean;
  13982. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13983. translationPivot: Vector2;
  13984. /** @hidden */
  13985. protected _isAnimationSheetEnabled: boolean;
  13986. /**
  13987. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13988. */
  13989. beginAnimationOnStart: boolean;
  13990. /**
  13991. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13992. */
  13993. beginAnimationFrom: number;
  13994. /**
  13995. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13996. */
  13997. beginAnimationTo: number;
  13998. /**
  13999. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14000. */
  14001. beginAnimationLoop: boolean;
  14002. /**
  14003. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14004. */
  14005. isAnimationSheetEnabled: boolean;
  14006. /**
  14007. * Get hosting scene
  14008. * @returns the scene
  14009. */
  14010. getScene(): Scene;
  14011. /**
  14012. * You can use gravity if you want to give an orientation to your particles.
  14013. */
  14014. gravity: Vector3;
  14015. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14016. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14017. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14018. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14019. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14020. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14021. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14022. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14023. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14024. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14025. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14026. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14027. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14028. /**
  14029. * Defines the delay in milliseconds before starting the system (0 by default)
  14030. */
  14031. startDelay: number;
  14032. /**
  14033. * Gets the current list of drag gradients.
  14034. * You must use addDragGradient and removeDragGradient to udpate this list
  14035. * @returns the list of drag gradients
  14036. */
  14037. getDragGradients(): Nullable<Array<FactorGradient>>;
  14038. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14039. limitVelocityDamping: number;
  14040. /**
  14041. * Gets the current list of limit velocity gradients.
  14042. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14043. * @returns the list of limit velocity gradients
  14044. */
  14045. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14046. /**
  14047. * Gets the current list of color gradients.
  14048. * You must use addColorGradient and removeColorGradient to udpate this list
  14049. * @returns the list of color gradients
  14050. */
  14051. getColorGradients(): Nullable<Array<ColorGradient>>;
  14052. /**
  14053. * Gets the current list of size gradients.
  14054. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14055. * @returns the list of size gradients
  14056. */
  14057. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14058. /**
  14059. * Gets the current list of color remap gradients.
  14060. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14061. * @returns the list of color remap gradients
  14062. */
  14063. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14064. /**
  14065. * Gets the current list of alpha remap gradients.
  14066. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14067. * @returns the list of alpha remap gradients
  14068. */
  14069. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14070. /**
  14071. * Gets the current list of life time gradients.
  14072. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14073. * @returns the list of life time gradients
  14074. */
  14075. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14076. /**
  14077. * Gets the current list of angular speed gradients.
  14078. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14079. * @returns the list of angular speed gradients
  14080. */
  14081. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14082. /**
  14083. * Gets the current list of velocity gradients.
  14084. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14085. * @returns the list of velocity gradients
  14086. */
  14087. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14088. /**
  14089. * Gets the current list of start size gradients.
  14090. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14091. * @returns the list of start size gradients
  14092. */
  14093. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14094. /**
  14095. * Gets the current list of emit rate gradients.
  14096. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14097. * @returns the list of emit rate gradients
  14098. */
  14099. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14100. /**
  14101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14102. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14103. */
  14104. direction1: Vector3;
  14105. /**
  14106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14107. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14108. */
  14109. direction2: Vector3;
  14110. /**
  14111. * 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.
  14112. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14113. */
  14114. minEmitBox: Vector3;
  14115. /**
  14116. * 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.
  14117. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14118. */
  14119. maxEmitBox: Vector3;
  14120. /**
  14121. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14122. */
  14123. color1: Color4;
  14124. /**
  14125. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14126. */
  14127. color2: Color4;
  14128. /**
  14129. * Color the particle will have at the end of its lifetime
  14130. */
  14131. colorDead: Color4;
  14132. /**
  14133. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14134. */
  14135. textureMask: Color4;
  14136. /**
  14137. * The particle emitter type defines the emitter used by the particle system.
  14138. * It can be for example box, sphere, or cone...
  14139. */
  14140. particleEmitterType: IParticleEmitterType;
  14141. /** @hidden */
  14142. _isSubEmitter: boolean;
  14143. /**
  14144. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14145. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14146. */
  14147. billboardMode: number;
  14148. protected _isBillboardBased: boolean;
  14149. /**
  14150. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14151. */
  14152. isBillboardBased: boolean;
  14153. /**
  14154. * The scene the particle system belongs to.
  14155. */
  14156. protected _scene: Scene;
  14157. /**
  14158. * Local cache of defines for image processing.
  14159. */
  14160. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14161. /**
  14162. * Default configuration related to image processing available in the standard Material.
  14163. */
  14164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14165. /**
  14166. * Gets the image processing configuration used either in this material.
  14167. */
  14168. /**
  14169. * Sets the Default image processing configuration used either in the this material.
  14170. *
  14171. * If sets to null, the scene one is in use.
  14172. */
  14173. imageProcessingConfiguration: ImageProcessingConfiguration;
  14174. /**
  14175. * Attaches a new image processing configuration to the Standard Material.
  14176. * @param configuration
  14177. */
  14178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14179. /** @hidden */
  14180. protected _reset(): void;
  14181. /** @hidden */
  14182. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14183. /**
  14184. * Instantiates a particle system.
  14185. * 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.
  14186. * @param name The name of the particle system
  14187. */
  14188. constructor(name: string);
  14189. /**
  14190. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14191. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14192. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14193. * @returns the emitter
  14194. */
  14195. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14196. /**
  14197. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14198. * @param radius The radius of the hemisphere to emit from
  14199. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14200. * @returns the emitter
  14201. */
  14202. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14203. /**
  14204. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14205. * @param radius The radius of the sphere to emit from
  14206. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14207. * @returns the emitter
  14208. */
  14209. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14210. /**
  14211. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14212. * @param radius The radius of the sphere to emit from
  14213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14215. * @returns the emitter
  14216. */
  14217. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14218. /**
  14219. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14220. * @param radius The radius of the emission cylinder
  14221. * @param height The height of the emission cylinder
  14222. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14223. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14224. * @returns the emitter
  14225. */
  14226. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14227. /**
  14228. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14229. * @param radius The radius of the cylinder to emit from
  14230. * @param height The height of the emission cylinder
  14231. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14234. * @returns the emitter
  14235. */
  14236. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14237. /**
  14238. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14239. * @param radius The radius of the cone to emit from
  14240. * @param angle The base angle of the cone
  14241. * @returns the emitter
  14242. */
  14243. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14244. /**
  14245. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14246. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14247. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14248. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14249. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14250. * @returns the emitter
  14251. */
  14252. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14253. }
  14254. }
  14255. declare module "babylonjs/Particles/subEmitter" {
  14256. import { Scene } from "babylonjs/scene";
  14257. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14258. /**
  14259. * Type of sub emitter
  14260. */
  14261. export enum SubEmitterType {
  14262. /**
  14263. * Attached to the particle over it's lifetime
  14264. */
  14265. ATTACHED = 0,
  14266. /**
  14267. * Created when the particle dies
  14268. */
  14269. END = 1
  14270. }
  14271. /**
  14272. * Sub emitter class used to emit particles from an existing particle
  14273. */
  14274. export class SubEmitter {
  14275. /**
  14276. * the particle system to be used by the sub emitter
  14277. */
  14278. particleSystem: ParticleSystem;
  14279. /**
  14280. * Type of the submitter (Default: END)
  14281. */
  14282. type: SubEmitterType;
  14283. /**
  14284. * 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)
  14285. * Note: This only is supported when using an emitter of type Mesh
  14286. */
  14287. inheritDirection: boolean;
  14288. /**
  14289. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14290. */
  14291. inheritedVelocityAmount: number;
  14292. /**
  14293. * Creates a sub emitter
  14294. * @param particleSystem the particle system to be used by the sub emitter
  14295. */
  14296. constructor(
  14297. /**
  14298. * the particle system to be used by the sub emitter
  14299. */
  14300. particleSystem: ParticleSystem);
  14301. /**
  14302. * Clones the sub emitter
  14303. * @returns the cloned sub emitter
  14304. */
  14305. clone(): SubEmitter;
  14306. /**
  14307. * Serialize current object to a JSON object
  14308. * @returns the serialized object
  14309. */
  14310. serialize(): any;
  14311. /** @hidden */
  14312. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14313. /**
  14314. * Creates a new SubEmitter from a serialized JSON version
  14315. * @param serializationObject defines the JSON object to read from
  14316. * @param scene defines the hosting scene
  14317. * @param rootUrl defines the rootUrl for data loading
  14318. * @returns a new SubEmitter
  14319. */
  14320. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14321. /** Release associated resources */
  14322. dispose(): void;
  14323. }
  14324. }
  14325. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14326. /** @hidden */
  14327. export var clipPlaneFragmentDeclaration: {
  14328. name: string;
  14329. shader: string;
  14330. };
  14331. }
  14332. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14333. /** @hidden */
  14334. export var imageProcessingDeclaration: {
  14335. name: string;
  14336. shader: string;
  14337. };
  14338. }
  14339. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14340. /** @hidden */
  14341. export var imageProcessingFunctions: {
  14342. name: string;
  14343. shader: string;
  14344. };
  14345. }
  14346. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14347. /** @hidden */
  14348. export var clipPlaneFragment: {
  14349. name: string;
  14350. shader: string;
  14351. };
  14352. }
  14353. declare module "babylonjs/Shaders/particles.fragment" {
  14354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14355. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14357. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14359. /** @hidden */
  14360. export var particlesPixelShader: {
  14361. name: string;
  14362. shader: string;
  14363. };
  14364. }
  14365. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14366. /** @hidden */
  14367. export var clipPlaneVertexDeclaration: {
  14368. name: string;
  14369. shader: string;
  14370. };
  14371. }
  14372. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14373. /** @hidden */
  14374. export var clipPlaneVertex: {
  14375. name: string;
  14376. shader: string;
  14377. };
  14378. }
  14379. declare module "babylonjs/Shaders/particles.vertex" {
  14380. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14382. /** @hidden */
  14383. export var particlesVertexShader: {
  14384. name: string;
  14385. shader: string;
  14386. };
  14387. }
  14388. declare module "babylonjs/Particles/particleSystem" {
  14389. import { Nullable } from "babylonjs/types";
  14390. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14391. import { Observable } from "babylonjs/Misc/observable";
  14392. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14393. import { Effect } from "babylonjs/Materials/effect";
  14394. import { Scene, IDisposable } from "babylonjs/scene";
  14395. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14396. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14397. import { Particle } from "babylonjs/Particles/particle";
  14398. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14399. import "babylonjs/Shaders/particles.fragment";
  14400. import "babylonjs/Shaders/particles.vertex";
  14401. /**
  14402. * This represents a particle system in Babylon.
  14403. * 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.
  14404. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14405. * @example https://doc.babylonjs.com/babylon101/particles
  14406. */
  14407. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14408. /**
  14409. * Billboard mode will only apply to Y axis
  14410. */
  14411. static readonly BILLBOARDMODE_Y: number;
  14412. /**
  14413. * Billboard mode will apply to all axes
  14414. */
  14415. static readonly BILLBOARDMODE_ALL: number;
  14416. /**
  14417. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14418. */
  14419. static readonly BILLBOARDMODE_STRETCHED: number;
  14420. /**
  14421. * This function can be defined to provide custom update for active particles.
  14422. * This function will be called instead of regular update (age, position, color, etc.).
  14423. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14424. */
  14425. updateFunction: (particles: Particle[]) => void;
  14426. private _emitterWorldMatrix;
  14427. /**
  14428. * This function can be defined to specify initial direction for every new particle.
  14429. * It by default use the emitterType defined function
  14430. */
  14431. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14432. /**
  14433. * This function can be defined to specify initial position for every new particle.
  14434. * It by default use the emitterType defined function
  14435. */
  14436. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14437. /**
  14438. * @hidden
  14439. */
  14440. _inheritedVelocityOffset: Vector3;
  14441. /**
  14442. * An event triggered when the system is disposed
  14443. */
  14444. onDisposeObservable: Observable<ParticleSystem>;
  14445. private _onDisposeObserver;
  14446. /**
  14447. * Sets a callback that will be triggered when the system is disposed
  14448. */
  14449. onDispose: () => void;
  14450. private _particles;
  14451. private _epsilon;
  14452. private _capacity;
  14453. private _stockParticles;
  14454. private _newPartsExcess;
  14455. private _vertexData;
  14456. private _vertexBuffer;
  14457. private _vertexBuffers;
  14458. private _spriteBuffer;
  14459. private _indexBuffer;
  14460. private _effect;
  14461. private _customEffect;
  14462. private _cachedDefines;
  14463. private _scaledColorStep;
  14464. private _colorDiff;
  14465. private _scaledDirection;
  14466. private _scaledGravity;
  14467. private _currentRenderId;
  14468. private _alive;
  14469. private _useInstancing;
  14470. private _started;
  14471. private _stopped;
  14472. private _actualFrame;
  14473. private _scaledUpdateSpeed;
  14474. private _vertexBufferSize;
  14475. /** @hidden */
  14476. _currentEmitRateGradient: Nullable<FactorGradient>;
  14477. /** @hidden */
  14478. _currentEmitRate1: number;
  14479. /** @hidden */
  14480. _currentEmitRate2: number;
  14481. /** @hidden */
  14482. _currentStartSizeGradient: Nullable<FactorGradient>;
  14483. /** @hidden */
  14484. _currentStartSize1: number;
  14485. /** @hidden */
  14486. _currentStartSize2: number;
  14487. private readonly _rawTextureWidth;
  14488. private _rampGradientsTexture;
  14489. private _useRampGradients;
  14490. /** Gets or sets a boolean indicating that ramp gradients must be used
  14491. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14492. */
  14493. useRampGradients: boolean;
  14494. /**
  14495. * 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.
  14496. * 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: [])
  14497. */
  14498. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14499. private _subEmitters;
  14500. /**
  14501. * @hidden
  14502. * If the particle systems emitter should be disposed when the particle system is disposed
  14503. */
  14504. _disposeEmitterOnDispose: boolean;
  14505. /**
  14506. * The current active Sub-systems, this property is used by the root particle system only.
  14507. */
  14508. activeSubSystems: Array<ParticleSystem>;
  14509. private _rootParticleSystem;
  14510. /**
  14511. * Gets the current list of active particles
  14512. */
  14513. readonly particles: Particle[];
  14514. /**
  14515. * Returns the string "ParticleSystem"
  14516. * @returns a string containing the class name
  14517. */
  14518. getClassName(): string;
  14519. /**
  14520. * Instantiates a particle system.
  14521. * 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.
  14522. * @param name The name of the particle system
  14523. * @param capacity The max number of particles alive at the same time
  14524. * @param scene The scene the particle system belongs to
  14525. * @param customEffect a custom effect used to change the way particles are rendered by default
  14526. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14527. * @param epsilon Offset used to render the particles
  14528. */
  14529. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14530. private _addFactorGradient;
  14531. private _removeFactorGradient;
  14532. /**
  14533. * Adds a new life time gradient
  14534. * @param gradient defines the gradient to use (between 0 and 1)
  14535. * @param factor defines the life time factor to affect to the specified gradient
  14536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14537. * @returns the current particle system
  14538. */
  14539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14540. /**
  14541. * Remove a specific life time gradient
  14542. * @param gradient defines the gradient to remove
  14543. * @returns the current particle system
  14544. */
  14545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14546. /**
  14547. * Adds a new size gradient
  14548. * @param gradient defines the gradient to use (between 0 and 1)
  14549. * @param factor defines the size factor to affect to the specified gradient
  14550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14551. * @returns the current particle system
  14552. */
  14553. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14554. /**
  14555. * Remove a specific size gradient
  14556. * @param gradient defines the gradient to remove
  14557. * @returns the current particle system
  14558. */
  14559. removeSizeGradient(gradient: number): IParticleSystem;
  14560. /**
  14561. * Adds a new color remap gradient
  14562. * @param gradient defines the gradient to use (between 0 and 1)
  14563. * @param min defines the color remap minimal range
  14564. * @param max defines the color remap maximal range
  14565. * @returns the current particle system
  14566. */
  14567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14568. /**
  14569. * Remove a specific color remap gradient
  14570. * @param gradient defines the gradient to remove
  14571. * @returns the current particle system
  14572. */
  14573. removeColorRemapGradient(gradient: number): IParticleSystem;
  14574. /**
  14575. * Adds a new alpha remap gradient
  14576. * @param gradient defines the gradient to use (between 0 and 1)
  14577. * @param min defines the alpha remap minimal range
  14578. * @param max defines the alpha remap maximal range
  14579. * @returns the current particle system
  14580. */
  14581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14582. /**
  14583. * Remove a specific alpha remap gradient
  14584. * @param gradient defines the gradient to remove
  14585. * @returns the current particle system
  14586. */
  14587. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14588. /**
  14589. * Adds a new angular speed gradient
  14590. * @param gradient defines the gradient to use (between 0 and 1)
  14591. * @param factor defines the angular speed to affect to the specified gradient
  14592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14593. * @returns the current particle system
  14594. */
  14595. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14596. /**
  14597. * Remove a specific angular speed gradient
  14598. * @param gradient defines the gradient to remove
  14599. * @returns the current particle system
  14600. */
  14601. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14602. /**
  14603. * Adds a new velocity gradient
  14604. * @param gradient defines the gradient to use (between 0 and 1)
  14605. * @param factor defines the velocity to affect to the specified gradient
  14606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14607. * @returns the current particle system
  14608. */
  14609. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14610. /**
  14611. * Remove a specific velocity gradient
  14612. * @param gradient defines the gradient to remove
  14613. * @returns the current particle system
  14614. */
  14615. removeVelocityGradient(gradient: number): IParticleSystem;
  14616. /**
  14617. * Adds a new limit velocity gradient
  14618. * @param gradient defines the gradient to use (between 0 and 1)
  14619. * @param factor defines the limit velocity value to affect to the specified gradient
  14620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14621. * @returns the current particle system
  14622. */
  14623. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14624. /**
  14625. * Remove a specific limit velocity gradient
  14626. * @param gradient defines the gradient to remove
  14627. * @returns the current particle system
  14628. */
  14629. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14630. /**
  14631. * Adds a new drag gradient
  14632. * @param gradient defines the gradient to use (between 0 and 1)
  14633. * @param factor defines the drag value to affect to the specified gradient
  14634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14635. * @returns the current particle system
  14636. */
  14637. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14638. /**
  14639. * Remove a specific drag gradient
  14640. * @param gradient defines the gradient to remove
  14641. * @returns the current particle system
  14642. */
  14643. removeDragGradient(gradient: number): IParticleSystem;
  14644. /**
  14645. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14646. * @param gradient defines the gradient to use (between 0 and 1)
  14647. * @param factor defines the emit rate value to affect to the specified gradient
  14648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14649. * @returns the current particle system
  14650. */
  14651. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14652. /**
  14653. * Remove a specific emit rate gradient
  14654. * @param gradient defines the gradient to remove
  14655. * @returns the current particle system
  14656. */
  14657. removeEmitRateGradient(gradient: number): IParticleSystem;
  14658. /**
  14659. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14660. * @param gradient defines the gradient to use (between 0 and 1)
  14661. * @param factor defines the start size value to affect to the specified gradient
  14662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14663. * @returns the current particle system
  14664. */
  14665. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14666. /**
  14667. * Remove a specific start size gradient
  14668. * @param gradient defines the gradient to remove
  14669. * @returns the current particle system
  14670. */
  14671. removeStartSizeGradient(gradient: number): IParticleSystem;
  14672. private _createRampGradientTexture;
  14673. /**
  14674. * Gets the current list of ramp gradients.
  14675. * You must use addRampGradient and removeRampGradient to udpate this list
  14676. * @returns the list of ramp gradients
  14677. */
  14678. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14679. /**
  14680. * Adds a new ramp gradient used to remap particle colors
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color defines the color to affect to the specified gradient
  14683. * @returns the current particle system
  14684. */
  14685. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14686. /**
  14687. * Remove a specific ramp gradient
  14688. * @param gradient defines the gradient to remove
  14689. * @returns the current particle system
  14690. */
  14691. removeRampGradient(gradient: number): ParticleSystem;
  14692. /**
  14693. * Adds a new color gradient
  14694. * @param gradient defines the gradient to use (between 0 and 1)
  14695. * @param color1 defines the color to affect to the specified gradient
  14696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14697. * @returns this particle system
  14698. */
  14699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14700. /**
  14701. * Remove a specific color gradient
  14702. * @param gradient defines the gradient to remove
  14703. * @returns this particle system
  14704. */
  14705. removeColorGradient(gradient: number): IParticleSystem;
  14706. private _fetchR;
  14707. protected _reset(): void;
  14708. private _resetEffect;
  14709. private _createVertexBuffers;
  14710. private _createIndexBuffer;
  14711. /**
  14712. * Gets the maximum number of particles active at the same time.
  14713. * @returns The max number of active particles.
  14714. */
  14715. getCapacity(): number;
  14716. /**
  14717. * Gets whether there are still active particles in the system.
  14718. * @returns True if it is alive, otherwise false.
  14719. */
  14720. isAlive(): boolean;
  14721. /**
  14722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14723. * @returns True if it has been started, otherwise false.
  14724. */
  14725. isStarted(): boolean;
  14726. private _prepareSubEmitterInternalArray;
  14727. /**
  14728. * Starts the particle system and begins to emit
  14729. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14730. */
  14731. start(delay?: number): void;
  14732. /**
  14733. * Stops the particle system.
  14734. * @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.
  14735. */
  14736. stop(stopSubEmitters?: boolean): void;
  14737. /**
  14738. * Remove all active particles
  14739. */
  14740. reset(): void;
  14741. /**
  14742. * @hidden (for internal use only)
  14743. */
  14744. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14745. /**
  14746. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14747. * Its lifetime will start back at 0.
  14748. */
  14749. recycleParticle: (particle: Particle) => void;
  14750. private _stopSubEmitters;
  14751. private _createParticle;
  14752. private _removeFromRoot;
  14753. private _emitFromParticle;
  14754. private _update;
  14755. /** @hidden */
  14756. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14757. /** @hidden */
  14758. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14759. /** @hidden */
  14760. private _getEffect;
  14761. /**
  14762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14764. */
  14765. animate(preWarmOnly?: boolean): void;
  14766. private _appendParticleVertices;
  14767. /**
  14768. * Rebuilds the particle system.
  14769. */
  14770. rebuild(): void;
  14771. /**
  14772. * Is this system ready to be used/rendered
  14773. * @return true if the system is ready
  14774. */
  14775. isReady(): boolean;
  14776. private _render;
  14777. /**
  14778. * Renders the particle system in its current state.
  14779. * @returns the current number of particles
  14780. */
  14781. render(): number;
  14782. /**
  14783. * Disposes the particle system and free the associated resources
  14784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14785. */
  14786. dispose(disposeTexture?: boolean): void;
  14787. /**
  14788. * Clones the particle system.
  14789. * @param name The name of the cloned object
  14790. * @param newEmitter The new emitter to use
  14791. * @returns the cloned particle system
  14792. */
  14793. clone(name: string, newEmitter: any): ParticleSystem;
  14794. /**
  14795. * Serializes the particle system to a JSON object.
  14796. * @returns the JSON object
  14797. */
  14798. serialize(): any;
  14799. /** @hidden */
  14800. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14801. /** @hidden */
  14802. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14803. /**
  14804. * Parses a JSON object to create a particle system.
  14805. * @param parsedParticleSystem The JSON object to parse
  14806. * @param scene The scene to create the particle system in
  14807. * @param rootUrl The root url to use to load external dependencies like texture
  14808. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14809. * @returns the Parsed particle system
  14810. */
  14811. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14812. }
  14813. }
  14814. declare module "babylonjs/Particles/particle" {
  14815. import { Nullable } from "babylonjs/types";
  14816. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  14817. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14818. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14819. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  14820. /**
  14821. * A particle represents one of the element emitted by a particle system.
  14822. * This is mainly define by its coordinates, direction, velocity and age.
  14823. */
  14824. export class Particle {
  14825. /**
  14826. * The particle system the particle belongs to.
  14827. */
  14828. particleSystem: ParticleSystem;
  14829. private static _Count;
  14830. /**
  14831. * Unique ID of the particle
  14832. */
  14833. id: number;
  14834. /**
  14835. * The world position of the particle in the scene.
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * The world direction of the particle in the scene.
  14840. */
  14841. direction: Vector3;
  14842. /**
  14843. * The color of the particle.
  14844. */
  14845. color: Color4;
  14846. /**
  14847. * The color change of the particle per step.
  14848. */
  14849. colorStep: Color4;
  14850. /**
  14851. * Defines how long will the life of the particle be.
  14852. */
  14853. lifeTime: number;
  14854. /**
  14855. * The current age of the particle.
  14856. */
  14857. age: number;
  14858. /**
  14859. * The current size of the particle.
  14860. */
  14861. size: number;
  14862. /**
  14863. * The current scale of the particle.
  14864. */
  14865. scale: Vector2;
  14866. /**
  14867. * The current angle of the particle.
  14868. */
  14869. angle: number;
  14870. /**
  14871. * Defines how fast is the angle changing.
  14872. */
  14873. angularSpeed: number;
  14874. /**
  14875. * Defines the cell index used by the particle to be rendered from a sprite.
  14876. */
  14877. cellIndex: number;
  14878. /**
  14879. * The information required to support color remapping
  14880. */
  14881. remapData: Vector4;
  14882. /** @hidden */
  14883. _randomCellOffset?: number;
  14884. /** @hidden */
  14885. _initialDirection: Nullable<Vector3>;
  14886. /** @hidden */
  14887. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14888. /** @hidden */
  14889. _initialStartSpriteCellID: number;
  14890. /** @hidden */
  14891. _initialEndSpriteCellID: number;
  14892. /** @hidden */
  14893. _currentColorGradient: Nullable<ColorGradient>;
  14894. /** @hidden */
  14895. _currentColor1: Color4;
  14896. /** @hidden */
  14897. _currentColor2: Color4;
  14898. /** @hidden */
  14899. _currentSizeGradient: Nullable<FactorGradient>;
  14900. /** @hidden */
  14901. _currentSize1: number;
  14902. /** @hidden */
  14903. _currentSize2: number;
  14904. /** @hidden */
  14905. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14906. /** @hidden */
  14907. _currentAngularSpeed1: number;
  14908. /** @hidden */
  14909. _currentAngularSpeed2: number;
  14910. /** @hidden */
  14911. _currentVelocityGradient: Nullable<FactorGradient>;
  14912. /** @hidden */
  14913. _currentVelocity1: number;
  14914. /** @hidden */
  14915. _currentVelocity2: number;
  14916. /** @hidden */
  14917. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14918. /** @hidden */
  14919. _currentLimitVelocity1: number;
  14920. /** @hidden */
  14921. _currentLimitVelocity2: number;
  14922. /** @hidden */
  14923. _currentDragGradient: Nullable<FactorGradient>;
  14924. /** @hidden */
  14925. _currentDrag1: number;
  14926. /** @hidden */
  14927. _currentDrag2: number;
  14928. /** @hidden */
  14929. _randomNoiseCoordinates1: Vector3;
  14930. /** @hidden */
  14931. _randomNoiseCoordinates2: Vector3;
  14932. /**
  14933. * Creates a new instance Particle
  14934. * @param particleSystem the particle system the particle belongs to
  14935. */
  14936. constructor(
  14937. /**
  14938. * The particle system the particle belongs to.
  14939. */
  14940. particleSystem: ParticleSystem);
  14941. private updateCellInfoFromSystem;
  14942. /**
  14943. * Defines how the sprite cell index is updated for the particle
  14944. */
  14945. updateCellIndex(): void;
  14946. /** @hidden */
  14947. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14948. /** @hidden */
  14949. _inheritParticleInfoToSubEmitters(): void;
  14950. /** @hidden */
  14951. _reset(): void;
  14952. /**
  14953. * Copy the properties of particle to another one.
  14954. * @param other the particle to copy the information to.
  14955. */
  14956. copyTo(other: Particle): void;
  14957. }
  14958. }
  14959. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  14960. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14961. import { Effect } from "babylonjs/Materials/effect";
  14962. import { Particle } from "babylonjs/Particles/particle";
  14963. /**
  14964. * Particle emitter represents a volume emitting particles.
  14965. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14966. */
  14967. export interface IParticleEmitterType {
  14968. /**
  14969. * Called by the particle System when the direction is computed for the created particle.
  14970. * @param worldMatrix is the world matrix of the particle system
  14971. * @param directionToUpdate is the direction vector to update with the result
  14972. * @param particle is the particle we are computed the direction for
  14973. */
  14974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14975. /**
  14976. * Called by the particle System when the position is computed for the created particle.
  14977. * @param worldMatrix is the world matrix of the particle system
  14978. * @param positionToUpdate is the position vector to update with the result
  14979. * @param particle is the particle we are computed the position for
  14980. */
  14981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14982. /**
  14983. * Clones the current emitter and returns a copy of it
  14984. * @returns the new emitter
  14985. */
  14986. clone(): IParticleEmitterType;
  14987. /**
  14988. * Called by the GPUParticleSystem to setup the update shader
  14989. * @param effect defines the update shader
  14990. */
  14991. applyToShader(effect: Effect): void;
  14992. /**
  14993. * Returns a string to use to update the GPU particles update shader
  14994. * @returns the effect defines string
  14995. */
  14996. getEffectDefines(): string;
  14997. /**
  14998. * Returns a string representing the class name
  14999. * @returns a string containing the class name
  15000. */
  15001. getClassName(): string;
  15002. /**
  15003. * Serializes the particle system to a JSON object.
  15004. * @returns the JSON object
  15005. */
  15006. serialize(): any;
  15007. /**
  15008. * Parse properties from a JSON object
  15009. * @param serializationObject defines the JSON object
  15010. */
  15011. parse(serializationObject: any): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15015. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15016. import { Effect } from "babylonjs/Materials/effect";
  15017. import { Particle } from "babylonjs/Particles/particle";
  15018. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15019. /**
  15020. * Particle emitter emitting particles from the inside of a box.
  15021. * It emits the particles randomly between 2 given directions.
  15022. */
  15023. export class BoxParticleEmitter implements IParticleEmitterType {
  15024. /**
  15025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15026. */
  15027. direction1: Vector3;
  15028. /**
  15029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15030. */
  15031. direction2: Vector3;
  15032. /**
  15033. * 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.
  15034. */
  15035. minEmitBox: Vector3;
  15036. /**
  15037. * 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.
  15038. */
  15039. maxEmitBox: Vector3;
  15040. /**
  15041. * Creates a new instance BoxParticleEmitter
  15042. */
  15043. constructor();
  15044. /**
  15045. * Called by the particle System when the direction is computed for the created particle.
  15046. * @param worldMatrix is the world matrix of the particle system
  15047. * @param directionToUpdate is the direction vector to update with the result
  15048. * @param particle is the particle we are computed the direction for
  15049. */
  15050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15051. /**
  15052. * Called by the particle System when the position is computed for the created particle.
  15053. * @param worldMatrix is the world matrix of the particle system
  15054. * @param positionToUpdate is the position vector to update with the result
  15055. * @param particle is the particle we are computed the position for
  15056. */
  15057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15058. /**
  15059. * Clones the current emitter and returns a copy of it
  15060. * @returns the new emitter
  15061. */
  15062. clone(): BoxParticleEmitter;
  15063. /**
  15064. * Called by the GPUParticleSystem to setup the update shader
  15065. * @param effect defines the update shader
  15066. */
  15067. applyToShader(effect: Effect): void;
  15068. /**
  15069. * Returns a string to use to update the GPU particles update shader
  15070. * @returns a string containng the defines string
  15071. */
  15072. getEffectDefines(): string;
  15073. /**
  15074. * Returns the string "BoxParticleEmitter"
  15075. * @returns a string containing the class name
  15076. */
  15077. getClassName(): string;
  15078. /**
  15079. * Serializes the particle system to a JSON object.
  15080. * @returns the JSON object
  15081. */
  15082. serialize(): any;
  15083. /**
  15084. * Parse properties from a JSON object
  15085. * @param serializationObject defines the JSON object
  15086. */
  15087. parse(serializationObject: any): void;
  15088. }
  15089. }
  15090. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15091. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15092. import { Effect } from "babylonjs/Materials/effect";
  15093. import { Particle } from "babylonjs/Particles/particle";
  15094. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15095. /**
  15096. * Particle emitter emitting particles from the inside of a cone.
  15097. * It emits the particles alongside the cone volume from the base to the particle.
  15098. * The emission direction might be randomized.
  15099. */
  15100. export class ConeParticleEmitter implements IParticleEmitterType {
  15101. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15102. directionRandomizer: number;
  15103. private _radius;
  15104. private _angle;
  15105. private _height;
  15106. /**
  15107. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15108. */
  15109. radiusRange: number;
  15110. /**
  15111. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15112. */
  15113. heightRange: number;
  15114. /**
  15115. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15116. */
  15117. emitFromSpawnPointOnly: boolean;
  15118. /**
  15119. * Gets or sets the radius of the emission cone
  15120. */
  15121. radius: number;
  15122. /**
  15123. * Gets or sets the angle of the emission cone
  15124. */
  15125. angle: number;
  15126. private _buildHeight;
  15127. /**
  15128. * Creates a new instance ConeParticleEmitter
  15129. * @param radius the radius of the emission cone (1 by default)
  15130. * @param angles the cone base angle (PI by default)
  15131. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15132. */
  15133. constructor(radius?: number, angle?: number,
  15134. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15135. directionRandomizer?: number);
  15136. /**
  15137. * Called by the particle System when the direction is computed for the created particle.
  15138. * @param worldMatrix is the world matrix of the particle system
  15139. * @param directionToUpdate is the direction vector to update with the result
  15140. * @param particle is the particle we are computed the direction for
  15141. */
  15142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15143. /**
  15144. * Called by the particle System when the position is computed for the created particle.
  15145. * @param worldMatrix is the world matrix of the particle system
  15146. * @param positionToUpdate is the position vector to update with the result
  15147. * @param particle is the particle we are computed the position for
  15148. */
  15149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15150. /**
  15151. * Clones the current emitter and returns a copy of it
  15152. * @returns the new emitter
  15153. */
  15154. clone(): ConeParticleEmitter;
  15155. /**
  15156. * Called by the GPUParticleSystem to setup the update shader
  15157. * @param effect defines the update shader
  15158. */
  15159. applyToShader(effect: Effect): void;
  15160. /**
  15161. * Returns a string to use to update the GPU particles update shader
  15162. * @returns a string containng the defines string
  15163. */
  15164. getEffectDefines(): string;
  15165. /**
  15166. * Returns the string "ConeParticleEmitter"
  15167. * @returns a string containing the class name
  15168. */
  15169. getClassName(): string;
  15170. /**
  15171. * Serializes the particle system to a JSON object.
  15172. * @returns the JSON object
  15173. */
  15174. serialize(): any;
  15175. /**
  15176. * Parse properties from a JSON object
  15177. * @param serializationObject defines the JSON object
  15178. */
  15179. parse(serializationObject: any): void;
  15180. }
  15181. }
  15182. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15183. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15184. import { Effect } from "babylonjs/Materials/effect";
  15185. import { Particle } from "babylonjs/Particles/particle";
  15186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15187. /**
  15188. * Particle emitter emitting particles from the inside of a cylinder.
  15189. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15190. */
  15191. export class CylinderParticleEmitter implements IParticleEmitterType {
  15192. /**
  15193. * The radius of the emission cylinder.
  15194. */
  15195. radius: number;
  15196. /**
  15197. * The height of the emission cylinder.
  15198. */
  15199. height: number;
  15200. /**
  15201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15202. */
  15203. radiusRange: number;
  15204. /**
  15205. * How much to randomize the particle direction [0-1].
  15206. */
  15207. directionRandomizer: number;
  15208. /**
  15209. * Creates a new instance CylinderParticleEmitter
  15210. * @param radius the radius of the emission cylinder (1 by default)
  15211. * @param height the height of the emission cylinder (1 by default)
  15212. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15213. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15214. */
  15215. constructor(
  15216. /**
  15217. * The radius of the emission cylinder.
  15218. */
  15219. radius?: number,
  15220. /**
  15221. * The height of the emission cylinder.
  15222. */
  15223. height?: number,
  15224. /**
  15225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15226. */
  15227. radiusRange?: number,
  15228. /**
  15229. * How much to randomize the particle direction [0-1].
  15230. */
  15231. directionRandomizer?: number);
  15232. /**
  15233. * Called by the particle System when the direction is computed for the created particle.
  15234. * @param worldMatrix is the world matrix of the particle system
  15235. * @param directionToUpdate is the direction vector to update with the result
  15236. * @param particle is the particle we are computed the direction for
  15237. */
  15238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15239. /**
  15240. * Called by the particle System when the position is computed for the created particle.
  15241. * @param worldMatrix is the world matrix of the particle system
  15242. * @param positionToUpdate is the position vector to update with the result
  15243. * @param particle is the particle we are computed the position for
  15244. */
  15245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15246. /**
  15247. * Clones the current emitter and returns a copy of it
  15248. * @returns the new emitter
  15249. */
  15250. clone(): CylinderParticleEmitter;
  15251. /**
  15252. * Called by the GPUParticleSystem to setup the update shader
  15253. * @param effect defines the update shader
  15254. */
  15255. applyToShader(effect: Effect): void;
  15256. /**
  15257. * Returns a string to use to update the GPU particles update shader
  15258. * @returns a string containng the defines string
  15259. */
  15260. getEffectDefines(): string;
  15261. /**
  15262. * Returns the string "CylinderParticleEmitter"
  15263. * @returns a string containing the class name
  15264. */
  15265. getClassName(): string;
  15266. /**
  15267. * Serializes the particle system to a JSON object.
  15268. * @returns the JSON object
  15269. */
  15270. serialize(): any;
  15271. /**
  15272. * Parse properties from a JSON object
  15273. * @param serializationObject defines the JSON object
  15274. */
  15275. parse(serializationObject: any): void;
  15276. }
  15277. /**
  15278. * Particle emitter emitting particles from the inside of a cylinder.
  15279. * It emits the particles randomly between two vectors.
  15280. */
  15281. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15282. /**
  15283. * The min limit of the emission direction.
  15284. */
  15285. direction1: Vector3;
  15286. /**
  15287. * The max limit of the emission direction.
  15288. */
  15289. direction2: Vector3;
  15290. /**
  15291. * Creates a new instance CylinderDirectedParticleEmitter
  15292. * @param radius the radius of the emission cylinder (1 by default)
  15293. * @param height the height of the emission cylinder (1 by default)
  15294. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15295. * @param direction1 the min limit of the emission direction (up vector by default)
  15296. * @param direction2 the max limit of the emission direction (up vector by default)
  15297. */
  15298. constructor(radius?: number, height?: number, radiusRange?: number,
  15299. /**
  15300. * The min limit of the emission direction.
  15301. */
  15302. direction1?: Vector3,
  15303. /**
  15304. * The max limit of the emission direction.
  15305. */
  15306. direction2?: Vector3);
  15307. /**
  15308. * Called by the particle System when the direction is computed for the created particle.
  15309. * @param worldMatrix is the world matrix of the particle system
  15310. * @param directionToUpdate is the direction vector to update with the result
  15311. * @param particle is the particle we are computed the direction for
  15312. */
  15313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15314. /**
  15315. * Clones the current emitter and returns a copy of it
  15316. * @returns the new emitter
  15317. */
  15318. clone(): CylinderDirectedParticleEmitter;
  15319. /**
  15320. * Called by the GPUParticleSystem to setup the update shader
  15321. * @param effect defines the update shader
  15322. */
  15323. applyToShader(effect: Effect): void;
  15324. /**
  15325. * Returns a string to use to update the GPU particles update shader
  15326. * @returns a string containng the defines string
  15327. */
  15328. getEffectDefines(): string;
  15329. /**
  15330. * Returns the string "CylinderDirectedParticleEmitter"
  15331. * @returns a string containing the class name
  15332. */
  15333. getClassName(): string;
  15334. /**
  15335. * Serializes the particle system to a JSON object.
  15336. * @returns the JSON object
  15337. */
  15338. serialize(): any;
  15339. /**
  15340. * Parse properties from a JSON object
  15341. * @param serializationObject defines the JSON object
  15342. */
  15343. parse(serializationObject: any): void;
  15344. }
  15345. }
  15346. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15347. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15348. import { Effect } from "babylonjs/Materials/effect";
  15349. import { Particle } from "babylonjs/Particles/particle";
  15350. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15351. /**
  15352. * Particle emitter emitting particles from the inside of a hemisphere.
  15353. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15354. */
  15355. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15356. /**
  15357. * The radius of the emission hemisphere.
  15358. */
  15359. radius: number;
  15360. /**
  15361. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15362. */
  15363. radiusRange: number;
  15364. /**
  15365. * How much to randomize the particle direction [0-1].
  15366. */
  15367. directionRandomizer: number;
  15368. /**
  15369. * Creates a new instance HemisphericParticleEmitter
  15370. * @param radius the radius of the emission hemisphere (1 by default)
  15371. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15372. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15373. */
  15374. constructor(
  15375. /**
  15376. * The radius of the emission hemisphere.
  15377. */
  15378. radius?: number,
  15379. /**
  15380. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15381. */
  15382. radiusRange?: number,
  15383. /**
  15384. * How much to randomize the particle direction [0-1].
  15385. */
  15386. directionRandomizer?: number);
  15387. /**
  15388. * Called by the particle System when the direction is computed for the created particle.
  15389. * @param worldMatrix is the world matrix of the particle system
  15390. * @param directionToUpdate is the direction vector to update with the result
  15391. * @param particle is the particle we are computed the direction for
  15392. */
  15393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15394. /**
  15395. * Called by the particle System when the position is computed for the created particle.
  15396. * @param worldMatrix is the world matrix of the particle system
  15397. * @param positionToUpdate is the position vector to update with the result
  15398. * @param particle is the particle we are computed the position for
  15399. */
  15400. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15401. /**
  15402. * Clones the current emitter and returns a copy of it
  15403. * @returns the new emitter
  15404. */
  15405. clone(): HemisphericParticleEmitter;
  15406. /**
  15407. * Called by the GPUParticleSystem to setup the update shader
  15408. * @param effect defines the update shader
  15409. */
  15410. applyToShader(effect: Effect): void;
  15411. /**
  15412. * Returns a string to use to update the GPU particles update shader
  15413. * @returns a string containng the defines string
  15414. */
  15415. getEffectDefines(): string;
  15416. /**
  15417. * Returns the string "HemisphericParticleEmitter"
  15418. * @returns a string containing the class name
  15419. */
  15420. getClassName(): string;
  15421. /**
  15422. * Serializes the particle system to a JSON object.
  15423. * @returns the JSON object
  15424. */
  15425. serialize(): any;
  15426. /**
  15427. * Parse properties from a JSON object
  15428. * @param serializationObject defines the JSON object
  15429. */
  15430. parse(serializationObject: any): void;
  15431. }
  15432. }
  15433. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15434. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15435. import { Effect } from "babylonjs/Materials/effect";
  15436. import { Particle } from "babylonjs/Particles/particle";
  15437. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15438. /**
  15439. * Particle emitter emitting particles from a point.
  15440. * It emits the particles randomly between 2 given directions.
  15441. */
  15442. export class PointParticleEmitter implements IParticleEmitterType {
  15443. /**
  15444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15445. */
  15446. direction1: Vector3;
  15447. /**
  15448. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15449. */
  15450. direction2: Vector3;
  15451. /**
  15452. * Creates a new instance PointParticleEmitter
  15453. */
  15454. constructor();
  15455. /**
  15456. * Called by the particle System when the direction is computed for the created particle.
  15457. * @param worldMatrix is the world matrix of the particle system
  15458. * @param directionToUpdate is the direction vector to update with the result
  15459. * @param particle is the particle we are computed the direction for
  15460. */
  15461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15462. /**
  15463. * Called by the particle System when the position is computed for the created particle.
  15464. * @param worldMatrix is the world matrix of the particle system
  15465. * @param positionToUpdate is the position vector to update with the result
  15466. * @param particle is the particle we are computed the position for
  15467. */
  15468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15469. /**
  15470. * Clones the current emitter and returns a copy of it
  15471. * @returns the new emitter
  15472. */
  15473. clone(): PointParticleEmitter;
  15474. /**
  15475. * Called by the GPUParticleSystem to setup the update shader
  15476. * @param effect defines the update shader
  15477. */
  15478. applyToShader(effect: Effect): void;
  15479. /**
  15480. * Returns a string to use to update the GPU particles update shader
  15481. * @returns a string containng the defines string
  15482. */
  15483. getEffectDefines(): string;
  15484. /**
  15485. * Returns the string "PointParticleEmitter"
  15486. * @returns a string containing the class name
  15487. */
  15488. getClassName(): string;
  15489. /**
  15490. * Serializes the particle system to a JSON object.
  15491. * @returns the JSON object
  15492. */
  15493. serialize(): any;
  15494. /**
  15495. * Parse properties from a JSON object
  15496. * @param serializationObject defines the JSON object
  15497. */
  15498. parse(serializationObject: any): void;
  15499. }
  15500. }
  15501. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15502. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15503. import { Effect } from "babylonjs/Materials/effect";
  15504. import { Particle } from "babylonjs/Particles/particle";
  15505. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15506. /**
  15507. * Particle emitter emitting particles from the inside of a sphere.
  15508. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15509. */
  15510. export class SphereParticleEmitter implements IParticleEmitterType {
  15511. /**
  15512. * The radius of the emission sphere.
  15513. */
  15514. radius: number;
  15515. /**
  15516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15517. */
  15518. radiusRange: number;
  15519. /**
  15520. * How much to randomize the particle direction [0-1].
  15521. */
  15522. directionRandomizer: number;
  15523. /**
  15524. * Creates a new instance SphereParticleEmitter
  15525. * @param radius the radius of the emission sphere (1 by default)
  15526. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15527. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15528. */
  15529. constructor(
  15530. /**
  15531. * The radius of the emission sphere.
  15532. */
  15533. radius?: number,
  15534. /**
  15535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15536. */
  15537. radiusRange?: number,
  15538. /**
  15539. * How much to randomize the particle direction [0-1].
  15540. */
  15541. directionRandomizer?: number);
  15542. /**
  15543. * Called by the particle System when the direction is computed for the created particle.
  15544. * @param worldMatrix is the world matrix of the particle system
  15545. * @param directionToUpdate is the direction vector to update with the result
  15546. * @param particle is the particle we are computed the direction for
  15547. */
  15548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15549. /**
  15550. * Called by the particle System when the position is computed for the created particle.
  15551. * @param worldMatrix is the world matrix of the particle system
  15552. * @param positionToUpdate is the position vector to update with the result
  15553. * @param particle is the particle we are computed the position for
  15554. */
  15555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15556. /**
  15557. * Clones the current emitter and returns a copy of it
  15558. * @returns the new emitter
  15559. */
  15560. clone(): SphereParticleEmitter;
  15561. /**
  15562. * Called by the GPUParticleSystem to setup the update shader
  15563. * @param effect defines the update shader
  15564. */
  15565. applyToShader(effect: Effect): void;
  15566. /**
  15567. * Returns a string to use to update the GPU particles update shader
  15568. * @returns a string containng the defines string
  15569. */
  15570. getEffectDefines(): string;
  15571. /**
  15572. * Returns the string "SphereParticleEmitter"
  15573. * @returns a string containing the class name
  15574. */
  15575. getClassName(): string;
  15576. /**
  15577. * Serializes the particle system to a JSON object.
  15578. * @returns the JSON object
  15579. */
  15580. serialize(): any;
  15581. /**
  15582. * Parse properties from a JSON object
  15583. * @param serializationObject defines the JSON object
  15584. */
  15585. parse(serializationObject: any): void;
  15586. }
  15587. /**
  15588. * Particle emitter emitting particles from the inside of a sphere.
  15589. * It emits the particles randomly between two vectors.
  15590. */
  15591. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15592. /**
  15593. * The min limit of the emission direction.
  15594. */
  15595. direction1: Vector3;
  15596. /**
  15597. * The max limit of the emission direction.
  15598. */
  15599. direction2: Vector3;
  15600. /**
  15601. * Creates a new instance SphereDirectedParticleEmitter
  15602. * @param radius the radius of the emission sphere (1 by default)
  15603. * @param direction1 the min limit of the emission direction (up vector by default)
  15604. * @param direction2 the max limit of the emission direction (up vector by default)
  15605. */
  15606. constructor(radius?: number,
  15607. /**
  15608. * The min limit of the emission direction.
  15609. */
  15610. direction1?: Vector3,
  15611. /**
  15612. * The max limit of the emission direction.
  15613. */
  15614. direction2?: Vector3);
  15615. /**
  15616. * Called by the particle System when the direction is computed for the created particle.
  15617. * @param worldMatrix is the world matrix of the particle system
  15618. * @param directionToUpdate is the direction vector to update with the result
  15619. * @param particle is the particle we are computed the direction for
  15620. */
  15621. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15622. /**
  15623. * Clones the current emitter and returns a copy of it
  15624. * @returns the new emitter
  15625. */
  15626. clone(): SphereDirectedParticleEmitter;
  15627. /**
  15628. * Called by the GPUParticleSystem to setup the update shader
  15629. * @param effect defines the update shader
  15630. */
  15631. applyToShader(effect: Effect): void;
  15632. /**
  15633. * Returns a string to use to update the GPU particles update shader
  15634. * @returns a string containng the defines string
  15635. */
  15636. getEffectDefines(): string;
  15637. /**
  15638. * Returns the string "SphereDirectedParticleEmitter"
  15639. * @returns a string containing the class name
  15640. */
  15641. getClassName(): string;
  15642. /**
  15643. * Serializes the particle system to a JSON object.
  15644. * @returns the JSON object
  15645. */
  15646. serialize(): any;
  15647. /**
  15648. * Parse properties from a JSON object
  15649. * @param serializationObject defines the JSON object
  15650. */
  15651. parse(serializationObject: any): void;
  15652. }
  15653. }
  15654. declare module "babylonjs/Particles/EmitterTypes/index" {
  15655. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15656. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15657. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15658. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15659. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15660. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15661. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15662. }
  15663. declare module "babylonjs/Particles/IParticleSystem" {
  15664. import { Nullable } from "babylonjs/types";
  15665. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15668. import { Texture } from "babylonjs/Materials/Textures/texture";
  15669. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15670. import { Scene } from "babylonjs/scene";
  15671. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15672. import { Animation } from "babylonjs/Animations/animation";
  15673. /**
  15674. * Interface representing a particle system in Babylon.js.
  15675. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15676. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15677. */
  15678. export interface IParticleSystem {
  15679. /**
  15680. * List of animations used by the particle system.
  15681. */
  15682. animations: Animation[];
  15683. /**
  15684. * The id of the Particle system.
  15685. */
  15686. id: string;
  15687. /**
  15688. * The name of the Particle system.
  15689. */
  15690. name: string;
  15691. /**
  15692. * The emitter represents the Mesh or position we are attaching the particle system to.
  15693. */
  15694. emitter: Nullable<AbstractMesh | Vector3>;
  15695. /**
  15696. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15697. */
  15698. isBillboardBased: boolean;
  15699. /**
  15700. * The rendering group used by the Particle system to chose when to render.
  15701. */
  15702. renderingGroupId: number;
  15703. /**
  15704. * The layer mask we are rendering the particles through.
  15705. */
  15706. layerMask: number;
  15707. /**
  15708. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15709. */
  15710. updateSpeed: number;
  15711. /**
  15712. * The amount of time the particle system is running (depends of the overall update speed).
  15713. */
  15714. targetStopDuration: number;
  15715. /**
  15716. * The texture used to render each particle. (this can be a spritesheet)
  15717. */
  15718. particleTexture: Nullable<Texture>;
  15719. /**
  15720. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15721. */
  15722. blendMode: number;
  15723. /**
  15724. * Minimum life time of emitting particles.
  15725. */
  15726. minLifeTime: number;
  15727. /**
  15728. * Maximum life time of emitting particles.
  15729. */
  15730. maxLifeTime: number;
  15731. /**
  15732. * Minimum Size of emitting particles.
  15733. */
  15734. minSize: number;
  15735. /**
  15736. * Maximum Size of emitting particles.
  15737. */
  15738. maxSize: number;
  15739. /**
  15740. * Minimum scale of emitting particles on X axis.
  15741. */
  15742. minScaleX: number;
  15743. /**
  15744. * Maximum scale of emitting particles on X axis.
  15745. */
  15746. maxScaleX: number;
  15747. /**
  15748. * Minimum scale of emitting particles on Y axis.
  15749. */
  15750. minScaleY: number;
  15751. /**
  15752. * Maximum scale of emitting particles on Y axis.
  15753. */
  15754. maxScaleY: number;
  15755. /**
  15756. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15757. */
  15758. color1: Color4;
  15759. /**
  15760. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15761. */
  15762. color2: Color4;
  15763. /**
  15764. * Color the particle will have at the end of its lifetime.
  15765. */
  15766. colorDead: Color4;
  15767. /**
  15768. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15769. */
  15770. emitRate: number;
  15771. /**
  15772. * You can use gravity if you want to give an orientation to your particles.
  15773. */
  15774. gravity: Vector3;
  15775. /**
  15776. * Minimum power of emitting particles.
  15777. */
  15778. minEmitPower: number;
  15779. /**
  15780. * Maximum power of emitting particles.
  15781. */
  15782. maxEmitPower: number;
  15783. /**
  15784. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15785. */
  15786. minAngularSpeed: number;
  15787. /**
  15788. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15789. */
  15790. maxAngularSpeed: number;
  15791. /**
  15792. * Gets or sets the minimal initial rotation in radians.
  15793. */
  15794. minInitialRotation: number;
  15795. /**
  15796. * Gets or sets the maximal initial rotation in radians.
  15797. */
  15798. maxInitialRotation: number;
  15799. /**
  15800. * The particle emitter type defines the emitter used by the particle system.
  15801. * It can be for example box, sphere, or cone...
  15802. */
  15803. particleEmitterType: Nullable<IParticleEmitterType>;
  15804. /**
  15805. * Defines the delay in milliseconds before starting the system (0 by default)
  15806. */
  15807. startDelay: number;
  15808. /**
  15809. * 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
  15810. */
  15811. preWarmCycles: number;
  15812. /**
  15813. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15814. */
  15815. preWarmStepOffset: number;
  15816. /**
  15817. * 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)
  15818. */
  15819. spriteCellChangeSpeed: number;
  15820. /**
  15821. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15822. */
  15823. startSpriteCellID: number;
  15824. /**
  15825. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15826. */
  15827. endSpriteCellID: number;
  15828. /**
  15829. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15830. */
  15831. spriteCellWidth: number;
  15832. /**
  15833. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15834. */
  15835. spriteCellHeight: number;
  15836. /**
  15837. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15838. */
  15839. spriteRandomStartCell: boolean;
  15840. /**
  15841. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15842. */
  15843. isAnimationSheetEnabled: boolean;
  15844. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15845. translationPivot: Vector2;
  15846. /**
  15847. * Gets or sets a texture used to add random noise to particle positions
  15848. */
  15849. noiseTexture: Nullable<BaseTexture>;
  15850. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15851. noiseStrength: Vector3;
  15852. /**
  15853. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15854. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15855. */
  15856. billboardMode: number;
  15857. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15858. limitVelocityDamping: number;
  15859. /**
  15860. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15861. */
  15862. beginAnimationOnStart: boolean;
  15863. /**
  15864. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15865. */
  15866. beginAnimationFrom: number;
  15867. /**
  15868. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15869. */
  15870. beginAnimationTo: number;
  15871. /**
  15872. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15873. */
  15874. beginAnimationLoop: boolean;
  15875. /**
  15876. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15877. */
  15878. disposeOnStop: boolean;
  15879. /**
  15880. * Gets the maximum number of particles active at the same time.
  15881. * @returns The max number of active particles.
  15882. */
  15883. getCapacity(): number;
  15884. /**
  15885. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15886. * @returns True if it has been started, otherwise false.
  15887. */
  15888. isStarted(): boolean;
  15889. /**
  15890. * Animates the particle system for this frame.
  15891. */
  15892. animate(): void;
  15893. /**
  15894. * Renders the particle system in its current state.
  15895. * @returns the current number of particles
  15896. */
  15897. render(): number;
  15898. /**
  15899. * Dispose the particle system and frees its associated resources.
  15900. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15901. */
  15902. dispose(disposeTexture?: boolean): void;
  15903. /**
  15904. * Clones the particle system.
  15905. * @param name The name of the cloned object
  15906. * @param newEmitter The new emitter to use
  15907. * @returns the cloned particle system
  15908. */
  15909. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15910. /**
  15911. * Serializes the particle system to a JSON object.
  15912. * @returns the JSON object
  15913. */
  15914. serialize(): any;
  15915. /**
  15916. * Rebuild the particle system
  15917. */
  15918. rebuild(): void;
  15919. /**
  15920. * Starts the particle system and begins to emit
  15921. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15922. */
  15923. start(delay?: number): void;
  15924. /**
  15925. * Stops the particle system.
  15926. */
  15927. stop(): void;
  15928. /**
  15929. * Remove all active particles
  15930. */
  15931. reset(): void;
  15932. /**
  15933. * Is this system ready to be used/rendered
  15934. * @return true if the system is ready
  15935. */
  15936. isReady(): boolean;
  15937. /**
  15938. * Adds a new color gradient
  15939. * @param gradient defines the gradient to use (between 0 and 1)
  15940. * @param color1 defines the color to affect to the specified gradient
  15941. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15942. * @returns the current particle system
  15943. */
  15944. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15945. /**
  15946. * Remove a specific color gradient
  15947. * @param gradient defines the gradient to remove
  15948. * @returns the current particle system
  15949. */
  15950. removeColorGradient(gradient: number): IParticleSystem;
  15951. /**
  15952. * Adds a new size gradient
  15953. * @param gradient defines the gradient to use (between 0 and 1)
  15954. * @param factor defines the size factor to affect to the specified gradient
  15955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15956. * @returns the current particle system
  15957. */
  15958. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15959. /**
  15960. * Remove a specific size gradient
  15961. * @param gradient defines the gradient to remove
  15962. * @returns the current particle system
  15963. */
  15964. removeSizeGradient(gradient: number): IParticleSystem;
  15965. /**
  15966. * Gets the current list of color gradients.
  15967. * You must use addColorGradient and removeColorGradient to udpate this list
  15968. * @returns the list of color gradients
  15969. */
  15970. getColorGradients(): Nullable<Array<ColorGradient>>;
  15971. /**
  15972. * Gets the current list of size gradients.
  15973. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15974. * @returns the list of size gradients
  15975. */
  15976. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15977. /**
  15978. * Gets the current list of angular speed gradients.
  15979. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15980. * @returns the list of angular speed gradients
  15981. */
  15982. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15983. /**
  15984. * Adds a new angular speed gradient
  15985. * @param gradient defines the gradient to use (between 0 and 1)
  15986. * @param factor defines the angular speed to affect to the specified gradient
  15987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15988. * @returns the current particle system
  15989. */
  15990. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15991. /**
  15992. * Remove a specific angular speed gradient
  15993. * @param gradient defines the gradient to remove
  15994. * @returns the current particle system
  15995. */
  15996. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15997. /**
  15998. * Gets the current list of velocity gradients.
  15999. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16000. * @returns the list of velocity gradients
  16001. */
  16002. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16003. /**
  16004. * Adds a new velocity gradient
  16005. * @param gradient defines the gradient to use (between 0 and 1)
  16006. * @param factor defines the velocity to affect to the specified gradient
  16007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16008. * @returns the current particle system
  16009. */
  16010. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16011. /**
  16012. * Remove a specific velocity gradient
  16013. * @param gradient defines the gradient to remove
  16014. * @returns the current particle system
  16015. */
  16016. removeVelocityGradient(gradient: number): IParticleSystem;
  16017. /**
  16018. * Gets the current list of limit velocity gradients.
  16019. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16020. * @returns the list of limit velocity gradients
  16021. */
  16022. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16023. /**
  16024. * Adds a new limit velocity gradient
  16025. * @param gradient defines the gradient to use (between 0 and 1)
  16026. * @param factor defines the limit velocity to affect to the specified gradient
  16027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16028. * @returns the current particle system
  16029. */
  16030. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16031. /**
  16032. * Remove a specific limit velocity gradient
  16033. * @param gradient defines the gradient to remove
  16034. * @returns the current particle system
  16035. */
  16036. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16037. /**
  16038. * Adds a new drag gradient
  16039. * @param gradient defines the gradient to use (between 0 and 1)
  16040. * @param factor defines the drag to affect to the specified gradient
  16041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16042. * @returns the current particle system
  16043. */
  16044. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16045. /**
  16046. * Remove a specific drag gradient
  16047. * @param gradient defines the gradient to remove
  16048. * @returns the current particle system
  16049. */
  16050. removeDragGradient(gradient: number): IParticleSystem;
  16051. /**
  16052. * Gets the current list of drag gradients.
  16053. * You must use addDragGradient and removeDragGradient to udpate this list
  16054. * @returns the list of drag gradients
  16055. */
  16056. getDragGradients(): Nullable<Array<FactorGradient>>;
  16057. /**
  16058. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16059. * @param gradient defines the gradient to use (between 0 and 1)
  16060. * @param factor defines the emit rate to affect to the specified gradient
  16061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16062. * @returns the current particle system
  16063. */
  16064. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16065. /**
  16066. * Remove a specific emit rate gradient
  16067. * @param gradient defines the gradient to remove
  16068. * @returns the current particle system
  16069. */
  16070. removeEmitRateGradient(gradient: number): IParticleSystem;
  16071. /**
  16072. * Gets the current list of emit rate gradients.
  16073. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16074. * @returns the list of emit rate gradients
  16075. */
  16076. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16077. /**
  16078. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16079. * @param gradient defines the gradient to use (between 0 and 1)
  16080. * @param factor defines the start size to affect to the specified gradient
  16081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16082. * @returns the current particle system
  16083. */
  16084. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16085. /**
  16086. * Remove a specific start size gradient
  16087. * @param gradient defines the gradient to remove
  16088. * @returns the current particle system
  16089. */
  16090. removeStartSizeGradient(gradient: number): IParticleSystem;
  16091. /**
  16092. * Gets the current list of start size gradients.
  16093. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16094. * @returns the list of start size gradients
  16095. */
  16096. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16097. /**
  16098. * Adds a new life time gradient
  16099. * @param gradient defines the gradient to use (between 0 and 1)
  16100. * @param factor defines the life time factor to affect to the specified gradient
  16101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16102. * @returns the current particle system
  16103. */
  16104. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16105. /**
  16106. * Remove a specific life time gradient
  16107. * @param gradient defines the gradient to remove
  16108. * @returns the current particle system
  16109. */
  16110. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16111. /**
  16112. * Gets the current list of life time gradients.
  16113. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16114. * @returns the list of life time gradients
  16115. */
  16116. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16117. /**
  16118. * Gets the current list of color gradients.
  16119. * You must use addColorGradient and removeColorGradient to udpate this list
  16120. * @returns the list of color gradients
  16121. */
  16122. getColorGradients(): Nullable<Array<ColorGradient>>;
  16123. /**
  16124. * Adds a new ramp gradient used to remap particle colors
  16125. * @param gradient defines the gradient to use (between 0 and 1)
  16126. * @param color defines the color to affect to the specified gradient
  16127. * @returns the current particle system
  16128. */
  16129. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16130. /**
  16131. * Gets the current list of ramp gradients.
  16132. * You must use addRampGradient and removeRampGradient to udpate this list
  16133. * @returns the list of ramp gradients
  16134. */
  16135. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16136. /** Gets or sets a boolean indicating that ramp gradients must be used
  16137. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16138. */
  16139. useRampGradients: boolean;
  16140. /**
  16141. * Adds a new color remap gradient
  16142. * @param gradient defines the gradient to use (between 0 and 1)
  16143. * @param min defines the color remap minimal range
  16144. * @param max defines the color remap maximal range
  16145. * @returns the current particle system
  16146. */
  16147. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16148. /**
  16149. * Gets the current list of color remap gradients.
  16150. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16151. * @returns the list of color remap gradients
  16152. */
  16153. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16154. /**
  16155. * Adds a new alpha remap gradient
  16156. * @param gradient defines the gradient to use (between 0 and 1)
  16157. * @param min defines the alpha remap minimal range
  16158. * @param max defines the alpha remap maximal range
  16159. * @returns the current particle system
  16160. */
  16161. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16162. /**
  16163. * Gets the current list of alpha remap gradients.
  16164. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16165. * @returns the list of alpha remap gradients
  16166. */
  16167. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16168. /**
  16169. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16170. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16171. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16172. * @returns the emitter
  16173. */
  16174. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16175. /**
  16176. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16177. * @param radius The radius of the hemisphere to emit from
  16178. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16179. * @returns the emitter
  16180. */
  16181. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16182. /**
  16183. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16184. * @param radius The radius of the sphere to emit from
  16185. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16186. * @returns the emitter
  16187. */
  16188. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16189. /**
  16190. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16191. * @param radius The radius of the sphere to emit from
  16192. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16193. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16194. * @returns the emitter
  16195. */
  16196. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16197. /**
  16198. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16199. * @param radius The radius of the emission cylinder
  16200. * @param height The height of the emission cylinder
  16201. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16202. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16203. * @returns the emitter
  16204. */
  16205. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16206. /**
  16207. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16208. * @param radius The radius of the cylinder to emit from
  16209. * @param height The height of the emission cylinder
  16210. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16213. * @returns the emitter
  16214. */
  16215. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16216. /**
  16217. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16218. * @param radius The radius of the cone to emit from
  16219. * @param angle The base angle of the cone
  16220. * @returns the emitter
  16221. */
  16222. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16223. /**
  16224. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16225. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16226. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16227. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16228. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16229. * @returns the emitter
  16230. */
  16231. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16232. /**
  16233. * Get hosting scene
  16234. * @returns the scene
  16235. */
  16236. getScene(): Scene;
  16237. }
  16238. }
  16239. declare module "babylonjs/Meshes/instancedMesh" {
  16240. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16241. import { Vector3 } from "babylonjs/Maths/math";
  16242. import { Camera } from "babylonjs/Cameras/camera";
  16243. import { Node } from "babylonjs/node";
  16244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16245. import { Mesh } from "babylonjs/Meshes/mesh";
  16246. import { Material } from "babylonjs/Materials/material";
  16247. import { Skeleton } from "babylonjs/Bones/skeleton";
  16248. /**
  16249. * Creates an instance based on a source mesh.
  16250. */
  16251. export class InstancedMesh extends AbstractMesh {
  16252. private _sourceMesh;
  16253. private _currentLOD;
  16254. /** @hidden */
  16255. _indexInSourceMeshInstanceArray: number;
  16256. constructor(name: string, source: Mesh);
  16257. /**
  16258. * Returns the string "InstancedMesh".
  16259. */
  16260. getClassName(): string;
  16261. /**
  16262. * If the source mesh receives shadows
  16263. */
  16264. readonly receiveShadows: boolean;
  16265. /**
  16266. * The material of the source mesh
  16267. */
  16268. readonly material: Nullable<Material>;
  16269. /**
  16270. * Visibility of the source mesh
  16271. */
  16272. readonly visibility: number;
  16273. /**
  16274. * Skeleton of the source mesh
  16275. */
  16276. readonly skeleton: Nullable<Skeleton>;
  16277. /**
  16278. * Rendering ground id of the source mesh
  16279. */
  16280. renderingGroupId: number;
  16281. /**
  16282. * Returns the total number of vertices (integer).
  16283. */
  16284. getTotalVertices(): number;
  16285. /**
  16286. * Returns a positive integer : the total number of indices in this mesh geometry.
  16287. * @returns the numner of indices or zero if the mesh has no geometry.
  16288. */
  16289. getTotalIndices(): number;
  16290. /**
  16291. * The source mesh of the instance
  16292. */
  16293. readonly sourceMesh: Mesh;
  16294. /**
  16295. * Is this node ready to be used/rendered
  16296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16297. * @return {boolean} is it ready
  16298. */
  16299. isReady(completeCheck?: boolean): boolean;
  16300. /**
  16301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16302. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16303. * @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.
  16304. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16305. */
  16306. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16307. /**
  16308. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16309. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16310. * The `data` are either a numeric array either a Float32Array.
  16311. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16312. * 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).
  16313. * Note that a new underlying VertexBuffer object is created each call.
  16314. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16315. *
  16316. * Possible `kind` values :
  16317. * - VertexBuffer.PositionKind
  16318. * - VertexBuffer.UVKind
  16319. * - VertexBuffer.UV2Kind
  16320. * - VertexBuffer.UV3Kind
  16321. * - VertexBuffer.UV4Kind
  16322. * - VertexBuffer.UV5Kind
  16323. * - VertexBuffer.UV6Kind
  16324. * - VertexBuffer.ColorKind
  16325. * - VertexBuffer.MatricesIndicesKind
  16326. * - VertexBuffer.MatricesIndicesExtraKind
  16327. * - VertexBuffer.MatricesWeightsKind
  16328. * - VertexBuffer.MatricesWeightsExtraKind
  16329. *
  16330. * Returns the Mesh.
  16331. */
  16332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16333. /**
  16334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16335. * If the mesh has no geometry, it is simply returned as it is.
  16336. * The `data` are either a numeric array either a Float32Array.
  16337. * No new underlying VertexBuffer object is created.
  16338. * 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.
  16339. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16340. *
  16341. * Possible `kind` values :
  16342. * - VertexBuffer.PositionKind
  16343. * - VertexBuffer.UVKind
  16344. * - VertexBuffer.UV2Kind
  16345. * - VertexBuffer.UV3Kind
  16346. * - VertexBuffer.UV4Kind
  16347. * - VertexBuffer.UV5Kind
  16348. * - VertexBuffer.UV6Kind
  16349. * - VertexBuffer.ColorKind
  16350. * - VertexBuffer.MatricesIndicesKind
  16351. * - VertexBuffer.MatricesIndicesExtraKind
  16352. * - VertexBuffer.MatricesWeightsKind
  16353. * - VertexBuffer.MatricesWeightsExtraKind
  16354. *
  16355. * Returns the Mesh.
  16356. */
  16357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16358. /**
  16359. * Sets the mesh indices.
  16360. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16362. * This method creates a new index buffer each call.
  16363. * Returns the Mesh.
  16364. */
  16365. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16366. /**
  16367. * Boolean : True if the mesh owns the requested kind of data.
  16368. */
  16369. isVerticesDataPresent(kind: string): boolean;
  16370. /**
  16371. * Returns an array of indices (IndicesArray).
  16372. */
  16373. getIndices(): Nullable<IndicesArray>;
  16374. readonly _positions: Nullable<Vector3[]>;
  16375. /**
  16376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16377. * This means the mesh underlying bounding box and sphere are recomputed.
  16378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16379. * @returns the current mesh
  16380. */
  16381. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16382. /** @hidden */
  16383. _preActivate(): InstancedMesh;
  16384. /** @hidden */
  16385. _activate(renderId: number): InstancedMesh;
  16386. /**
  16387. * Returns the current associated LOD AbstractMesh.
  16388. */
  16389. getLOD(camera: Camera): AbstractMesh;
  16390. /** @hidden */
  16391. _syncSubMeshes(): InstancedMesh;
  16392. /** @hidden */
  16393. _generatePointsArray(): boolean;
  16394. /**
  16395. * Creates a new InstancedMesh from the current mesh.
  16396. * - name (string) : the cloned mesh name
  16397. * - newParent (optional Node) : the optional Node to parent the clone to.
  16398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16399. *
  16400. * Returns the clone.
  16401. */
  16402. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16403. /**
  16404. * Disposes the InstancedMesh.
  16405. * Returns nothing.
  16406. */
  16407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Materials/shaderMaterial" {
  16411. import { Scene } from "babylonjs/scene";
  16412. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16414. import { Mesh } from "babylonjs/Meshes/mesh";
  16415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16416. import { Texture } from "babylonjs/Materials/Textures/texture";
  16417. import { Material } from "babylonjs/Materials/material";
  16418. /**
  16419. * Defines the options associated with the creation of a shader material.
  16420. */
  16421. export interface IShaderMaterialOptions {
  16422. /**
  16423. * Does the material work in alpha blend mode
  16424. */
  16425. needAlphaBlending: boolean;
  16426. /**
  16427. * Does the material work in alpha test mode
  16428. */
  16429. needAlphaTesting: boolean;
  16430. /**
  16431. * The list of attribute names used in the shader
  16432. */
  16433. attributes: string[];
  16434. /**
  16435. * The list of unifrom names used in the shader
  16436. */
  16437. uniforms: string[];
  16438. /**
  16439. * The list of UBO names used in the shader
  16440. */
  16441. uniformBuffers: string[];
  16442. /**
  16443. * The list of sampler names used in the shader
  16444. */
  16445. samplers: string[];
  16446. /**
  16447. * The list of defines used in the shader
  16448. */
  16449. defines: string[];
  16450. }
  16451. /**
  16452. * 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.
  16453. *
  16454. * This returned material effects how the mesh will look based on the code in the shaders.
  16455. *
  16456. * @see http://doc.babylonjs.com/how_to/shader_material
  16457. */
  16458. export class ShaderMaterial extends Material {
  16459. private _shaderPath;
  16460. private _options;
  16461. private _textures;
  16462. private _textureArrays;
  16463. private _floats;
  16464. private _ints;
  16465. private _floatsArrays;
  16466. private _colors3;
  16467. private _colors3Arrays;
  16468. private _colors4;
  16469. private _vectors2;
  16470. private _vectors3;
  16471. private _vectors4;
  16472. private _matrices;
  16473. private _matrices3x3;
  16474. private _matrices2x2;
  16475. private _vectors2Arrays;
  16476. private _vectors3Arrays;
  16477. private _cachedWorldViewMatrix;
  16478. private _renderId;
  16479. /**
  16480. * Instantiate a new shader material.
  16481. * 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.
  16482. * This returned material effects how the mesh will look based on the code in the shaders.
  16483. * @see http://doc.babylonjs.com/how_to/shader_material
  16484. * @param name Define the name of the material in the scene
  16485. * @param scene Define the scene the material belongs to
  16486. * @param shaderPath Defines the route to the shader code in one of three ways:
  16487. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16488. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16489. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16490. * @param options Define the options used to create the shader
  16491. */
  16492. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16493. /**
  16494. * Gets the current class name of the material e.g. "ShaderMaterial"
  16495. * Mainly use in serialization.
  16496. * @returns the class name
  16497. */
  16498. getClassName(): string;
  16499. /**
  16500. * Specifies if the material will require alpha blending
  16501. * @returns a boolean specifying if alpha blending is needed
  16502. */
  16503. needAlphaBlending(): boolean;
  16504. /**
  16505. * Specifies if this material should be rendered in alpha test mode
  16506. * @returns a boolean specifying if an alpha test is needed.
  16507. */
  16508. needAlphaTesting(): boolean;
  16509. private _checkUniform;
  16510. /**
  16511. * Set a texture in the shader.
  16512. * @param name Define the name of the uniform samplers as defined in the shader
  16513. * @param texture Define the texture to bind to this sampler
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setTexture(name: string, texture: Texture): ShaderMaterial;
  16517. /**
  16518. * Set a texture array in the shader.
  16519. * @param name Define the name of the uniform sampler array as defined in the shader
  16520. * @param textures Define the list of textures to bind to this sampler
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16524. /**
  16525. * Set a float in the shader.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setFloat(name: string, value: number): ShaderMaterial;
  16531. /**
  16532. * Set a int in the shader.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setInt(name: string, value: number): ShaderMaterial;
  16538. /**
  16539. * Set an array of floats in the shader.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setFloats(name: string, value: number[]): ShaderMaterial;
  16545. /**
  16546. * Set a vec3 in the shader from a Color3.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setColor3(name: string, value: Color3): ShaderMaterial;
  16552. /**
  16553. * Set a vec3 array in the shader from a Color3 array.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16559. /**
  16560. * Set a vec4 in the shader from a Color4.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setColor4(name: string, value: Color4): ShaderMaterial;
  16566. /**
  16567. * Set a vec2 in the shader from a Vector2.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setVector2(name: string, value: Vector2): ShaderMaterial;
  16573. /**
  16574. * Set a vec3 in the shader from a Vector3.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setVector3(name: string, value: Vector3): ShaderMaterial;
  16580. /**
  16581. * Set a vec4 in the shader from a Vector4.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setVector4(name: string, value: Vector4): ShaderMaterial;
  16587. /**
  16588. * Set a mat4 in the shader from a Matrix.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the material itself allowing "fluent" like uniform updates
  16592. */
  16593. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16594. /**
  16595. * Set a mat3 in the shader from a Float32Array.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the material itself allowing "fluent" like uniform updates
  16599. */
  16600. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16601. /**
  16602. * Set a mat2 in the shader from a Float32Array.
  16603. * @param name Define the name of the uniform as defined in the shader
  16604. * @param value Define the value to give to the uniform
  16605. * @return the material itself allowing "fluent" like uniform updates
  16606. */
  16607. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16608. /**
  16609. * Set a vec2 array in the shader from a number array.
  16610. * @param name Define the name of the uniform as defined in the shader
  16611. * @param value Define the value to give to the uniform
  16612. * @return the material itself allowing "fluent" like uniform updates
  16613. */
  16614. setArray2(name: string, value: number[]): ShaderMaterial;
  16615. /**
  16616. * Set a vec3 array in the shader from a number array.
  16617. * @param name Define the name of the uniform as defined in the shader
  16618. * @param value Define the value to give to the uniform
  16619. * @return the material itself allowing "fluent" like uniform updates
  16620. */
  16621. setArray3(name: string, value: number[]): ShaderMaterial;
  16622. private _checkCache;
  16623. /**
  16624. * Checks if the material is ready to render the requested mesh
  16625. * @param mesh Define the mesh to render
  16626. * @param useInstances Define whether or not the material is used with instances
  16627. * @returns true if ready, otherwise false
  16628. */
  16629. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16630. /**
  16631. * Binds the world matrix to the material
  16632. * @param world defines the world transformation matrix
  16633. */
  16634. bindOnlyWorldMatrix(world: Matrix): void;
  16635. /**
  16636. * Binds the material to the mesh
  16637. * @param world defines the world transformation matrix
  16638. * @param mesh defines the mesh to bind the material to
  16639. */
  16640. bind(world: Matrix, mesh?: Mesh): void;
  16641. /**
  16642. * Gets the active textures from the material
  16643. * @returns an array of textures
  16644. */
  16645. getActiveTextures(): BaseTexture[];
  16646. /**
  16647. * Specifies if the material uses a texture
  16648. * @param texture defines the texture to check against the material
  16649. * @returns a boolean specifying if the material uses the texture
  16650. */
  16651. hasTexture(texture: BaseTexture): boolean;
  16652. /**
  16653. * Makes a duplicate of the material, and gives it a new name
  16654. * @param name defines the new name for the duplicated material
  16655. * @returns the cloned material
  16656. */
  16657. clone(name: string): ShaderMaterial;
  16658. /**
  16659. * Disposes the material
  16660. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16661. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16662. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16663. */
  16664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16665. /**
  16666. * Serializes this material in a JSON representation
  16667. * @returns the serialized material object
  16668. */
  16669. serialize(): any;
  16670. /**
  16671. * Creates a shader material from parsed shader material data
  16672. * @param source defines the JSON represnetation of the material
  16673. * @param scene defines the hosting scene
  16674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16675. * @returns a new material
  16676. */
  16677. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16678. }
  16679. }
  16680. declare module "babylonjs/Shaders/color.fragment" {
  16681. /** @hidden */
  16682. export var colorPixelShader: {
  16683. name: string;
  16684. shader: string;
  16685. };
  16686. }
  16687. declare module "babylonjs/Shaders/color.vertex" {
  16688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16690. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16691. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16692. /** @hidden */
  16693. export var colorVertexShader: {
  16694. name: string;
  16695. shader: string;
  16696. };
  16697. }
  16698. declare module "babylonjs/Meshes/linesMesh" {
  16699. import { Nullable } from "babylonjs/types";
  16700. import { Scene } from "babylonjs/scene";
  16701. import { Color3 } from "babylonjs/Maths/math";
  16702. import { Node } from "babylonjs/node";
  16703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16704. import { Mesh } from "babylonjs/Meshes/mesh";
  16705. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16706. import { Effect } from "babylonjs/Materials/effect";
  16707. import { Material } from "babylonjs/Materials/material";
  16708. import "babylonjs/Shaders/color.fragment";
  16709. import "babylonjs/Shaders/color.vertex";
  16710. /**
  16711. * Line mesh
  16712. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16713. */
  16714. export class LinesMesh extends Mesh {
  16715. /**
  16716. * If vertex color should be applied to the mesh
  16717. */
  16718. useVertexColor?: boolean | undefined;
  16719. /**
  16720. * If vertex alpha should be applied to the mesh
  16721. */
  16722. useVertexAlpha?: boolean | undefined;
  16723. /**
  16724. * Color of the line (Default: White)
  16725. */
  16726. color: Color3;
  16727. /**
  16728. * Alpha of the line (Default: 1)
  16729. */
  16730. alpha: number;
  16731. /**
  16732. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16733. * This margin is expressed in world space coordinates, so its value may vary.
  16734. * Default value is 0.1
  16735. */
  16736. intersectionThreshold: number;
  16737. private _colorShader;
  16738. /**
  16739. * Creates a new LinesMesh
  16740. * @param name defines the name
  16741. * @param scene defines the hosting scene
  16742. * @param parent defines the parent mesh if any
  16743. * @param source defines the optional source LinesMesh used to clone data from
  16744. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16745. * When false, achieved by calling a clone(), also passing False.
  16746. * This will make creation of children, recursive.
  16747. * @param useVertexColor defines if this LinesMesh supports vertex color
  16748. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16749. */
  16750. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16751. /**
  16752. * If vertex color should be applied to the mesh
  16753. */
  16754. useVertexColor?: boolean | undefined,
  16755. /**
  16756. * If vertex alpha should be applied to the mesh
  16757. */
  16758. useVertexAlpha?: boolean | undefined);
  16759. /**
  16760. * Returns the string "LineMesh"
  16761. */
  16762. getClassName(): string;
  16763. /**
  16764. * @hidden
  16765. */
  16766. /**
  16767. * @hidden
  16768. */
  16769. material: Material;
  16770. /**
  16771. * @hidden
  16772. */
  16773. readonly checkCollisions: boolean;
  16774. /** @hidden */
  16775. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16776. /** @hidden */
  16777. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16778. /**
  16779. * Disposes of the line mesh
  16780. * @param doNotRecurse If children should be disposed
  16781. */
  16782. dispose(doNotRecurse?: boolean): void;
  16783. /**
  16784. * Returns a new LineMesh object cloned from the current one.
  16785. */
  16786. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16787. /**
  16788. * Creates a new InstancedLinesMesh object from the mesh model.
  16789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16790. * @param name defines the name of the new instance
  16791. * @returns a new InstancedLinesMesh
  16792. */
  16793. createInstance(name: string): InstancedLinesMesh;
  16794. }
  16795. /**
  16796. * Creates an instance based on a source LinesMesh
  16797. */
  16798. export class InstancedLinesMesh extends InstancedMesh {
  16799. /**
  16800. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16801. * This margin is expressed in world space coordinates, so its value may vary.
  16802. * Initilized with the intersectionThreshold value of the source LinesMesh
  16803. */
  16804. intersectionThreshold: number;
  16805. constructor(name: string, source: LinesMesh);
  16806. /**
  16807. * Returns the string "InstancedLinesMesh".
  16808. */
  16809. getClassName(): string;
  16810. }
  16811. }
  16812. declare module "babylonjs/Shaders/line.fragment" {
  16813. /** @hidden */
  16814. export var linePixelShader: {
  16815. name: string;
  16816. shader: string;
  16817. };
  16818. }
  16819. declare module "babylonjs/Shaders/line.vertex" {
  16820. /** @hidden */
  16821. export var lineVertexShader: {
  16822. name: string;
  16823. shader: string;
  16824. };
  16825. }
  16826. declare module "babylonjs/Rendering/edgesRenderer" {
  16827. import { Nullable } from "babylonjs/types";
  16828. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16830. import { Vector3 } from "babylonjs/Maths/math";
  16831. import { IDisposable } from "babylonjs/scene";
  16832. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16833. import "babylonjs/Shaders/line.fragment";
  16834. import "babylonjs/Shaders/line.vertex";
  16835. module "babylonjs/Meshes/abstractMesh" {
  16836. interface AbstractMesh {
  16837. /**
  16838. * Disables the mesh edge rendering mode
  16839. * @returns the currentAbstractMesh
  16840. */
  16841. disableEdgesRendering(): AbstractMesh;
  16842. /**
  16843. * Enables the edge rendering mode on the mesh.
  16844. * This mode makes the mesh edges visible
  16845. * @param epsilon defines the maximal distance between two angles to detect a face
  16846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16847. * @returns the currentAbstractMesh
  16848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16849. */
  16850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16851. /**
  16852. * Gets the edgesRenderer associated with the mesh
  16853. */
  16854. edgesRenderer: Nullable<EdgesRenderer>;
  16855. }
  16856. }
  16857. module "babylonjs/Meshes/linesMesh" {
  16858. interface LinesMesh {
  16859. /**
  16860. * Enables the edge rendering mode on the mesh.
  16861. * This mode makes the mesh edges visible
  16862. * @param epsilon defines the maximal distance between two angles to detect a face
  16863. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16864. * @returns the currentAbstractMesh
  16865. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16866. */
  16867. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16868. }
  16869. }
  16870. module "babylonjs/Meshes/linesMesh" {
  16871. interface InstancedLinesMesh {
  16872. /**
  16873. * Enables the edge rendering mode on the mesh.
  16874. * This mode makes the mesh edges visible
  16875. * @param epsilon defines the maximal distance between two angles to detect a face
  16876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16877. * @returns the current InstancedLinesMesh
  16878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16879. */
  16880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16881. }
  16882. }
  16883. /**
  16884. * Defines the minimum contract an Edges renderer should follow.
  16885. */
  16886. export interface IEdgesRenderer extends IDisposable {
  16887. /**
  16888. * Gets or sets a boolean indicating if the edgesRenderer is active
  16889. */
  16890. isEnabled: boolean;
  16891. /**
  16892. * Renders the edges of the attached mesh,
  16893. */
  16894. render(): void;
  16895. /**
  16896. * Checks wether or not the edges renderer is ready to render.
  16897. * @return true if ready, otherwise false.
  16898. */
  16899. isReady(): boolean;
  16900. }
  16901. /**
  16902. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16903. */
  16904. export class EdgesRenderer implements IEdgesRenderer {
  16905. /**
  16906. * Define the size of the edges with an orthographic camera
  16907. */
  16908. edgesWidthScalerForOrthographic: number;
  16909. /**
  16910. * Define the size of the edges with a perspective camera
  16911. */
  16912. edgesWidthScalerForPerspective: number;
  16913. protected _source: AbstractMesh;
  16914. protected _linesPositions: number[];
  16915. protected _linesNormals: number[];
  16916. protected _linesIndices: number[];
  16917. protected _epsilon: number;
  16918. protected _indicesCount: number;
  16919. protected _lineShader: ShaderMaterial;
  16920. protected _ib: WebGLBuffer;
  16921. protected _buffers: {
  16922. [key: string]: Nullable<VertexBuffer>;
  16923. };
  16924. protected _checkVerticesInsteadOfIndices: boolean;
  16925. private _meshRebuildObserver;
  16926. private _meshDisposeObserver;
  16927. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16928. isEnabled: boolean;
  16929. /**
  16930. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16931. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16932. * @param source Mesh used to create edges
  16933. * @param epsilon sum of angles in adjacency to check for edge
  16934. * @param checkVerticesInsteadOfIndices
  16935. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16936. */
  16937. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16938. protected _prepareRessources(): void;
  16939. /** @hidden */
  16940. _rebuild(): void;
  16941. /**
  16942. * Releases the required resources for the edges renderer
  16943. */
  16944. dispose(): void;
  16945. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16946. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16947. /**
  16948. * Checks if the pair of p0 and p1 is en edge
  16949. * @param faceIndex
  16950. * @param edge
  16951. * @param faceNormals
  16952. * @param p0
  16953. * @param p1
  16954. * @private
  16955. */
  16956. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16957. /**
  16958. * push line into the position, normal and index buffer
  16959. * @protected
  16960. */
  16961. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16962. /**
  16963. * Generates lines edges from adjacencjes
  16964. * @private
  16965. */
  16966. _generateEdgesLines(): void;
  16967. /**
  16968. * Checks wether or not the edges renderer is ready to render.
  16969. * @return true if ready, otherwise false.
  16970. */
  16971. isReady(): boolean;
  16972. /**
  16973. * Renders the edges of the attached mesh,
  16974. */
  16975. render(): void;
  16976. }
  16977. /**
  16978. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16979. */
  16980. export class LineEdgesRenderer extends EdgesRenderer {
  16981. /**
  16982. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16983. * @param source LineMesh used to generate edges
  16984. * @param epsilon not important (specified angle for edge detection)
  16985. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16986. */
  16987. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16988. /**
  16989. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16990. */
  16991. _generateEdgesLines(): void;
  16992. }
  16993. }
  16994. declare module "babylonjs/Rendering/renderingGroup" {
  16995. import { SmartArray } from "babylonjs/Misc/smartArray";
  16996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16998. import { Nullable } from "babylonjs/types";
  16999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17000. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17001. import { Material } from "babylonjs/Materials/material";
  17002. import { Scene } from "babylonjs/scene";
  17003. /**
  17004. * This represents the object necessary to create a rendering group.
  17005. * This is exclusively used and created by the rendering manager.
  17006. * To modify the behavior, you use the available helpers in your scene or meshes.
  17007. * @hidden
  17008. */
  17009. export class RenderingGroup {
  17010. index: number;
  17011. private _scene;
  17012. private _opaqueSubMeshes;
  17013. private _transparentSubMeshes;
  17014. private _alphaTestSubMeshes;
  17015. private _depthOnlySubMeshes;
  17016. private _particleSystems;
  17017. private _spriteManagers;
  17018. private _opaqueSortCompareFn;
  17019. private _alphaTestSortCompareFn;
  17020. private _transparentSortCompareFn;
  17021. private _renderOpaque;
  17022. private _renderAlphaTest;
  17023. private _renderTransparent;
  17024. private _edgesRenderers;
  17025. onBeforeTransparentRendering: () => void;
  17026. /**
  17027. * Set the opaque sort comparison function.
  17028. * If null the sub meshes will be render in the order they were created
  17029. */
  17030. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17031. /**
  17032. * Set the alpha test sort comparison function.
  17033. * If null the sub meshes will be render in the order they were created
  17034. */
  17035. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17036. /**
  17037. * Set the transparent sort comparison function.
  17038. * If null the sub meshes will be render in the order they were created
  17039. */
  17040. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17041. /**
  17042. * Creates a new rendering group.
  17043. * @param index The rendering group index
  17044. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17045. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17046. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17047. */
  17048. 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>);
  17049. /**
  17050. * Render all the sub meshes contained in the group.
  17051. * @param customRenderFunction Used to override the default render behaviour of the group.
  17052. * @returns true if rendered some submeshes.
  17053. */
  17054. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17055. /**
  17056. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17057. * @param subMeshes The submeshes to render
  17058. */
  17059. private renderOpaqueSorted;
  17060. /**
  17061. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17062. * @param subMeshes The submeshes to render
  17063. */
  17064. private renderAlphaTestSorted;
  17065. /**
  17066. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17067. * @param subMeshes The submeshes to render
  17068. */
  17069. private renderTransparentSorted;
  17070. /**
  17071. * Renders the submeshes in a specified order.
  17072. * @param subMeshes The submeshes to sort before render
  17073. * @param sortCompareFn The comparison function use to sort
  17074. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17075. * @param transparent Specifies to activate blending if true
  17076. */
  17077. private static renderSorted;
  17078. /**
  17079. * Renders the submeshes in the order they were dispatched (no sort applied).
  17080. * @param subMeshes The submeshes to render
  17081. */
  17082. private static renderUnsorted;
  17083. /**
  17084. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17085. * are rendered back to front if in the same alpha index.
  17086. *
  17087. * @param a The first submesh
  17088. * @param b The second submesh
  17089. * @returns The result of the comparison
  17090. */
  17091. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17092. /**
  17093. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17094. * are rendered back to front.
  17095. *
  17096. * @param a The first submesh
  17097. * @param b The second submesh
  17098. * @returns The result of the comparison
  17099. */
  17100. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17101. /**
  17102. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17103. * are rendered front to back (prevent overdraw).
  17104. *
  17105. * @param a The first submesh
  17106. * @param b The second submesh
  17107. * @returns The result of the comparison
  17108. */
  17109. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17110. /**
  17111. * Resets the different lists of submeshes to prepare a new frame.
  17112. */
  17113. prepare(): void;
  17114. dispose(): void;
  17115. /**
  17116. * Inserts the submesh in its correct queue depending on its material.
  17117. * @param subMesh The submesh to dispatch
  17118. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17119. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17120. */
  17121. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17122. dispatchSprites(spriteManager: ISpriteManager): void;
  17123. dispatchParticles(particleSystem: IParticleSystem): void;
  17124. private _renderParticles;
  17125. private _renderSprites;
  17126. }
  17127. }
  17128. declare module "babylonjs/Rendering/renderingManager" {
  17129. import { Nullable } from "babylonjs/types";
  17130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17131. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17132. import { SmartArray } from "babylonjs/Misc/smartArray";
  17133. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17134. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17135. import { Material } from "babylonjs/Materials/material";
  17136. import { Scene } from "babylonjs/scene";
  17137. import { Camera } from "babylonjs/Cameras/camera";
  17138. /**
  17139. * Interface describing the different options available in the rendering manager
  17140. * regarding Auto Clear between groups.
  17141. */
  17142. export interface IRenderingManagerAutoClearSetup {
  17143. /**
  17144. * Defines whether or not autoclear is enable.
  17145. */
  17146. autoClear: boolean;
  17147. /**
  17148. * Defines whether or not to autoclear the depth buffer.
  17149. */
  17150. depth: boolean;
  17151. /**
  17152. * Defines whether or not to autoclear the stencil buffer.
  17153. */
  17154. stencil: boolean;
  17155. }
  17156. /**
  17157. * This class is used by the onRenderingGroupObservable
  17158. */
  17159. export class RenderingGroupInfo {
  17160. /**
  17161. * The Scene that being rendered
  17162. */
  17163. scene: Scene;
  17164. /**
  17165. * The camera currently used for the rendering pass
  17166. */
  17167. camera: Nullable<Camera>;
  17168. /**
  17169. * The ID of the renderingGroup being processed
  17170. */
  17171. renderingGroupId: number;
  17172. }
  17173. /**
  17174. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17175. * It is enable to manage the different groups as well as the different necessary sort functions.
  17176. * This should not be used directly aside of the few static configurations
  17177. */
  17178. export class RenderingManager {
  17179. /**
  17180. * The max id used for rendering groups (not included)
  17181. */
  17182. static MAX_RENDERINGGROUPS: number;
  17183. /**
  17184. * The min id used for rendering groups (included)
  17185. */
  17186. static MIN_RENDERINGGROUPS: number;
  17187. /**
  17188. * Used to globally prevent autoclearing scenes.
  17189. */
  17190. static AUTOCLEAR: boolean;
  17191. /**
  17192. * @hidden
  17193. */
  17194. _useSceneAutoClearSetup: boolean;
  17195. private _scene;
  17196. private _renderingGroups;
  17197. private _depthStencilBufferAlreadyCleaned;
  17198. private _autoClearDepthStencil;
  17199. private _customOpaqueSortCompareFn;
  17200. private _customAlphaTestSortCompareFn;
  17201. private _customTransparentSortCompareFn;
  17202. private _renderingGroupInfo;
  17203. /**
  17204. * Instantiates a new rendering group for a particular scene
  17205. * @param scene Defines the scene the groups belongs to
  17206. */
  17207. constructor(scene: Scene);
  17208. private _clearDepthStencilBuffer;
  17209. /**
  17210. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17211. * @hidden
  17212. */
  17213. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17214. /**
  17215. * Resets the different information of the group to prepare a new frame
  17216. * @hidden
  17217. */
  17218. reset(): void;
  17219. /**
  17220. * Dispose and release the group and its associated resources.
  17221. * @hidden
  17222. */
  17223. dispose(): void;
  17224. /**
  17225. * Clear the info related to rendering groups preventing retention points during dispose.
  17226. */
  17227. freeRenderingGroups(): void;
  17228. private _prepareRenderingGroup;
  17229. /**
  17230. * Add a sprite manager to the rendering manager in order to render it this frame.
  17231. * @param spriteManager Define the sprite manager to render
  17232. */
  17233. dispatchSprites(spriteManager: ISpriteManager): void;
  17234. /**
  17235. * Add a particle system to the rendering manager in order to render it this frame.
  17236. * @param particleSystem Define the particle system to render
  17237. */
  17238. dispatchParticles(particleSystem: IParticleSystem): void;
  17239. /**
  17240. * Add a submesh to the manager in order to render it this frame
  17241. * @param subMesh The submesh to dispatch
  17242. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17243. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17244. */
  17245. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17246. /**
  17247. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17248. * This allowed control for front to back rendering or reversly depending of the special needs.
  17249. *
  17250. * @param renderingGroupId The rendering group id corresponding to its index
  17251. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17252. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17253. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17254. */
  17255. 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;
  17256. /**
  17257. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17258. *
  17259. * @param renderingGroupId The rendering group id corresponding to its index
  17260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17261. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17262. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17263. */
  17264. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17265. /**
  17266. * Gets the current auto clear configuration for one rendering group of the rendering
  17267. * manager.
  17268. * @param index the rendering group index to get the information for
  17269. * @returns The auto clear setup for the requested rendering group
  17270. */
  17271. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17272. }
  17273. }
  17274. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17275. import { Observable } from "babylonjs/Misc/observable";
  17276. import { SmartArray } from "babylonjs/Misc/smartArray";
  17277. import { Nullable } from "babylonjs/types";
  17278. import { Camera } from "babylonjs/Cameras/camera";
  17279. import { Scene } from "babylonjs/scene";
  17280. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17281. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17285. import { Texture } from "babylonjs/Materials/Textures/texture";
  17286. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17287. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17288. import { Engine } from "babylonjs/Engines/engine";
  17289. /**
  17290. * This Helps creating a texture that will be created from a camera in your scene.
  17291. * It is basically a dynamic texture that could be used to create special effects for instance.
  17292. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17293. */
  17294. export class RenderTargetTexture extends Texture {
  17295. isCube: boolean;
  17296. /**
  17297. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17298. */
  17299. static readonly REFRESHRATE_RENDER_ONCE: number;
  17300. /**
  17301. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17302. */
  17303. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17304. /**
  17305. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17306. * the central point of your effect and can save a lot of performances.
  17307. */
  17308. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17309. /**
  17310. * Use this predicate to dynamically define the list of mesh you want to render.
  17311. * If set, the renderList property will be overwritten.
  17312. */
  17313. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17314. private _renderList;
  17315. /**
  17316. * Use this list to define the list of mesh you want to render.
  17317. */
  17318. renderList: Nullable<Array<AbstractMesh>>;
  17319. private _hookArray;
  17320. /**
  17321. * Define if particles should be rendered in your texture.
  17322. */
  17323. renderParticles: boolean;
  17324. /**
  17325. * Define if sprites should be rendered in your texture.
  17326. */
  17327. renderSprites: boolean;
  17328. /**
  17329. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17330. */
  17331. coordinatesMode: number;
  17332. /**
  17333. * Define the camera used to render the texture.
  17334. */
  17335. activeCamera: Nullable<Camera>;
  17336. /**
  17337. * Override the render function of the texture with your own one.
  17338. */
  17339. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17340. /**
  17341. * Define if camera post processes should be use while rendering the texture.
  17342. */
  17343. useCameraPostProcesses: boolean;
  17344. /**
  17345. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17346. */
  17347. ignoreCameraViewport: boolean;
  17348. private _postProcessManager;
  17349. private _postProcesses;
  17350. private _resizeObserver;
  17351. /**
  17352. * An event triggered when the texture is unbind.
  17353. */
  17354. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17355. /**
  17356. * An event triggered when the texture is unbind.
  17357. */
  17358. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17359. private _onAfterUnbindObserver;
  17360. /**
  17361. * Set a after unbind callback in the texture.
  17362. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17363. */
  17364. onAfterUnbind: () => void;
  17365. /**
  17366. * An event triggered before rendering the texture
  17367. */
  17368. onBeforeRenderObservable: Observable<number>;
  17369. private _onBeforeRenderObserver;
  17370. /**
  17371. * Set a before render callback in the texture.
  17372. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17373. */
  17374. onBeforeRender: (faceIndex: number) => void;
  17375. /**
  17376. * An event triggered after rendering the texture
  17377. */
  17378. onAfterRenderObservable: Observable<number>;
  17379. private _onAfterRenderObserver;
  17380. /**
  17381. * Set a after render callback in the texture.
  17382. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17383. */
  17384. onAfterRender: (faceIndex: number) => void;
  17385. /**
  17386. * An event triggered after the texture clear
  17387. */
  17388. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17389. private _onClearObserver;
  17390. /**
  17391. * Set a clear callback in the texture.
  17392. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17393. */
  17394. onClear: (Engine: Engine) => void;
  17395. /**
  17396. * Define the clear color of the Render Target if it should be different from the scene.
  17397. */
  17398. clearColor: Color4;
  17399. protected _size: number | {
  17400. width: number;
  17401. height: number;
  17402. };
  17403. protected _initialSizeParameter: number | {
  17404. width: number;
  17405. height: number;
  17406. } | {
  17407. ratio: number;
  17408. };
  17409. protected _sizeRatio: Nullable<number>;
  17410. /** @hidden */
  17411. _generateMipMaps: boolean;
  17412. protected _renderingManager: RenderingManager;
  17413. /** @hidden */
  17414. _waitingRenderList: string[];
  17415. protected _doNotChangeAspectRatio: boolean;
  17416. protected _currentRefreshId: number;
  17417. protected _refreshRate: number;
  17418. protected _textureMatrix: Matrix;
  17419. protected _samples: number;
  17420. protected _renderTargetOptions: RenderTargetCreationOptions;
  17421. /**
  17422. * Gets render target creation options that were used.
  17423. */
  17424. readonly renderTargetOptions: RenderTargetCreationOptions;
  17425. protected _engine: Engine;
  17426. protected _onRatioRescale(): void;
  17427. /**
  17428. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17429. * It must define where the camera used to render the texture is set
  17430. */
  17431. boundingBoxPosition: Vector3;
  17432. private _boundingBoxSize;
  17433. /**
  17434. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17435. * When defined, the cubemap will switch to local mode
  17436. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17437. * @example https://www.babylonjs-playground.com/#RNASML
  17438. */
  17439. boundingBoxSize: Vector3;
  17440. /**
  17441. * In case the RTT has been created with a depth texture, get the associated
  17442. * depth texture.
  17443. * Otherwise, return null.
  17444. */
  17445. depthStencilTexture: Nullable<InternalTexture>;
  17446. /**
  17447. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17448. * or used a shadow, depth texture...
  17449. * @param name The friendly name of the texture
  17450. * @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)
  17451. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17452. * @param generateMipMaps True if mip maps need to be generated after render.
  17453. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17454. * @param type The type of the buffer in the RTT (int, half float, float...)
  17455. * @param isCube True if a cube texture needs to be created
  17456. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17457. * @param generateDepthBuffer True to generate a depth buffer
  17458. * @param generateStencilBuffer True to generate a stencil buffer
  17459. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17460. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17461. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17462. */
  17463. constructor(name: string, size: number | {
  17464. width: number;
  17465. height: number;
  17466. } | {
  17467. ratio: number;
  17468. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17469. /**
  17470. * Creates a depth stencil texture.
  17471. * This is only available in WebGL 2 or with the depth texture extension available.
  17472. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17473. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17474. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17475. */
  17476. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17477. private _processSizeParameter;
  17478. /**
  17479. * Define the number of samples to use in case of MSAA.
  17480. * It defaults to one meaning no MSAA has been enabled.
  17481. */
  17482. samples: number;
  17483. /**
  17484. * Resets the refresh counter of the texture and start bak from scratch.
  17485. * Could be useful to regenerate the texture if it is setup to render only once.
  17486. */
  17487. resetRefreshCounter(): void;
  17488. /**
  17489. * Define the refresh rate of the texture or the rendering frequency.
  17490. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17491. */
  17492. refreshRate: number;
  17493. /**
  17494. * Adds a post process to the render target rendering passes.
  17495. * @param postProcess define the post process to add
  17496. */
  17497. addPostProcess(postProcess: PostProcess): void;
  17498. /**
  17499. * Clear all the post processes attached to the render target
  17500. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17501. */
  17502. clearPostProcesses(dispose?: boolean): void;
  17503. /**
  17504. * Remove one of the post process from the list of attached post processes to the texture
  17505. * @param postProcess define the post process to remove from the list
  17506. */
  17507. removePostProcess(postProcess: PostProcess): void;
  17508. /** @hidden */
  17509. _shouldRender(): boolean;
  17510. /**
  17511. * Gets the actual render size of the texture.
  17512. * @returns the width of the render size
  17513. */
  17514. getRenderSize(): number;
  17515. /**
  17516. * Gets the actual render width of the texture.
  17517. * @returns the width of the render size
  17518. */
  17519. getRenderWidth(): number;
  17520. /**
  17521. * Gets the actual render height of the texture.
  17522. * @returns the height of the render size
  17523. */
  17524. getRenderHeight(): number;
  17525. /**
  17526. * Get if the texture can be rescaled or not.
  17527. */
  17528. readonly canRescale: boolean;
  17529. /**
  17530. * Resize the texture using a ratio.
  17531. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17532. */
  17533. scale(ratio: number): void;
  17534. /**
  17535. * Get the texture reflection matrix used to rotate/transform the reflection.
  17536. * @returns the reflection matrix
  17537. */
  17538. getReflectionTextureMatrix(): Matrix;
  17539. /**
  17540. * Resize the texture to a new desired size.
  17541. * Be carrefull as it will recreate all the data in the new texture.
  17542. * @param size Define the new size. It can be:
  17543. * - a number for squared texture,
  17544. * - an object containing { width: number, height: number }
  17545. * - or an object containing a ratio { ratio: number }
  17546. */
  17547. resize(size: number | {
  17548. width: number;
  17549. height: number;
  17550. } | {
  17551. ratio: number;
  17552. }): void;
  17553. /**
  17554. * Renders all the objects from the render list into the texture.
  17555. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17556. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17557. */
  17558. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17559. private _bestReflectionRenderTargetDimension;
  17560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17561. private renderToTarget;
  17562. /**
  17563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17564. * This allowed control for front to back rendering or reversly depending of the special needs.
  17565. *
  17566. * @param renderingGroupId The rendering group id corresponding to its index
  17567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17570. */
  17571. 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;
  17572. /**
  17573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17574. *
  17575. * @param renderingGroupId The rendering group id corresponding to its index
  17576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17577. */
  17578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17579. /**
  17580. * Clones the texture.
  17581. * @returns the cloned texture
  17582. */
  17583. clone(): RenderTargetTexture;
  17584. /**
  17585. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17586. * @returns The JSON representation of the texture
  17587. */
  17588. serialize(): any;
  17589. /**
  17590. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17591. */
  17592. disposeFramebufferObjects(): void;
  17593. /**
  17594. * Dispose the texture and release its associated resources.
  17595. */
  17596. dispose(): void;
  17597. /** @hidden */
  17598. _rebuild(): void;
  17599. /**
  17600. * Clear the info related to rendering groups preventing retention point in material dispose.
  17601. */
  17602. freeRenderingGroups(): void;
  17603. }
  17604. }
  17605. declare module "babylonjs/Materials/material" {
  17606. import { IAnimatable } from "babylonjs/Misc/tools";
  17607. import { SmartArray } from "babylonjs/Misc/smartArray";
  17608. import { Observable } from "babylonjs/Misc/observable";
  17609. import { Nullable } from "babylonjs/types";
  17610. import { Scene } from "babylonjs/scene";
  17611. import { Matrix } from "babylonjs/Maths/math";
  17612. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  17613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17614. import { Mesh } from "babylonjs/Meshes/mesh";
  17615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17616. import { Effect } from "babylonjs/Materials/effect";
  17617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17619. import { Animation } from "babylonjs/Animations/animation";
  17620. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17621. /**
  17622. * Base class for the main features of a material in Babylon.js
  17623. */
  17624. export class Material implements IAnimatable {
  17625. /**
  17626. * Returns the triangle fill mode
  17627. */
  17628. static readonly TriangleFillMode: number;
  17629. /**
  17630. * Returns the wireframe mode
  17631. */
  17632. static readonly WireFrameFillMode: number;
  17633. /**
  17634. * Returns the point fill mode
  17635. */
  17636. static readonly PointFillMode: number;
  17637. /**
  17638. * Returns the point list draw mode
  17639. */
  17640. static readonly PointListDrawMode: number;
  17641. /**
  17642. * Returns the line list draw mode
  17643. */
  17644. static readonly LineListDrawMode: number;
  17645. /**
  17646. * Returns the line loop draw mode
  17647. */
  17648. static readonly LineLoopDrawMode: number;
  17649. /**
  17650. * Returns the line strip draw mode
  17651. */
  17652. static readonly LineStripDrawMode: number;
  17653. /**
  17654. * Returns the triangle strip draw mode
  17655. */
  17656. static readonly TriangleStripDrawMode: number;
  17657. /**
  17658. * Returns the triangle fan draw mode
  17659. */
  17660. static readonly TriangleFanDrawMode: number;
  17661. /**
  17662. * Stores the clock-wise side orientation
  17663. */
  17664. static readonly ClockWiseSideOrientation: number;
  17665. /**
  17666. * Stores the counter clock-wise side orientation
  17667. */
  17668. static readonly CounterClockWiseSideOrientation: number;
  17669. /**
  17670. * The dirty texture flag value
  17671. */
  17672. static readonly TextureDirtyFlag: number;
  17673. /**
  17674. * The dirty light flag value
  17675. */
  17676. static readonly LightDirtyFlag: number;
  17677. /**
  17678. * The dirty fresnel flag value
  17679. */
  17680. static readonly FresnelDirtyFlag: number;
  17681. /**
  17682. * The dirty attribute flag value
  17683. */
  17684. static readonly AttributesDirtyFlag: number;
  17685. /**
  17686. * The dirty misc flag value
  17687. */
  17688. static readonly MiscDirtyFlag: number;
  17689. /**
  17690. * The all dirty flag value
  17691. */
  17692. static readonly AllDirtyFlag: number;
  17693. /**
  17694. * The ID of the material
  17695. */
  17696. id: string;
  17697. /**
  17698. * Gets or sets the unique id of the material
  17699. */
  17700. uniqueId: number;
  17701. /**
  17702. * The name of the material
  17703. */
  17704. name: string;
  17705. /**
  17706. * Gets or sets user defined metadata
  17707. */
  17708. metadata: any;
  17709. /**
  17710. * For internal use only. Please do not use.
  17711. */
  17712. reservedDataStore: any;
  17713. /**
  17714. * Specifies if the ready state should be checked on each call
  17715. */
  17716. checkReadyOnEveryCall: boolean;
  17717. /**
  17718. * Specifies if the ready state should be checked once
  17719. */
  17720. checkReadyOnlyOnce: boolean;
  17721. /**
  17722. * The state of the material
  17723. */
  17724. state: string;
  17725. /**
  17726. * The alpha value of the material
  17727. */
  17728. protected _alpha: number;
  17729. /**
  17730. * Sets the alpha value of the material
  17731. */
  17732. /**
  17733. * Gets the alpha value of the material
  17734. */
  17735. alpha: number;
  17736. /**
  17737. * Specifies if back face culling is enabled
  17738. */
  17739. protected _backFaceCulling: boolean;
  17740. /**
  17741. * Sets the back-face culling state
  17742. */
  17743. /**
  17744. * Gets the back-face culling state
  17745. */
  17746. backFaceCulling: boolean;
  17747. /**
  17748. * Stores the value for side orientation
  17749. */
  17750. sideOrientation: number;
  17751. /**
  17752. * Callback triggered when the material is compiled
  17753. */
  17754. onCompiled: (effect: Effect) => void;
  17755. /**
  17756. * Callback triggered when an error occurs
  17757. */
  17758. onError: (effect: Effect, errors: string) => void;
  17759. /**
  17760. * Callback triggered to get the render target textures
  17761. */
  17762. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17763. /**
  17764. * Gets a boolean indicating that current material needs to register RTT
  17765. */
  17766. readonly hasRenderTargetTextures: boolean;
  17767. /**
  17768. * Specifies if the material should be serialized
  17769. */
  17770. doNotSerialize: boolean;
  17771. /**
  17772. * @hidden
  17773. */
  17774. _storeEffectOnSubMeshes: boolean;
  17775. /**
  17776. * Stores the animations for the material
  17777. */
  17778. animations: Array<Animation>;
  17779. /**
  17780. * An event triggered when the material is disposed
  17781. */
  17782. onDisposeObservable: Observable<Material>;
  17783. /**
  17784. * An observer which watches for dispose events
  17785. */
  17786. private _onDisposeObserver;
  17787. private _onUnBindObservable;
  17788. /**
  17789. * Called during a dispose event
  17790. */
  17791. onDispose: () => void;
  17792. private _onBindObservable;
  17793. /**
  17794. * An event triggered when the material is bound
  17795. */
  17796. readonly onBindObservable: Observable<AbstractMesh>;
  17797. /**
  17798. * An observer which watches for bind events
  17799. */
  17800. private _onBindObserver;
  17801. /**
  17802. * Called during a bind event
  17803. */
  17804. onBind: (Mesh: AbstractMesh) => void;
  17805. /**
  17806. * An event triggered when the material is unbound
  17807. */
  17808. readonly onUnBindObservable: Observable<Material>;
  17809. /**
  17810. * Stores the value of the alpha mode
  17811. */
  17812. private _alphaMode;
  17813. /**
  17814. * Sets the value of the alpha mode.
  17815. *
  17816. * | Value | Type | Description |
  17817. * | --- | --- | --- |
  17818. * | 0 | ALPHA_DISABLE | |
  17819. * | 1 | ALPHA_ADD | |
  17820. * | 2 | ALPHA_COMBINE | |
  17821. * | 3 | ALPHA_SUBTRACT | |
  17822. * | 4 | ALPHA_MULTIPLY | |
  17823. * | 5 | ALPHA_MAXIMIZED | |
  17824. * | 6 | ALPHA_ONEONE | |
  17825. * | 7 | ALPHA_PREMULTIPLIED | |
  17826. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17827. * | 9 | ALPHA_INTERPOLATE | |
  17828. * | 10 | ALPHA_SCREENMODE | |
  17829. *
  17830. */
  17831. /**
  17832. * Gets the value of the alpha mode
  17833. */
  17834. alphaMode: number;
  17835. /**
  17836. * Stores the state of the need depth pre-pass value
  17837. */
  17838. private _needDepthPrePass;
  17839. /**
  17840. * Sets the need depth pre-pass value
  17841. */
  17842. /**
  17843. * Gets the depth pre-pass value
  17844. */
  17845. needDepthPrePass: boolean;
  17846. /**
  17847. * Specifies if depth writing should be disabled
  17848. */
  17849. disableDepthWrite: boolean;
  17850. /**
  17851. * Specifies if depth writing should be forced
  17852. */
  17853. forceDepthWrite: boolean;
  17854. /**
  17855. * Specifies if there should be a separate pass for culling
  17856. */
  17857. separateCullingPass: boolean;
  17858. /**
  17859. * Stores the state specifing if fog should be enabled
  17860. */
  17861. private _fogEnabled;
  17862. /**
  17863. * Sets the state for enabling fog
  17864. */
  17865. /**
  17866. * Gets the value of the fog enabled state
  17867. */
  17868. fogEnabled: boolean;
  17869. /**
  17870. * Stores the size of points
  17871. */
  17872. pointSize: number;
  17873. /**
  17874. * Stores the z offset value
  17875. */
  17876. zOffset: number;
  17877. /**
  17878. * Gets a value specifying if wireframe mode is enabled
  17879. */
  17880. /**
  17881. * Sets the state of wireframe mode
  17882. */
  17883. wireframe: boolean;
  17884. /**
  17885. * Gets the value specifying if point clouds are enabled
  17886. */
  17887. /**
  17888. * Sets the state of point cloud mode
  17889. */
  17890. pointsCloud: boolean;
  17891. /**
  17892. * Gets the material fill mode
  17893. */
  17894. /**
  17895. * Sets the material fill mode
  17896. */
  17897. fillMode: number;
  17898. /**
  17899. * @hidden
  17900. * Stores the effects for the material
  17901. */
  17902. _effect: Nullable<Effect>;
  17903. /**
  17904. * @hidden
  17905. * Specifies if the material was previously ready
  17906. */
  17907. _wasPreviouslyReady: boolean;
  17908. /**
  17909. * Specifies if uniform buffers should be used
  17910. */
  17911. private _useUBO;
  17912. /**
  17913. * Stores a reference to the scene
  17914. */
  17915. private _scene;
  17916. /**
  17917. * Stores the fill mode state
  17918. */
  17919. private _fillMode;
  17920. /**
  17921. * Specifies if the depth write state should be cached
  17922. */
  17923. private _cachedDepthWriteState;
  17924. /**
  17925. * Stores the uniform buffer
  17926. */
  17927. protected _uniformBuffer: UniformBuffer;
  17928. /** @hidden */
  17929. _indexInSceneMaterialArray: number;
  17930. /** @hidden */
  17931. meshMap: Nullable<{
  17932. [id: string]: AbstractMesh | undefined;
  17933. }>;
  17934. /**
  17935. * Creates a material instance
  17936. * @param name defines the name of the material
  17937. * @param scene defines the scene to reference
  17938. * @param doNotAdd specifies if the material should be added to the scene
  17939. */
  17940. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17941. /**
  17942. * Returns a string representation of the current material
  17943. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17944. * @returns a string with material information
  17945. */
  17946. toString(fullDetails?: boolean): string;
  17947. /**
  17948. * Gets the class name of the material
  17949. * @returns a string with the class name of the material
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * Specifies if updates for the material been locked
  17954. */
  17955. readonly isFrozen: boolean;
  17956. /**
  17957. * Locks updates for the material
  17958. */
  17959. freeze(): void;
  17960. /**
  17961. * Unlocks updates for the material
  17962. */
  17963. unfreeze(): void;
  17964. /**
  17965. * Specifies if the material is ready to be used
  17966. * @param mesh defines the mesh to check
  17967. * @param useInstances specifies if instances should be used
  17968. * @returns a boolean indicating if the material is ready to be used
  17969. */
  17970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17971. /**
  17972. * Specifies that the submesh is ready to be used
  17973. * @param mesh defines the mesh to check
  17974. * @param subMesh defines which submesh to check
  17975. * @param useInstances specifies that instances should be used
  17976. * @returns a boolean indicating that the submesh is ready or not
  17977. */
  17978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17979. /**
  17980. * Returns the material effect
  17981. * @returns the effect associated with the material
  17982. */
  17983. getEffect(): Nullable<Effect>;
  17984. /**
  17985. * Returns the current scene
  17986. * @returns a Scene
  17987. */
  17988. getScene(): Scene;
  17989. /**
  17990. * Specifies if the material will require alpha blending
  17991. * @returns a boolean specifying if alpha blending is needed
  17992. */
  17993. needAlphaBlending(): boolean;
  17994. /**
  17995. * Specifies if the mesh will require alpha blending
  17996. * @param mesh defines the mesh to check
  17997. * @returns a boolean specifying if alpha blending is needed for the mesh
  17998. */
  17999. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18000. /**
  18001. * Specifies if this material should be rendered in alpha test mode
  18002. * @returns a boolean specifying if an alpha test is needed.
  18003. */
  18004. needAlphaTesting(): boolean;
  18005. /**
  18006. * Gets the texture used for the alpha test
  18007. * @returns the texture to use for alpha testing
  18008. */
  18009. getAlphaTestTexture(): Nullable<BaseTexture>;
  18010. /**
  18011. * Marks the material to indicate that it needs to be re-calculated
  18012. */
  18013. markDirty(): void;
  18014. /** @hidden */
  18015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18016. /**
  18017. * Binds the material to the mesh
  18018. * @param world defines the world transformation matrix
  18019. * @param mesh defines the mesh to bind the material to
  18020. */
  18021. bind(world: Matrix, mesh?: Mesh): void;
  18022. /**
  18023. * Binds the submesh to the material
  18024. * @param world defines the world transformation matrix
  18025. * @param mesh defines the mesh containing the submesh
  18026. * @param subMesh defines the submesh to bind the material to
  18027. */
  18028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18029. /**
  18030. * Binds the world matrix to the material
  18031. * @param world defines the world transformation matrix
  18032. */
  18033. bindOnlyWorldMatrix(world: Matrix): void;
  18034. /**
  18035. * Binds the scene's uniform buffer to the effect.
  18036. * @param effect defines the effect to bind to the scene uniform buffer
  18037. * @param sceneUbo defines the uniform buffer storing scene data
  18038. */
  18039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18040. /**
  18041. * Binds the view matrix to the effect
  18042. * @param effect defines the effect to bind the view matrix to
  18043. */
  18044. bindView(effect: Effect): void;
  18045. /**
  18046. * Binds the view projection matrix to the effect
  18047. * @param effect defines the effect to bind the view projection matrix to
  18048. */
  18049. bindViewProjection(effect: Effect): void;
  18050. /**
  18051. * Specifies if material alpha testing should be turned on for the mesh
  18052. * @param mesh defines the mesh to check
  18053. */
  18054. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18055. /**
  18056. * Processes to execute after binding the material to a mesh
  18057. * @param mesh defines the rendered mesh
  18058. */
  18059. protected _afterBind(mesh?: Mesh): void;
  18060. /**
  18061. * Unbinds the material from the mesh
  18062. */
  18063. unbind(): void;
  18064. /**
  18065. * Gets the active textures from the material
  18066. * @returns an array of textures
  18067. */
  18068. getActiveTextures(): BaseTexture[];
  18069. /**
  18070. * Specifies if the material uses a texture
  18071. * @param texture defines the texture to check against the material
  18072. * @returns a boolean specifying if the material uses the texture
  18073. */
  18074. hasTexture(texture: BaseTexture): boolean;
  18075. /**
  18076. * Makes a duplicate of the material, and gives it a new name
  18077. * @param name defines the new name for the duplicated material
  18078. * @returns the cloned material
  18079. */
  18080. clone(name: string): Nullable<Material>;
  18081. /**
  18082. * Gets the meshes bound to the material
  18083. * @returns an array of meshes bound to the material
  18084. */
  18085. getBindedMeshes(): AbstractMesh[];
  18086. /**
  18087. * Force shader compilation
  18088. * @param mesh defines the mesh associated with this material
  18089. * @param onCompiled defines a function to execute once the material is compiled
  18090. * @param options defines the options to configure the compilation
  18091. */
  18092. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18093. clipPlane: boolean;
  18094. }>): void;
  18095. /**
  18096. * Force shader compilation
  18097. * @param mesh defines the mesh that will use this material
  18098. * @param options defines additional options for compiling the shaders
  18099. * @returns a promise that resolves when the compilation completes
  18100. */
  18101. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18102. clipPlane: boolean;
  18103. }>): Promise<void>;
  18104. private static readonly _ImageProcessingDirtyCallBack;
  18105. private static readonly _TextureDirtyCallBack;
  18106. private static readonly _FresnelDirtyCallBack;
  18107. private static readonly _MiscDirtyCallBack;
  18108. private static readonly _LightsDirtyCallBack;
  18109. private static readonly _AttributeDirtyCallBack;
  18110. private static _FresnelAndMiscDirtyCallBack;
  18111. private static _TextureAndMiscDirtyCallBack;
  18112. private static readonly _DirtyCallbackArray;
  18113. private static readonly _RunDirtyCallBacks;
  18114. /**
  18115. * Marks a define in the material to indicate that it needs to be re-computed
  18116. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18117. */
  18118. markAsDirty(flag: number): void;
  18119. /**
  18120. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18121. * @param func defines a function which checks material defines against the submeshes
  18122. */
  18123. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18124. /**
  18125. * Indicates that image processing needs to be re-calculated for all submeshes
  18126. */
  18127. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18128. /**
  18129. * Indicates that textures need to be re-calculated for all submeshes
  18130. */
  18131. protected _markAllSubMeshesAsTexturesDirty(): void;
  18132. /**
  18133. * Indicates that fresnel needs to be re-calculated for all submeshes
  18134. */
  18135. protected _markAllSubMeshesAsFresnelDirty(): void;
  18136. /**
  18137. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18138. */
  18139. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18140. /**
  18141. * Indicates that lights need to be re-calculated for all submeshes
  18142. */
  18143. protected _markAllSubMeshesAsLightsDirty(): void;
  18144. /**
  18145. * Indicates that attributes need to be re-calculated for all submeshes
  18146. */
  18147. protected _markAllSubMeshesAsAttributesDirty(): void;
  18148. /**
  18149. * Indicates that misc needs to be re-calculated for all submeshes
  18150. */
  18151. protected _markAllSubMeshesAsMiscDirty(): void;
  18152. /**
  18153. * Indicates that textures and misc need to be re-calculated for all submeshes
  18154. */
  18155. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18156. /**
  18157. * Disposes the material
  18158. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18159. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18160. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18161. */
  18162. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18163. /** @hidden */
  18164. private releaseVertexArrayObject;
  18165. /**
  18166. * Serializes this material
  18167. * @returns the serialized material object
  18168. */
  18169. serialize(): any;
  18170. /**
  18171. * Creates a material from parsed material data
  18172. * @param parsedMaterial defines parsed material data
  18173. * @param scene defines the hosting scene
  18174. * @param rootUrl defines the root URL to use to load textures
  18175. * @returns a new material
  18176. */
  18177. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18178. }
  18179. }
  18180. declare module "babylonjs/Loading/sceneLoaderFlags" {
  18181. /**
  18182. * Class used to represent data loading progression
  18183. */
  18184. export class SceneLoaderFlags {
  18185. private static _ForceFullSceneLoadingForIncremental;
  18186. private static _ShowLoadingScreen;
  18187. private static _CleanBoneMatrixWeights;
  18188. private static _loggingLevel;
  18189. /**
  18190. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  18191. */
  18192. static ForceFullSceneLoadingForIncremental: boolean;
  18193. /**
  18194. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  18195. */
  18196. static ShowLoadingScreen: boolean;
  18197. /**
  18198. * Defines the current logging level (while loading the scene)
  18199. * @ignorenaming
  18200. */
  18201. static loggingLevel: number;
  18202. /**
  18203. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  18204. */
  18205. static CleanBoneMatrixWeights: boolean;
  18206. }
  18207. }
  18208. declare module "babylonjs/Morph/morphTarget" {
  18209. import { IAnimatable } from "babylonjs/Misc/tools";
  18210. import { Observable } from "babylonjs/Misc/observable";
  18211. import { Nullable, FloatArray } from "babylonjs/types";
  18212. import { Scene } from "babylonjs/scene";
  18213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18214. import { Animation } from "babylonjs/Animations/animation";
  18215. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18216. /**
  18217. * Defines a target to use with MorphTargetManager
  18218. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18219. */
  18220. export class MorphTarget implements IAnimatable {
  18221. /** defines the name of the target */
  18222. name: string;
  18223. /**
  18224. * Gets or sets the list of animations
  18225. */
  18226. animations: Animation[];
  18227. private _scene;
  18228. private _positions;
  18229. private _normals;
  18230. private _tangents;
  18231. private _influence;
  18232. /**
  18233. * Observable raised when the influence changes
  18234. */
  18235. onInfluenceChanged: Observable<boolean>;
  18236. /** @hidden */
  18237. _onDataLayoutChanged: Observable<void>;
  18238. /**
  18239. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18240. */
  18241. influence: number;
  18242. /**
  18243. * Gets or sets the id of the morph Target
  18244. */
  18245. id: string;
  18246. private _animationPropertiesOverride;
  18247. /**
  18248. * Gets or sets the animation properties override
  18249. */
  18250. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18251. /**
  18252. * Creates a new MorphTarget
  18253. * @param name defines the name of the target
  18254. * @param influence defines the influence to use
  18255. */
  18256. constructor(
  18257. /** defines the name of the target */
  18258. name: string, influence?: number, scene?: Nullable<Scene>);
  18259. /**
  18260. * Gets a boolean defining if the target contains position data
  18261. */
  18262. readonly hasPositions: boolean;
  18263. /**
  18264. * Gets a boolean defining if the target contains normal data
  18265. */
  18266. readonly hasNormals: boolean;
  18267. /**
  18268. * Gets a boolean defining if the target contains tangent data
  18269. */
  18270. readonly hasTangents: boolean;
  18271. /**
  18272. * Affects position data to this target
  18273. * @param data defines the position data to use
  18274. */
  18275. setPositions(data: Nullable<FloatArray>): void;
  18276. /**
  18277. * Gets the position data stored in this target
  18278. * @returns a FloatArray containing the position data (or null if not present)
  18279. */
  18280. getPositions(): Nullable<FloatArray>;
  18281. /**
  18282. * Affects normal data to this target
  18283. * @param data defines the normal data to use
  18284. */
  18285. setNormals(data: Nullable<FloatArray>): void;
  18286. /**
  18287. * Gets the normal data stored in this target
  18288. * @returns a FloatArray containing the normal data (or null if not present)
  18289. */
  18290. getNormals(): Nullable<FloatArray>;
  18291. /**
  18292. * Affects tangent data to this target
  18293. * @param data defines the tangent data to use
  18294. */
  18295. setTangents(data: Nullable<FloatArray>): void;
  18296. /**
  18297. * Gets the tangent data stored in this target
  18298. * @returns a FloatArray containing the tangent data (or null if not present)
  18299. */
  18300. getTangents(): Nullable<FloatArray>;
  18301. /**
  18302. * Serializes the current target into a Serialization object
  18303. * @returns the serialized object
  18304. */
  18305. serialize(): any;
  18306. /**
  18307. * Returns the string "MorphTarget"
  18308. * @returns "MorphTarget"
  18309. */
  18310. getClassName(): string;
  18311. /**
  18312. * Creates a new target from serialized data
  18313. * @param serializationObject defines the serialized data to use
  18314. * @returns a new MorphTarget
  18315. */
  18316. static Parse(serializationObject: any): MorphTarget;
  18317. /**
  18318. * Creates a MorphTarget from mesh data
  18319. * @param mesh defines the source mesh
  18320. * @param name defines the name to use for the new target
  18321. * @param influence defines the influence to attach to the target
  18322. * @returns a new MorphTarget
  18323. */
  18324. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18325. }
  18326. }
  18327. declare module "babylonjs/Morph/morphTargetManager" {
  18328. import { Nullable } from "babylonjs/types";
  18329. import { Scene } from "babylonjs/scene";
  18330. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  18331. /**
  18332. * This class is used to deform meshes using morphing between different targets
  18333. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18334. */
  18335. export class MorphTargetManager {
  18336. private _targets;
  18337. private _targetInfluenceChangedObservers;
  18338. private _targetDataLayoutChangedObservers;
  18339. private _activeTargets;
  18340. private _scene;
  18341. private _influences;
  18342. private _supportsNormals;
  18343. private _supportsTangents;
  18344. private _vertexCount;
  18345. private _uniqueId;
  18346. private _tempInfluences;
  18347. /**
  18348. * Creates a new MorphTargetManager
  18349. * @param scene defines the current scene
  18350. */
  18351. constructor(scene?: Nullable<Scene>);
  18352. /**
  18353. * Gets the unique ID of this manager
  18354. */
  18355. readonly uniqueId: number;
  18356. /**
  18357. * Gets the number of vertices handled by this manager
  18358. */
  18359. readonly vertexCount: number;
  18360. /**
  18361. * Gets a boolean indicating if this manager supports morphing of normals
  18362. */
  18363. readonly supportsNormals: boolean;
  18364. /**
  18365. * Gets a boolean indicating if this manager supports morphing of tangents
  18366. */
  18367. readonly supportsTangents: boolean;
  18368. /**
  18369. * Gets the number of targets stored in this manager
  18370. */
  18371. readonly numTargets: number;
  18372. /**
  18373. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18374. */
  18375. readonly numInfluencers: number;
  18376. /**
  18377. * Gets the list of influences (one per target)
  18378. */
  18379. readonly influences: Float32Array;
  18380. /**
  18381. * Gets the active target at specified index. An active target is a target with an influence > 0
  18382. * @param index defines the index to check
  18383. * @returns the requested target
  18384. */
  18385. getActiveTarget(index: number): MorphTarget;
  18386. /**
  18387. * Gets the target at specified index
  18388. * @param index defines the index to check
  18389. * @returns the requested target
  18390. */
  18391. getTarget(index: number): MorphTarget;
  18392. /**
  18393. * Add a new target to this manager
  18394. * @param target defines the target to add
  18395. */
  18396. addTarget(target: MorphTarget): void;
  18397. /**
  18398. * Removes a target from the manager
  18399. * @param target defines the target to remove
  18400. */
  18401. removeTarget(target: MorphTarget): void;
  18402. /**
  18403. * Serializes the current manager into a Serialization object
  18404. * @returns the serialized object
  18405. */
  18406. serialize(): any;
  18407. private _syncActiveTargets;
  18408. /**
  18409. * Syncrhonize the targets with all the meshes using this morph target manager
  18410. */
  18411. synchronize(): void;
  18412. /**
  18413. * Creates a new MorphTargetManager from serialized data
  18414. * @param serializationObject defines the serialized data
  18415. * @param scene defines the hosting scene
  18416. * @returns the new MorphTargetManager
  18417. */
  18418. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18419. }
  18420. }
  18421. declare module "babylonjs/Physics/physicsJoint" {
  18422. import { Vector3 } from "babylonjs/Maths/math";
  18423. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18424. /**
  18425. * Interface for Physics-Joint data
  18426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18427. */
  18428. export interface PhysicsJointData {
  18429. /**
  18430. * The main pivot of the joint
  18431. */
  18432. mainPivot?: Vector3;
  18433. /**
  18434. * The connected pivot of the joint
  18435. */
  18436. connectedPivot?: Vector3;
  18437. /**
  18438. * The main axis of the joint
  18439. */
  18440. mainAxis?: Vector3;
  18441. /**
  18442. * The connected axis of the joint
  18443. */
  18444. connectedAxis?: Vector3;
  18445. /**
  18446. * The collision of the joint
  18447. */
  18448. collision?: boolean;
  18449. /**
  18450. * Native Oimo/Cannon/Energy data
  18451. */
  18452. nativeParams?: any;
  18453. }
  18454. /**
  18455. * This is a holder class for the physics joint created by the physics plugin
  18456. * It holds a set of functions to control the underlying joint
  18457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18458. */
  18459. export class PhysicsJoint {
  18460. /**
  18461. * The type of the physics joint
  18462. */
  18463. type: number;
  18464. /**
  18465. * The data for the physics joint
  18466. */
  18467. jointData: PhysicsJointData;
  18468. private _physicsJoint;
  18469. protected _physicsPlugin: IPhysicsEnginePlugin;
  18470. /**
  18471. * Initializes the physics joint
  18472. * @param type The type of the physics joint
  18473. * @param jointData The data for the physics joint
  18474. */
  18475. constructor(
  18476. /**
  18477. * The type of the physics joint
  18478. */
  18479. type: number,
  18480. /**
  18481. * The data for the physics joint
  18482. */
  18483. jointData: PhysicsJointData);
  18484. /**
  18485. * Gets the physics joint
  18486. */
  18487. /**
  18488. * Sets the physics joint
  18489. */
  18490. physicsJoint: any;
  18491. /**
  18492. * Sets the physics plugin
  18493. */
  18494. physicsPlugin: IPhysicsEnginePlugin;
  18495. /**
  18496. * Execute a function that is physics-plugin specific.
  18497. * @param {Function} func the function that will be executed.
  18498. * It accepts two parameters: the physics world and the physics joint
  18499. */
  18500. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18501. /**
  18502. * Distance-Joint type
  18503. */
  18504. static DistanceJoint: number;
  18505. /**
  18506. * Hinge-Joint type
  18507. */
  18508. static HingeJoint: number;
  18509. /**
  18510. * Ball-and-Socket joint type
  18511. */
  18512. static BallAndSocketJoint: number;
  18513. /**
  18514. * Wheel-Joint type
  18515. */
  18516. static WheelJoint: number;
  18517. /**
  18518. * Slider-Joint type
  18519. */
  18520. static SliderJoint: number;
  18521. /**
  18522. * Prismatic-Joint type
  18523. */
  18524. static PrismaticJoint: number;
  18525. /**
  18526. * Universal-Joint type
  18527. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18528. */
  18529. static UniversalJoint: number;
  18530. /**
  18531. * Hinge-Joint 2 type
  18532. */
  18533. static Hinge2Joint: number;
  18534. /**
  18535. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18536. */
  18537. static PointToPointJoint: number;
  18538. /**
  18539. * Spring-Joint type
  18540. */
  18541. static SpringJoint: number;
  18542. /**
  18543. * Lock-Joint type
  18544. */
  18545. static LockJoint: number;
  18546. }
  18547. /**
  18548. * A class representing a physics distance joint
  18549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18550. */
  18551. export class DistanceJoint extends PhysicsJoint {
  18552. /**
  18553. *
  18554. * @param jointData The data for the Distance-Joint
  18555. */
  18556. constructor(jointData: DistanceJointData);
  18557. /**
  18558. * Update the predefined distance.
  18559. * @param maxDistance The maximum preferred distance
  18560. * @param minDistance The minimum preferred distance
  18561. */
  18562. updateDistance(maxDistance: number, minDistance?: number): void;
  18563. }
  18564. /**
  18565. * Represents a Motor-Enabled Joint
  18566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18567. */
  18568. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18569. /**
  18570. * Initializes the Motor-Enabled Joint
  18571. * @param type The type of the joint
  18572. * @param jointData The physica joint data for the joint
  18573. */
  18574. constructor(type: number, jointData: PhysicsJointData);
  18575. /**
  18576. * Set the motor values.
  18577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18578. * @param force the force to apply
  18579. * @param maxForce max force for this motor.
  18580. */
  18581. setMotor(force?: number, maxForce?: number): void;
  18582. /**
  18583. * Set the motor's limits.
  18584. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18585. * @param upperLimit The upper limit of the motor
  18586. * @param lowerLimit The lower limit of the motor
  18587. */
  18588. setLimit(upperLimit: number, lowerLimit?: number): void;
  18589. }
  18590. /**
  18591. * This class represents a single physics Hinge-Joint
  18592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18593. */
  18594. export class HingeJoint extends MotorEnabledJoint {
  18595. /**
  18596. * Initializes the Hinge-Joint
  18597. * @param jointData The joint data for the Hinge-Joint
  18598. */
  18599. constructor(jointData: PhysicsJointData);
  18600. /**
  18601. * Set the motor values.
  18602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18603. * @param {number} force the force to apply
  18604. * @param {number} maxForce max force for this motor.
  18605. */
  18606. setMotor(force?: number, maxForce?: number): void;
  18607. /**
  18608. * Set the motor's limits.
  18609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18610. * @param upperLimit The upper limit of the motor
  18611. * @param lowerLimit The lower limit of the motor
  18612. */
  18613. setLimit(upperLimit: number, lowerLimit?: number): void;
  18614. }
  18615. /**
  18616. * This class represents a dual hinge physics joint (same as wheel joint)
  18617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18618. */
  18619. export class Hinge2Joint extends MotorEnabledJoint {
  18620. /**
  18621. * Initializes the Hinge2-Joint
  18622. * @param jointData The joint data for the Hinge2-Joint
  18623. */
  18624. constructor(jointData: PhysicsJointData);
  18625. /**
  18626. * Set the motor values.
  18627. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18628. * @param {number} force the force to apply
  18629. * @param {number} maxForce max force for this motor.
  18630. * @param {motorIndex} the motor's index, 0 or 1.
  18631. */
  18632. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18633. /**
  18634. * Set the motor limits.
  18635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18636. * @param {number} upperLimit the upper limit
  18637. * @param {number} lowerLimit lower limit
  18638. * @param {motorIndex} the motor's index, 0 or 1.
  18639. */
  18640. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18641. }
  18642. /**
  18643. * Interface for a motor enabled joint
  18644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18645. */
  18646. export interface IMotorEnabledJoint {
  18647. /**
  18648. * Physics joint
  18649. */
  18650. physicsJoint: any;
  18651. /**
  18652. * Sets the motor of the motor-enabled joint
  18653. * @param force The force of the motor
  18654. * @param maxForce The maximum force of the motor
  18655. * @param motorIndex The index of the motor
  18656. */
  18657. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18658. /**
  18659. * Sets the limit of the motor
  18660. * @param upperLimit The upper limit of the motor
  18661. * @param lowerLimit The lower limit of the motor
  18662. * @param motorIndex The index of the motor
  18663. */
  18664. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18665. }
  18666. /**
  18667. * Joint data for a Distance-Joint
  18668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18669. */
  18670. export interface DistanceJointData extends PhysicsJointData {
  18671. /**
  18672. * Max distance the 2 joint objects can be apart
  18673. */
  18674. maxDistance: number;
  18675. }
  18676. /**
  18677. * Joint data from a spring joint
  18678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18679. */
  18680. export interface SpringJointData extends PhysicsJointData {
  18681. /**
  18682. * Length of the spring
  18683. */
  18684. length: number;
  18685. /**
  18686. * Stiffness of the spring
  18687. */
  18688. stiffness: number;
  18689. /**
  18690. * Damping of the spring
  18691. */
  18692. damping: number;
  18693. /** this callback will be called when applying the force to the impostors. */
  18694. forceApplicationCallback: () => void;
  18695. }
  18696. }
  18697. declare module "babylonjs/Physics/IPhysicsEngine" {
  18698. import { Nullable } from "babylonjs/types";
  18699. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18701. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18702. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18703. /**
  18704. * Interface used to describe a physics joint
  18705. */
  18706. export interface PhysicsImpostorJoint {
  18707. /** Defines the main impostor to which the joint is linked */
  18708. mainImpostor: PhysicsImpostor;
  18709. /** Defines the impostor that is connected to the main impostor using this joint */
  18710. connectedImpostor: PhysicsImpostor;
  18711. /** Defines the joint itself */
  18712. joint: PhysicsJoint;
  18713. }
  18714. /** @hidden */
  18715. export interface IPhysicsEnginePlugin {
  18716. world: any;
  18717. name: string;
  18718. setGravity(gravity: Vector3): void;
  18719. setTimeStep(timeStep: number): void;
  18720. getTimeStep(): number;
  18721. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18725. removePhysicsBody(impostor: PhysicsImpostor): void;
  18726. generateJoint(joint: PhysicsImpostorJoint): void;
  18727. removeJoint(joint: PhysicsImpostorJoint): void;
  18728. isSupported(): boolean;
  18729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18736. getBodyMass(impostor: PhysicsImpostor): number;
  18737. getBodyFriction(impostor: PhysicsImpostor): number;
  18738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18739. getBodyRestitution(impostor: PhysicsImpostor): number;
  18740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18741. sleepBody(impostor: PhysicsImpostor): void;
  18742. wakeUpBody(impostor: PhysicsImpostor): void;
  18743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18746. getRadius(impostor: PhysicsImpostor): number;
  18747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18749. dispose(): void;
  18750. }
  18751. /**
  18752. * Interface used to define a physics engine
  18753. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18754. */
  18755. export interface IPhysicsEngine {
  18756. /**
  18757. * Gets the gravity vector used by the simulation
  18758. */
  18759. gravity: Vector3;
  18760. /**
  18761. * Sets the gravity vector used by the simulation
  18762. * @param gravity defines the gravity vector to use
  18763. */
  18764. setGravity(gravity: Vector3): void;
  18765. /**
  18766. * Set the time step of the physics engine.
  18767. * Default is 1/60.
  18768. * To slow it down, enter 1/600 for example.
  18769. * To speed it up, 1/30
  18770. * @param newTimeStep the new timestep to apply to this world.
  18771. */
  18772. setTimeStep(newTimeStep: number): void;
  18773. /**
  18774. * Get the time step of the physics engine.
  18775. * @returns the current time step
  18776. */
  18777. getTimeStep(): number;
  18778. /**
  18779. * Release all resources
  18780. */
  18781. dispose(): void;
  18782. /**
  18783. * Gets the name of the current physics plugin
  18784. * @returns the name of the plugin
  18785. */
  18786. getPhysicsPluginName(): string;
  18787. /**
  18788. * Adding a new impostor for the impostor tracking.
  18789. * This will be done by the impostor itself.
  18790. * @param impostor the impostor to add
  18791. */
  18792. addImpostor(impostor: PhysicsImpostor): void;
  18793. /**
  18794. * Remove an impostor from the engine.
  18795. * This impostor and its mesh will not longer be updated by the physics engine.
  18796. * @param impostor the impostor to remove
  18797. */
  18798. removeImpostor(impostor: PhysicsImpostor): void;
  18799. /**
  18800. * Add a joint to the physics engine
  18801. * @param mainImpostor defines the main impostor to which the joint is added.
  18802. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18803. * @param joint defines the joint that will connect both impostors.
  18804. */
  18805. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18806. /**
  18807. * Removes a joint from the simulation
  18808. * @param mainImpostor defines the impostor used with the joint
  18809. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18810. * @param joint defines the joint to remove
  18811. */
  18812. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18813. /**
  18814. * Gets the current plugin used to run the simulation
  18815. * @returns current plugin
  18816. */
  18817. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18818. /**
  18819. * Gets the list of physic impostors
  18820. * @returns an array of PhysicsImpostor
  18821. */
  18822. getImpostors(): Array<PhysicsImpostor>;
  18823. /**
  18824. * Gets the impostor for a physics enabled object
  18825. * @param object defines the object impersonated by the impostor
  18826. * @returns the PhysicsImpostor or null if not found
  18827. */
  18828. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18829. /**
  18830. * Gets the impostor for a physics body object
  18831. * @param body defines physics body used by the impostor
  18832. * @returns the PhysicsImpostor or null if not found
  18833. */
  18834. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18835. /**
  18836. * Called by the scene. No need to call it.
  18837. * @param delta defines the timespam between frames
  18838. */
  18839. _step(delta: number): void;
  18840. }
  18841. }
  18842. declare module "babylonjs/Physics/physicsImpostor" {
  18843. import { Nullable, IndicesArray } from "babylonjs/types";
  18844. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  18845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  18846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18847. import { Scene } from "babylonjs/scene";
  18848. import { Bone } from "babylonjs/Bones/bone";
  18849. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  18850. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  18851. /**
  18852. * The interface for the physics imposter parameters
  18853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18854. */
  18855. export interface PhysicsImpostorParameters {
  18856. /**
  18857. * The mass of the physics imposter
  18858. */
  18859. mass: number;
  18860. /**
  18861. * The friction of the physics imposter
  18862. */
  18863. friction?: number;
  18864. /**
  18865. * The coefficient of restitution of the physics imposter
  18866. */
  18867. restitution?: number;
  18868. /**
  18869. * The native options of the physics imposter
  18870. */
  18871. nativeOptions?: any;
  18872. /**
  18873. * Specifies if the parent should be ignored
  18874. */
  18875. ignoreParent?: boolean;
  18876. /**
  18877. * Specifies if bi-directional transformations should be disabled
  18878. */
  18879. disableBidirectionalTransformation?: boolean;
  18880. }
  18881. /**
  18882. * Interface for a physics-enabled object
  18883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18884. */
  18885. export interface IPhysicsEnabledObject {
  18886. /**
  18887. * The position of the physics-enabled object
  18888. */
  18889. position: Vector3;
  18890. /**
  18891. * The rotation of the physics-enabled object
  18892. */
  18893. rotationQuaternion: Nullable<Quaternion>;
  18894. /**
  18895. * The scale of the physics-enabled object
  18896. */
  18897. scaling: Vector3;
  18898. /**
  18899. * The rotation of the physics-enabled object
  18900. */
  18901. rotation?: Vector3;
  18902. /**
  18903. * The parent of the physics-enabled object
  18904. */
  18905. parent?: any;
  18906. /**
  18907. * The bounding info of the physics-enabled object
  18908. * @returns The bounding info of the physics-enabled object
  18909. */
  18910. getBoundingInfo(): BoundingInfo;
  18911. /**
  18912. * Computes the world matrix
  18913. * @param force Specifies if the world matrix should be computed by force
  18914. * @returns A world matrix
  18915. */
  18916. computeWorldMatrix(force: boolean): Matrix;
  18917. /**
  18918. * Gets the world matrix
  18919. * @returns A world matrix
  18920. */
  18921. getWorldMatrix?(): Matrix;
  18922. /**
  18923. * Gets the child meshes
  18924. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18925. * @returns An array of abstract meshes
  18926. */
  18927. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18928. /**
  18929. * Gets the vertex data
  18930. * @param kind The type of vertex data
  18931. * @returns A nullable array of numbers, or a float32 array
  18932. */
  18933. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18934. /**
  18935. * Gets the indices from the mesh
  18936. * @returns A nullable array of index arrays
  18937. */
  18938. getIndices?(): Nullable<IndicesArray>;
  18939. /**
  18940. * Gets the scene from the mesh
  18941. * @returns the indices array or null
  18942. */
  18943. getScene?(): Scene;
  18944. /**
  18945. * Gets the absolute position from the mesh
  18946. * @returns the absolute position
  18947. */
  18948. getAbsolutePosition(): Vector3;
  18949. /**
  18950. * Gets the absolute pivot point from the mesh
  18951. * @returns the absolute pivot point
  18952. */
  18953. getAbsolutePivotPoint(): Vector3;
  18954. /**
  18955. * Rotates the mesh
  18956. * @param axis The axis of rotation
  18957. * @param amount The amount of rotation
  18958. * @param space The space of the rotation
  18959. * @returns The rotation transform node
  18960. */
  18961. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18962. /**
  18963. * Translates the mesh
  18964. * @param axis The axis of translation
  18965. * @param distance The distance of translation
  18966. * @param space The space of the translation
  18967. * @returns The transform node
  18968. */
  18969. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18970. /**
  18971. * Sets the absolute position of the mesh
  18972. * @param absolutePosition The absolute position of the mesh
  18973. * @returns The transform node
  18974. */
  18975. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18976. /**
  18977. * Gets the class name of the mesh
  18978. * @returns The class name
  18979. */
  18980. getClassName(): string;
  18981. }
  18982. /**
  18983. * Represents a physics imposter
  18984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18985. */
  18986. export class PhysicsImpostor {
  18987. /**
  18988. * The physics-enabled object used as the physics imposter
  18989. */
  18990. object: IPhysicsEnabledObject;
  18991. /**
  18992. * The type of the physics imposter
  18993. */
  18994. type: number;
  18995. private _options;
  18996. private _scene?;
  18997. /**
  18998. * The default object size of the imposter
  18999. */
  19000. static DEFAULT_OBJECT_SIZE: Vector3;
  19001. /**
  19002. * The identity quaternion of the imposter
  19003. */
  19004. static IDENTITY_QUATERNION: Quaternion;
  19005. /** @hidden */
  19006. _pluginData: any;
  19007. private _physicsEngine;
  19008. private _physicsBody;
  19009. private _bodyUpdateRequired;
  19010. private _onBeforePhysicsStepCallbacks;
  19011. private _onAfterPhysicsStepCallbacks;
  19012. /** @hidden */
  19013. _onPhysicsCollideCallbacks: Array<{
  19014. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19015. otherImpostors: Array<PhysicsImpostor>;
  19016. }>;
  19017. private _deltaPosition;
  19018. private _deltaRotation;
  19019. private _deltaRotationConjugated;
  19020. private _parent;
  19021. private _isDisposed;
  19022. private static _tmpVecs;
  19023. private static _tmpQuat;
  19024. /**
  19025. * Specifies if the physics imposter is disposed
  19026. */
  19027. readonly isDisposed: boolean;
  19028. /**
  19029. * Gets the mass of the physics imposter
  19030. */
  19031. mass: number;
  19032. /**
  19033. * Gets the coefficient of friction
  19034. */
  19035. /**
  19036. * Sets the coefficient of friction
  19037. */
  19038. friction: number;
  19039. /**
  19040. * Gets the coefficient of restitution
  19041. */
  19042. /**
  19043. * Sets the coefficient of restitution
  19044. */
  19045. restitution: number;
  19046. /**
  19047. * The unique id of the physics imposter
  19048. * set by the physics engine when adding this impostor to the array
  19049. */
  19050. uniqueId: number;
  19051. private _joints;
  19052. /**
  19053. * Initializes the physics imposter
  19054. * @param object The physics-enabled object used as the physics imposter
  19055. * @param type The type of the physics imposter
  19056. * @param _options The options for the physics imposter
  19057. * @param _scene The Babylon scene
  19058. */
  19059. constructor(
  19060. /**
  19061. * The physics-enabled object used as the physics imposter
  19062. */
  19063. object: IPhysicsEnabledObject,
  19064. /**
  19065. * The type of the physics imposter
  19066. */
  19067. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19068. /**
  19069. * This function will completly initialize this impostor.
  19070. * It will create a new body - but only if this mesh has no parent.
  19071. * If it has, this impostor will not be used other than to define the impostor
  19072. * of the child mesh.
  19073. * @hidden
  19074. */
  19075. _init(): void;
  19076. private _getPhysicsParent;
  19077. /**
  19078. * Should a new body be generated.
  19079. * @returns boolean specifying if body initialization is required
  19080. */
  19081. isBodyInitRequired(): boolean;
  19082. /**
  19083. * Sets the updated scaling
  19084. * @param updated Specifies if the scaling is updated
  19085. */
  19086. setScalingUpdated(): void;
  19087. /**
  19088. * Force a regeneration of this or the parent's impostor's body.
  19089. * Use under cautious - This will remove all joints already implemented.
  19090. */
  19091. forceUpdate(): void;
  19092. /**
  19093. * Gets the body that holds this impostor. Either its own, or its parent.
  19094. */
  19095. /**
  19096. * Set the physics body. Used mainly by the physics engine/plugin
  19097. */
  19098. physicsBody: any;
  19099. /**
  19100. * Get the parent of the physics imposter
  19101. * @returns Physics imposter or null
  19102. */
  19103. /**
  19104. * Sets the parent of the physics imposter
  19105. */
  19106. parent: Nullable<PhysicsImpostor>;
  19107. /**
  19108. * Resets the update flags
  19109. */
  19110. resetUpdateFlags(): void;
  19111. /**
  19112. * Gets the object extend size
  19113. * @returns the object extend size
  19114. */
  19115. getObjectExtendSize(): Vector3;
  19116. /**
  19117. * Gets the object center
  19118. * @returns The object center
  19119. */
  19120. getObjectCenter(): Vector3;
  19121. /**
  19122. * Get a specific parametes from the options parameter
  19123. * @param paramName The object parameter name
  19124. * @returns The object parameter
  19125. */
  19126. getParam(paramName: string): any;
  19127. /**
  19128. * Sets a specific parameter in the options given to the physics plugin
  19129. * @param paramName The parameter name
  19130. * @param value The value of the parameter
  19131. */
  19132. setParam(paramName: string, value: number): void;
  19133. /**
  19134. * Specifically change the body's mass option. Won't recreate the physics body object
  19135. * @param mass The mass of the physics imposter
  19136. */
  19137. setMass(mass: number): void;
  19138. /**
  19139. * Gets the linear velocity
  19140. * @returns linear velocity or null
  19141. */
  19142. getLinearVelocity(): Nullable<Vector3>;
  19143. /**
  19144. * Sets the linear velocity
  19145. * @param velocity linear velocity or null
  19146. */
  19147. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19148. /**
  19149. * Gets the angular velocity
  19150. * @returns angular velocity or null
  19151. */
  19152. getAngularVelocity(): Nullable<Vector3>;
  19153. /**
  19154. * Sets the angular velocity
  19155. * @param velocity The velocity or null
  19156. */
  19157. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19158. /**
  19159. * Execute a function with the physics plugin native code
  19160. * Provide a function the will have two variables - the world object and the physics body object
  19161. * @param func The function to execute with the physics plugin native code
  19162. */
  19163. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19164. /**
  19165. * Register a function that will be executed before the physics world is stepping forward
  19166. * @param func The function to execute before the physics world is stepped forward
  19167. */
  19168. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19169. /**
  19170. * Unregister a function that will be executed before the physics world is stepping forward
  19171. * @param func The function to execute before the physics world is stepped forward
  19172. */
  19173. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19174. /**
  19175. * Register a function that will be executed after the physics step
  19176. * @param func The function to execute after physics step
  19177. */
  19178. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19179. /**
  19180. * Unregisters a function that will be executed after the physics step
  19181. * @param func The function to execute after physics step
  19182. */
  19183. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19184. /**
  19185. * register a function that will be executed when this impostor collides against a different body
  19186. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19187. * @param func Callback that is executed on collision
  19188. */
  19189. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19190. /**
  19191. * Unregisters the physics imposter on contact
  19192. * @param collideAgainst The physics object to collide against
  19193. * @param func Callback to execute on collision
  19194. */
  19195. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19196. private _tmpQuat;
  19197. private _tmpQuat2;
  19198. /**
  19199. * Get the parent rotation
  19200. * @returns The parent rotation
  19201. */
  19202. getParentsRotation(): Quaternion;
  19203. /**
  19204. * this function is executed by the physics engine.
  19205. */
  19206. beforeStep: () => void;
  19207. /**
  19208. * this function is executed by the physics engine
  19209. */
  19210. afterStep: () => void;
  19211. /**
  19212. * Legacy collision detection event support
  19213. */
  19214. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19215. /**
  19216. * event and body object due to cannon's event-based architecture.
  19217. */
  19218. onCollide: (e: {
  19219. body: any;
  19220. }) => void;
  19221. /**
  19222. * Apply a force
  19223. * @param force The force to apply
  19224. * @param contactPoint The contact point for the force
  19225. * @returns The physics imposter
  19226. */
  19227. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19228. /**
  19229. * Apply an impulse
  19230. * @param force The impulse force
  19231. * @param contactPoint The contact point for the impulse force
  19232. * @returns The physics imposter
  19233. */
  19234. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19235. /**
  19236. * A help function to create a joint
  19237. * @param otherImpostor A physics imposter used to create a joint
  19238. * @param jointType The type of joint
  19239. * @param jointData The data for the joint
  19240. * @returns The physics imposter
  19241. */
  19242. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19243. /**
  19244. * Add a joint to this impostor with a different impostor
  19245. * @param otherImpostor A physics imposter used to add a joint
  19246. * @param joint The joint to add
  19247. * @returns The physics imposter
  19248. */
  19249. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19250. /**
  19251. * Will keep this body still, in a sleep mode.
  19252. * @returns the physics imposter
  19253. */
  19254. sleep(): PhysicsImpostor;
  19255. /**
  19256. * Wake the body up.
  19257. * @returns The physics imposter
  19258. */
  19259. wakeUp(): PhysicsImpostor;
  19260. /**
  19261. * Clones the physics imposter
  19262. * @param newObject The physics imposter clones to this physics-enabled object
  19263. * @returns A nullable physics imposter
  19264. */
  19265. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19266. /**
  19267. * Disposes the physics imposter
  19268. */
  19269. dispose(): void;
  19270. /**
  19271. * Sets the delta position
  19272. * @param position The delta position amount
  19273. */
  19274. setDeltaPosition(position: Vector3): void;
  19275. /**
  19276. * Sets the delta rotation
  19277. * @param rotation The delta rotation amount
  19278. */
  19279. setDeltaRotation(rotation: Quaternion): void;
  19280. /**
  19281. * Gets the box size of the physics imposter and stores the result in the input parameter
  19282. * @param result Stores the box size
  19283. * @returns The physics imposter
  19284. */
  19285. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19286. /**
  19287. * Gets the radius of the physics imposter
  19288. * @returns Radius of the physics imposter
  19289. */
  19290. getRadius(): number;
  19291. /**
  19292. * Sync a bone with this impostor
  19293. * @param bone The bone to sync to the impostor.
  19294. * @param boneMesh The mesh that the bone is influencing.
  19295. * @param jointPivot The pivot of the joint / bone in local space.
  19296. * @param distToJoint Optional distance from the impostor to the joint.
  19297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19298. */
  19299. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19300. /**
  19301. * Sync impostor to a bone
  19302. * @param bone The bone that the impostor will be synced to.
  19303. * @param boneMesh The mesh that the bone is influencing.
  19304. * @param jointPivot The pivot of the joint / bone in local space.
  19305. * @param distToJoint Optional distance from the impostor to the joint.
  19306. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19307. * @param boneAxis Optional vector3 axis the bone is aligned with
  19308. */
  19309. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19310. /**
  19311. * No-Imposter type
  19312. */
  19313. static NoImpostor: number;
  19314. /**
  19315. * Sphere-Imposter type
  19316. */
  19317. static SphereImpostor: number;
  19318. /**
  19319. * Box-Imposter type
  19320. */
  19321. static BoxImpostor: number;
  19322. /**
  19323. * Plane-Imposter type
  19324. */
  19325. static PlaneImpostor: number;
  19326. /**
  19327. * Mesh-imposter type
  19328. */
  19329. static MeshImpostor: number;
  19330. /**
  19331. * Cylinder-Imposter type
  19332. */
  19333. static CylinderImpostor: number;
  19334. /**
  19335. * Particle-Imposter type
  19336. */
  19337. static ParticleImpostor: number;
  19338. /**
  19339. * Heightmap-Imposter type
  19340. */
  19341. static HeightmapImpostor: number;
  19342. }
  19343. }
  19344. declare module "babylonjs/Meshes/groundMesh" {
  19345. import { Scene } from "babylonjs/scene";
  19346. import { Vector3 } from "babylonjs/Maths/math";
  19347. import { Mesh } from "babylonjs/Meshes/mesh";
  19348. /**
  19349. * Mesh representing the gorund
  19350. */
  19351. export class GroundMesh extends Mesh {
  19352. /** If octree should be generated */
  19353. generateOctree: boolean;
  19354. private _heightQuads;
  19355. /** @hidden */
  19356. _subdivisionsX: number;
  19357. /** @hidden */
  19358. _subdivisionsY: number;
  19359. /** @hidden */
  19360. _width: number;
  19361. /** @hidden */
  19362. _height: number;
  19363. /** @hidden */
  19364. _minX: number;
  19365. /** @hidden */
  19366. _maxX: number;
  19367. /** @hidden */
  19368. _minZ: number;
  19369. /** @hidden */
  19370. _maxZ: number;
  19371. constructor(name: string, scene: Scene);
  19372. /**
  19373. * "GroundMesh"
  19374. * @returns "GroundMesh"
  19375. */
  19376. getClassName(): string;
  19377. /**
  19378. * The minimum of x and y subdivisions
  19379. */
  19380. readonly subdivisions: number;
  19381. /**
  19382. * X subdivisions
  19383. */
  19384. readonly subdivisionsX: number;
  19385. /**
  19386. * Y subdivisions
  19387. */
  19388. readonly subdivisionsY: number;
  19389. /**
  19390. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19391. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19392. * @param chunksCount the number of subdivisions for x and y
  19393. * @param octreeBlocksSize (Default: 32)
  19394. */
  19395. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19396. /**
  19397. * Returns a height (y) value in the Worl system :
  19398. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19399. * @param x x coordinate
  19400. * @param z z coordinate
  19401. * @returns the ground y position if (x, z) are outside the ground surface.
  19402. */
  19403. getHeightAtCoordinates(x: number, z: number): number;
  19404. /**
  19405. * Returns a normalized vector (Vector3) orthogonal to the ground
  19406. * at the ground coordinates (x, z) expressed in the World system.
  19407. * @param x x coordinate
  19408. * @param z z coordinate
  19409. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19410. */
  19411. getNormalAtCoordinates(x: number, z: number): Vector3;
  19412. /**
  19413. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19414. * at the ground coordinates (x, z) expressed in the World system.
  19415. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19416. * @param x x coordinate
  19417. * @param z z coordinate
  19418. * @param ref vector to store the result
  19419. * @returns the GroundMesh.
  19420. */
  19421. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19422. /**
  19423. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19424. * if the ground has been updated.
  19425. * This can be used in the render loop.
  19426. * @returns the GroundMesh.
  19427. */
  19428. updateCoordinateHeights(): GroundMesh;
  19429. private _getFacetAt;
  19430. private _initHeightQuads;
  19431. private _computeHeightQuads;
  19432. /**
  19433. * Serializes this ground mesh
  19434. * @param serializationObject object to write serialization to
  19435. */
  19436. serialize(serializationObject: any): void;
  19437. /**
  19438. * Parses a serialized ground mesh
  19439. * @param parsedMesh the serialized mesh
  19440. * @param scene the scene to create the ground mesh in
  19441. * @returns the created ground mesh
  19442. */
  19443. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19444. }
  19445. }
  19446. declare module "babylonjs/Meshes/mesh" {
  19447. import { Observable } from "babylonjs/Misc/observable";
  19448. import { IAnimatable } from "babylonjs/Misc/tools";
  19449. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19450. import { Camera } from "babylonjs/Cameras/camera";
  19451. import { Scene } from "babylonjs/scene";
  19452. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19453. import { Engine } from "babylonjs/Engines/engine";
  19454. import { Node } from "babylonjs/node";
  19455. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19456. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19457. import { Buffer } from "babylonjs/Meshes/buffer";
  19458. import { Geometry } from "babylonjs/Meshes/geometry";
  19459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19461. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19462. import { Effect } from "babylonjs/Materials/effect";
  19463. import { Material } from "babylonjs/Materials/material";
  19464. import { Skeleton } from "babylonjs/Bones/skeleton";
  19465. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19466. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19467. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19468. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19469. /**
  19470. * Class used to represent a specific level of detail of a mesh
  19471. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19472. */
  19473. export class MeshLODLevel {
  19474. /** Defines the distance where this level should star being displayed */
  19475. distance: number;
  19476. /** Defines the mesh to use to render this level */
  19477. mesh: Nullable<Mesh>;
  19478. /**
  19479. * Creates a new LOD level
  19480. * @param distance defines the distance where this level should star being displayed
  19481. * @param mesh defines the mesh to use to render this level
  19482. */
  19483. constructor(
  19484. /** Defines the distance where this level should star being displayed */
  19485. distance: number,
  19486. /** Defines the mesh to use to render this level */
  19487. mesh: Nullable<Mesh>);
  19488. }
  19489. /**
  19490. * @hidden
  19491. **/
  19492. export class _CreationDataStorage {
  19493. closePath?: boolean;
  19494. closeArray?: boolean;
  19495. idx: number[];
  19496. dashSize: number;
  19497. gapSize: number;
  19498. path3D: Path3D;
  19499. pathArray: Vector3[][];
  19500. arc: number;
  19501. radius: number;
  19502. cap: number;
  19503. tessellation: number;
  19504. }
  19505. /**
  19506. * @hidden
  19507. **/
  19508. class _InstanceDataStorage {
  19509. visibleInstances: any;
  19510. renderIdForInstances: number[];
  19511. batchCache: _InstancesBatch;
  19512. instancesBufferSize: number;
  19513. instancesBuffer: Nullable<Buffer>;
  19514. instancesData: Float32Array;
  19515. overridenInstanceCount: number;
  19516. }
  19517. /**
  19518. * @hidden
  19519. **/
  19520. export class _InstancesBatch {
  19521. mustReturn: boolean;
  19522. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19523. renderSelf: boolean[];
  19524. }
  19525. /**
  19526. * Class used to represent renderable models
  19527. */
  19528. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19529. /**
  19530. * Mesh side orientation : usually the external or front surface
  19531. */
  19532. static readonly FRONTSIDE: number;
  19533. /**
  19534. * Mesh side orientation : usually the internal or back surface
  19535. */
  19536. static readonly BACKSIDE: number;
  19537. /**
  19538. * Mesh side orientation : both internal and external or front and back surfaces
  19539. */
  19540. static readonly DOUBLESIDE: number;
  19541. /**
  19542. * Mesh side orientation : by default, `FRONTSIDE`
  19543. */
  19544. static readonly DEFAULTSIDE: number;
  19545. /**
  19546. * Mesh cap setting : no cap
  19547. */
  19548. static readonly NO_CAP: number;
  19549. /**
  19550. * Mesh cap setting : one cap at the beginning of the mesh
  19551. */
  19552. static readonly CAP_START: number;
  19553. /**
  19554. * Mesh cap setting : one cap at the end of the mesh
  19555. */
  19556. static readonly CAP_END: number;
  19557. /**
  19558. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19559. */
  19560. static readonly CAP_ALL: number;
  19561. private _onBeforeRenderObservable;
  19562. private _onBeforeBindObservable;
  19563. private _onAfterRenderObservable;
  19564. private _onBeforeDrawObservable;
  19565. /**
  19566. * An event triggered before rendering the mesh
  19567. */
  19568. readonly onBeforeRenderObservable: Observable<Mesh>;
  19569. /**
  19570. * An event triggered before binding the mesh
  19571. */
  19572. readonly onBeforeBindObservable: Observable<Mesh>;
  19573. /**
  19574. * An event triggered after rendering the mesh
  19575. */
  19576. readonly onAfterRenderObservable: Observable<Mesh>;
  19577. /**
  19578. * An event triggered before drawing the mesh
  19579. */
  19580. readonly onBeforeDrawObservable: Observable<Mesh>;
  19581. private _onBeforeDrawObserver;
  19582. /**
  19583. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19584. */
  19585. onBeforeDraw: () => void;
  19586. /**
  19587. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19588. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19589. */
  19590. delayLoadState: number;
  19591. /**
  19592. * Gets the list of instances created from this mesh
  19593. * it is not supposed to be modified manually.
  19594. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19595. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19596. */
  19597. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19598. /**
  19599. * Gets the file containing delay loading data for this mesh
  19600. */
  19601. delayLoadingFile: string;
  19602. /** @hidden */
  19603. _binaryInfo: any;
  19604. private _LODLevels;
  19605. /**
  19606. * User defined function used to change how LOD level selection is done
  19607. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19608. */
  19609. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19610. private _morphTargetManager;
  19611. /**
  19612. * Gets or sets the morph target manager
  19613. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19614. */
  19615. morphTargetManager: Nullable<MorphTargetManager>;
  19616. /** @hidden */
  19617. _creationDataStorage: Nullable<_CreationDataStorage>;
  19618. /** @hidden */
  19619. _geometry: Nullable<Geometry>;
  19620. /** @hidden */
  19621. _delayInfo: Array<string>;
  19622. /** @hidden */
  19623. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19624. /** @hidden */
  19625. _instanceDataStorage: _InstanceDataStorage;
  19626. private _effectiveMaterial;
  19627. /** @hidden */
  19628. _shouldGenerateFlatShading: boolean;
  19629. private _preActivateId;
  19630. /** @hidden */
  19631. _originalBuilderSideOrientation: number;
  19632. /**
  19633. * Use this property to change the original side orientation defined at construction time
  19634. */
  19635. overrideMaterialSideOrientation: Nullable<number>;
  19636. private _areNormalsFrozen;
  19637. private _sourcePositions;
  19638. private _sourceNormals;
  19639. private _source;
  19640. private meshMap;
  19641. /**
  19642. * Gets the source mesh (the one used to clone this one from)
  19643. */
  19644. readonly source: Nullable<Mesh>;
  19645. /**
  19646. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19647. */
  19648. isUnIndexed: boolean;
  19649. /**
  19650. * @constructor
  19651. * @param name The value used by scene.getMeshByName() to do a lookup.
  19652. * @param scene The scene to add this mesh to.
  19653. * @param parent The parent of this mesh, if it has one
  19654. * @param source An optional Mesh from which geometry is shared, cloned.
  19655. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19656. * When false, achieved by calling a clone(), also passing False.
  19657. * This will make creation of children, recursive.
  19658. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19659. */
  19660. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19661. /**
  19662. * Gets the class name
  19663. * @returns the string "Mesh".
  19664. */
  19665. getClassName(): string;
  19666. /** @hidden */
  19667. readonly _isMesh: boolean;
  19668. /**
  19669. * Returns a description of this mesh
  19670. * @param fullDetails define if full details about this mesh must be used
  19671. * @returns a descriptive string representing this mesh
  19672. */
  19673. toString(fullDetails?: boolean): string;
  19674. /** @hidden */
  19675. _unBindEffect(): void;
  19676. /**
  19677. * Gets a boolean indicating if this mesh has LOD
  19678. */
  19679. readonly hasLODLevels: boolean;
  19680. /**
  19681. * Gets the list of MeshLODLevel associated with the current mesh
  19682. * @returns an array of MeshLODLevel
  19683. */
  19684. getLODLevels(): MeshLODLevel[];
  19685. private _sortLODLevels;
  19686. /**
  19687. * Add a mesh as LOD level triggered at the given distance.
  19688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19689. * @param distance The distance from the center of the object to show this level
  19690. * @param mesh The mesh to be added as LOD level (can be null)
  19691. * @return This mesh (for chaining)
  19692. */
  19693. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19694. /**
  19695. * Returns the LOD level mesh at the passed distance or null if not found.
  19696. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19697. * @param distance The distance from the center of the object to show this level
  19698. * @returns a Mesh or `null`
  19699. */
  19700. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19701. /**
  19702. * Remove a mesh from the LOD array
  19703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19704. * @param mesh defines the mesh to be removed
  19705. * @return This mesh (for chaining)
  19706. */
  19707. removeLODLevel(mesh: Mesh): Mesh;
  19708. /**
  19709. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19711. * @param camera defines the camera to use to compute distance
  19712. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19713. * @return This mesh (for chaining)
  19714. */
  19715. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19716. /**
  19717. * Gets the mesh internal Geometry object
  19718. */
  19719. readonly geometry: Nullable<Geometry>;
  19720. /**
  19721. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19722. * @returns the total number of vertices
  19723. */
  19724. getTotalVertices(): number;
  19725. /**
  19726. * Returns the content of an associated vertex buffer
  19727. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19728. * - VertexBuffer.PositionKind
  19729. * - VertexBuffer.UVKind
  19730. * - VertexBuffer.UV2Kind
  19731. * - VertexBuffer.UV3Kind
  19732. * - VertexBuffer.UV4Kind
  19733. * - VertexBuffer.UV5Kind
  19734. * - VertexBuffer.UV6Kind
  19735. * - VertexBuffer.ColorKind
  19736. * - VertexBuffer.MatricesIndicesKind
  19737. * - VertexBuffer.MatricesIndicesExtraKind
  19738. * - VertexBuffer.MatricesWeightsKind
  19739. * - VertexBuffer.MatricesWeightsExtraKind
  19740. * @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
  19741. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19742. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19743. */
  19744. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19745. /**
  19746. * Returns the mesh VertexBuffer object from the requested `kind`
  19747. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19748. * - VertexBuffer.PositionKind
  19749. * - VertexBuffer.UVKind
  19750. * - VertexBuffer.UV2Kind
  19751. * - VertexBuffer.UV3Kind
  19752. * - VertexBuffer.UV4Kind
  19753. * - VertexBuffer.UV5Kind
  19754. * - VertexBuffer.UV6Kind
  19755. * - VertexBuffer.ColorKind
  19756. * - VertexBuffer.MatricesIndicesKind
  19757. * - VertexBuffer.MatricesIndicesExtraKind
  19758. * - VertexBuffer.MatricesWeightsKind
  19759. * - VertexBuffer.MatricesWeightsExtraKind
  19760. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19761. */
  19762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19763. /**
  19764. * Tests if a specific vertex buffer is associated with this mesh
  19765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19766. * - VertexBuffer.PositionKind
  19767. * - VertexBuffer.UVKind
  19768. * - VertexBuffer.UV2Kind
  19769. * - VertexBuffer.UV3Kind
  19770. * - VertexBuffer.UV4Kind
  19771. * - VertexBuffer.UV5Kind
  19772. * - VertexBuffer.UV6Kind
  19773. * - VertexBuffer.ColorKind
  19774. * - VertexBuffer.MatricesIndicesKind
  19775. * - VertexBuffer.MatricesIndicesExtraKind
  19776. * - VertexBuffer.MatricesWeightsKind
  19777. * - VertexBuffer.MatricesWeightsExtraKind
  19778. * @returns a boolean
  19779. */
  19780. isVerticesDataPresent(kind: string): boolean;
  19781. /**
  19782. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19783. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19784. * - VertexBuffer.PositionKind
  19785. * - VertexBuffer.UVKind
  19786. * - VertexBuffer.UV2Kind
  19787. * - VertexBuffer.UV3Kind
  19788. * - VertexBuffer.UV4Kind
  19789. * - VertexBuffer.UV5Kind
  19790. * - VertexBuffer.UV6Kind
  19791. * - VertexBuffer.ColorKind
  19792. * - VertexBuffer.MatricesIndicesKind
  19793. * - VertexBuffer.MatricesIndicesExtraKind
  19794. * - VertexBuffer.MatricesWeightsKind
  19795. * - VertexBuffer.MatricesWeightsExtraKind
  19796. * @returns a boolean
  19797. */
  19798. isVertexBufferUpdatable(kind: string): boolean;
  19799. /**
  19800. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19801. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19802. * - VertexBuffer.PositionKind
  19803. * - VertexBuffer.UVKind
  19804. * - VertexBuffer.UV2Kind
  19805. * - VertexBuffer.UV3Kind
  19806. * - VertexBuffer.UV4Kind
  19807. * - VertexBuffer.UV5Kind
  19808. * - VertexBuffer.UV6Kind
  19809. * - VertexBuffer.ColorKind
  19810. * - VertexBuffer.MatricesIndicesKind
  19811. * - VertexBuffer.MatricesIndicesExtraKind
  19812. * - VertexBuffer.MatricesWeightsKind
  19813. * - VertexBuffer.MatricesWeightsExtraKind
  19814. * @returns an array of strings
  19815. */
  19816. getVerticesDataKinds(): string[];
  19817. /**
  19818. * Returns a positive integer : the total number of indices in this mesh geometry.
  19819. * @returns the numner of indices or zero if the mesh has no geometry.
  19820. */
  19821. getTotalIndices(): number;
  19822. /**
  19823. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19824. * @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.
  19825. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19826. * @returns the indices array or an empty array if the mesh has no geometry
  19827. */
  19828. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19829. readonly isBlocked: boolean;
  19830. /**
  19831. * Determine if the current mesh is ready to be rendered
  19832. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19833. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19834. * @returns true if all associated assets are ready (material, textures, shaders)
  19835. */
  19836. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19837. /**
  19838. * 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.
  19839. */
  19840. readonly areNormalsFrozen: boolean;
  19841. /**
  19842. * 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.
  19843. * @returns the current mesh
  19844. */
  19845. freezeNormals(): Mesh;
  19846. /**
  19847. * 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
  19848. * @returns the current mesh
  19849. */
  19850. unfreezeNormals(): Mesh;
  19851. /**
  19852. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19853. */
  19854. overridenInstanceCount: number;
  19855. /** @hidden */
  19856. _preActivate(): Mesh;
  19857. /** @hidden */
  19858. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19859. /** @hidden */
  19860. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19861. /**
  19862. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19863. * This means the mesh underlying bounding box and sphere are recomputed.
  19864. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19865. * @returns the current mesh
  19866. */
  19867. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19868. /** @hidden */
  19869. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19870. /**
  19871. * This function will subdivide the mesh into multiple submeshes
  19872. * @param count defines the expected number of submeshes
  19873. */
  19874. subdivide(count: number): void;
  19875. /**
  19876. * Copy a FloatArray into a specific associated vertex buffer
  19877. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19878. * - VertexBuffer.PositionKind
  19879. * - VertexBuffer.UVKind
  19880. * - VertexBuffer.UV2Kind
  19881. * - VertexBuffer.UV3Kind
  19882. * - VertexBuffer.UV4Kind
  19883. * - VertexBuffer.UV5Kind
  19884. * - VertexBuffer.UV6Kind
  19885. * - VertexBuffer.ColorKind
  19886. * - VertexBuffer.MatricesIndicesKind
  19887. * - VertexBuffer.MatricesIndicesExtraKind
  19888. * - VertexBuffer.MatricesWeightsKind
  19889. * - VertexBuffer.MatricesWeightsExtraKind
  19890. * @param data defines the data source
  19891. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19892. * @param stride defines the data stride size (can be null)
  19893. * @returns the current mesh
  19894. */
  19895. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19896. /**
  19897. * Flags an associated vertex buffer as updatable
  19898. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19899. * - VertexBuffer.PositionKind
  19900. * - VertexBuffer.UVKind
  19901. * - VertexBuffer.UV2Kind
  19902. * - VertexBuffer.UV3Kind
  19903. * - VertexBuffer.UV4Kind
  19904. * - VertexBuffer.UV5Kind
  19905. * - VertexBuffer.UV6Kind
  19906. * - VertexBuffer.ColorKind
  19907. * - VertexBuffer.MatricesIndicesKind
  19908. * - VertexBuffer.MatricesIndicesExtraKind
  19909. * - VertexBuffer.MatricesWeightsKind
  19910. * - VertexBuffer.MatricesWeightsExtraKind
  19911. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19912. */
  19913. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19914. /**
  19915. * Sets the mesh global Vertex Buffer
  19916. * @param buffer defines the buffer to use
  19917. * @returns the current mesh
  19918. */
  19919. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19920. /**
  19921. * Update a specific associated vertex buffer
  19922. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19923. * - VertexBuffer.PositionKind
  19924. * - VertexBuffer.UVKind
  19925. * - VertexBuffer.UV2Kind
  19926. * - VertexBuffer.UV3Kind
  19927. * - VertexBuffer.UV4Kind
  19928. * - VertexBuffer.UV5Kind
  19929. * - VertexBuffer.UV6Kind
  19930. * - VertexBuffer.ColorKind
  19931. * - VertexBuffer.MatricesIndicesKind
  19932. * - VertexBuffer.MatricesIndicesExtraKind
  19933. * - VertexBuffer.MatricesWeightsKind
  19934. * - VertexBuffer.MatricesWeightsExtraKind
  19935. * @param data defines the data source
  19936. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19937. * @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)
  19938. * @returns the current mesh
  19939. */
  19940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19941. /**
  19942. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19943. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19944. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19945. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19946. * @returns the current mesh
  19947. */
  19948. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19949. /**
  19950. * Creates a un-shared specific occurence of the geometry for the mesh.
  19951. * @returns the current mesh
  19952. */
  19953. makeGeometryUnique(): Mesh;
  19954. /**
  19955. * Set the index buffer of this mesh
  19956. * @param indices defines the source data
  19957. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19958. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19959. * @returns the current mesh
  19960. */
  19961. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19962. /**
  19963. * Update the current index buffer
  19964. * @param indices defines the source data
  19965. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19966. * @returns the current mesh
  19967. */
  19968. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19969. /**
  19970. * Invert the geometry to move from a right handed system to a left handed one.
  19971. * @returns the current mesh
  19972. */
  19973. toLeftHanded(): Mesh;
  19974. /** @hidden */
  19975. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19976. /** @hidden */
  19977. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19978. /**
  19979. * Registers for this mesh a javascript function called just before the rendering process
  19980. * @param func defines the function to call before rendering this mesh
  19981. * @returns the current mesh
  19982. */
  19983. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19984. /**
  19985. * Disposes a previously registered javascript function called before the rendering
  19986. * @param func defines the function to remove
  19987. * @returns the current mesh
  19988. */
  19989. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19990. /**
  19991. * Registers for this mesh a javascript function called just after the rendering is complete
  19992. * @param func defines the function to call after rendering this mesh
  19993. * @returns the current mesh
  19994. */
  19995. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19996. /**
  19997. * Disposes a previously registered javascript function called after the rendering.
  19998. * @param func defines the function to remove
  19999. * @returns the current mesh
  20000. */
  20001. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20002. /** @hidden */
  20003. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20004. /** @hidden */
  20005. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20006. /** @hidden */
  20007. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20008. /**
  20009. * 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
  20010. * @param subMesh defines the subMesh to render
  20011. * @param enableAlphaMode defines if alpha mode can be changed
  20012. * @returns the current mesh
  20013. */
  20014. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20015. private _onBeforeDraw;
  20016. /**
  20017. * Renormalize the mesh and patch it up if there are no weights
  20018. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20019. * However in the case of zero weights then we set just a single influence to 1.
  20020. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20021. */
  20022. cleanMatrixWeights(): void;
  20023. private normalizeSkinFourWeights;
  20024. private normalizeSkinWeightsAndExtra;
  20025. /**
  20026. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20027. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20028. * the user know there was an issue with importing the mesh
  20029. * @returns a validation object with skinned, valid and report string
  20030. */
  20031. validateSkinning(): {
  20032. skinned: boolean;
  20033. valid: boolean;
  20034. report: string;
  20035. };
  20036. /** @hidden */
  20037. _checkDelayState(): Mesh;
  20038. private _queueLoad;
  20039. /**
  20040. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20041. * A mesh is in the frustum if its bounding box intersects the frustum
  20042. * @param frustumPlanes defines the frustum to test
  20043. * @returns true if the mesh is in the frustum planes
  20044. */
  20045. isInFrustum(frustumPlanes: Plane[]): boolean;
  20046. /**
  20047. * Sets the mesh material by the material or multiMaterial `id` property
  20048. * @param id is a string identifying the material or the multiMaterial
  20049. * @returns the current mesh
  20050. */
  20051. setMaterialByID(id: string): Mesh;
  20052. /**
  20053. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20054. * @returns an array of IAnimatable
  20055. */
  20056. getAnimatables(): IAnimatable[];
  20057. /**
  20058. * Modifies the mesh geometry according to the passed transformation matrix.
  20059. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20060. * The mesh normals are modified using the same transformation.
  20061. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20062. * @param transform defines the transform matrix to use
  20063. * @see http://doc.babylonjs.com/resources/baking_transformations
  20064. * @returns the current mesh
  20065. */
  20066. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20067. /**
  20068. * Modifies the mesh geometry according to its own current World Matrix.
  20069. * The mesh World Matrix is then reset.
  20070. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20071. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20072. * @see http://doc.babylonjs.com/resources/baking_transformations
  20073. * @returns the current mesh
  20074. */
  20075. bakeCurrentTransformIntoVertices(): Mesh;
  20076. /** @hidden */
  20077. readonly _positions: Nullable<Vector3[]>;
  20078. /** @hidden */
  20079. _resetPointsArrayCache(): Mesh;
  20080. /** @hidden */
  20081. _generatePointsArray(): boolean;
  20082. /**
  20083. * Returns a new Mesh object generated from the current mesh properties.
  20084. * This method must not get confused with createInstance()
  20085. * @param name is a string, the name given to the new mesh
  20086. * @param newParent can be any Node object (default `null`)
  20087. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20088. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20089. * @returns a new mesh
  20090. */
  20091. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20092. /**
  20093. * Releases resources associated with this mesh.
  20094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20096. */
  20097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20098. /**
  20099. * Modifies the mesh geometry according to a displacement map.
  20100. * 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.
  20101. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20102. * @param url is a string, the URL from the image file is to be downloaded.
  20103. * @param minHeight is the lower limit of the displacement.
  20104. * @param maxHeight is the upper limit of the displacement.
  20105. * @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.
  20106. * @param uvOffset is an optional vector2 used to offset UV.
  20107. * @param uvScale is an optional vector2 used to scale UV.
  20108. * @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.
  20109. * @returns the Mesh.
  20110. */
  20111. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20112. /**
  20113. * Modifies the mesh geometry according to a displacementMap buffer.
  20114. * 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.
  20115. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20116. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20117. * @param heightMapWidth is the width of the buffer image.
  20118. * @param heightMapHeight is the height of the buffer image.
  20119. * @param minHeight is the lower limit of the displacement.
  20120. * @param maxHeight is the upper limit of the displacement.
  20121. * @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.
  20122. * @param uvOffset is an optional vector2 used to offset UV.
  20123. * @param uvScale is an optional vector2 used to scale UV.
  20124. * @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.
  20125. * @returns the Mesh.
  20126. */
  20127. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20128. /**
  20129. * Modify the mesh to get a flat shading rendering.
  20130. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20131. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20132. * @returns current mesh
  20133. */
  20134. convertToFlatShadedMesh(): Mesh;
  20135. /**
  20136. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20137. * In other words, more vertices, no more indices and a single bigger VBO.
  20138. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20139. * @returns current mesh
  20140. */
  20141. convertToUnIndexedMesh(): Mesh;
  20142. /**
  20143. * Inverses facet orientations.
  20144. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20145. * @param flipNormals will also inverts the normals
  20146. * @returns current mesh
  20147. */
  20148. flipFaces(flipNormals?: boolean): Mesh;
  20149. /** @hidden */
  20150. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  20151. /**
  20152. * Creates a new InstancedMesh object from the mesh model.
  20153. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20154. * @param name defines the name of the new instance
  20155. * @returns a new InstancedMesh
  20156. */
  20157. createInstance(name: string): InstancedMesh;
  20158. /**
  20159. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20160. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20161. * @returns the current mesh
  20162. */
  20163. synchronizeInstances(): Mesh;
  20164. /**
  20165. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20166. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20167. * This should be used together with the simplification to avoid disappearing triangles.
  20168. * @param successCallback an optional success callback to be called after the optimization finished.
  20169. * @returns the current mesh
  20170. */
  20171. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20172. /**
  20173. * Serialize current mesh
  20174. * @param serializationObject defines the object which will receive the serialization data
  20175. */
  20176. serialize(serializationObject: any): void;
  20177. /** @hidden */
  20178. _syncGeometryWithMorphTargetManager(): void;
  20179. /** @hidden */
  20180. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20181. /**
  20182. * Returns a new Mesh object parsed from the source provided.
  20183. * @param parsedMesh is the source
  20184. * @param scene defines the hosting scene
  20185. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20186. * @returns a new Mesh
  20187. */
  20188. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20189. /**
  20190. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20191. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20192. * @param name defines the name of the mesh to create
  20193. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20194. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20195. * @param closePath creates a seam between the first and the last points of each path of the path array
  20196. * @param offset is taken in account only if the `pathArray` is containing a single path
  20197. * @param scene defines the hosting scene
  20198. * @param updatable defines if the mesh must be flagged as updatable
  20199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20200. * @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)
  20201. * @returns a new Mesh
  20202. */
  20203. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20204. /**
  20205. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20206. * @param name defines the name of the mesh to create
  20207. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20208. * @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
  20209. * @param scene defines the hosting scene
  20210. * @param updatable defines if the mesh must be flagged as updatable
  20211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20212. * @returns a new Mesh
  20213. */
  20214. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20215. /**
  20216. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20217. * @param name defines the name of the mesh to create
  20218. * @param size sets the size (float) of each box side (default 1)
  20219. * @param scene defines the hosting scene
  20220. * @param updatable defines if the mesh must be flagged as updatable
  20221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20222. * @returns a new Mesh
  20223. */
  20224. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20225. /**
  20226. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20227. * @param name defines the name of the mesh to create
  20228. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20229. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20230. * @param scene defines the hosting scene
  20231. * @param updatable defines if the mesh must be flagged as updatable
  20232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20233. * @returns a new Mesh
  20234. */
  20235. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20236. /**
  20237. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20238. * @param name defines the name of the mesh to create
  20239. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20240. * @param diameterTop set the top cap diameter (floats, default 1)
  20241. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20242. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20243. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20244. * @param scene defines the hosting scene
  20245. * @param updatable defines if the mesh must be flagged as updatable
  20246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20247. * @returns a new Mesh
  20248. */
  20249. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20250. /**
  20251. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20252. * @param name defines the name of the mesh to create
  20253. * @param diameter sets the diameter size (float) of the torus (default 1)
  20254. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20255. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20256. * @param scene defines the hosting scene
  20257. * @param updatable defines if the mesh must be flagged as updatable
  20258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20259. * @returns a new Mesh
  20260. */
  20261. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20262. /**
  20263. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20264. * @param name defines the name of the mesh to create
  20265. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20266. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20267. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20268. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20269. * @param p the number of windings on X axis (positive integers, default 2)
  20270. * @param q the number of windings on Y axis (positive integers, default 3)
  20271. * @param scene defines the hosting scene
  20272. * @param updatable defines if the mesh must be flagged as updatable
  20273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20274. * @returns a new Mesh
  20275. */
  20276. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20277. /**
  20278. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20279. * @param name defines the name of the mesh to create
  20280. * @param points is an array successive Vector3
  20281. * @param scene defines the hosting scene
  20282. * @param updatable defines if the mesh must be flagged as updatable
  20283. * @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).
  20284. * @returns a new Mesh
  20285. */
  20286. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20287. /**
  20288. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20289. * @param name defines the name of the mesh to create
  20290. * @param points is an array successive Vector3
  20291. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20292. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20293. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20294. * @param scene defines the hosting scene
  20295. * @param updatable defines if the mesh must be flagged as updatable
  20296. * @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)
  20297. * @returns a new Mesh
  20298. */
  20299. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20300. /**
  20301. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20302. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20303. * 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.
  20304. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20305. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20306. * Remember you can only change the shape positions, not their number when updating a polygon.
  20307. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20308. * @param name defines the name of the mesh to create
  20309. * @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
  20310. * @param scene defines the hosting scene
  20311. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20312. * @param updatable defines if the mesh must be flagged as updatable
  20313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20314. * @returns a new Mesh
  20315. */
  20316. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20317. /**
  20318. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20319. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20320. * @param name defines the name of the mesh to create
  20321. * @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
  20322. * @param depth defines the height of extrusion
  20323. * @param scene defines the hosting scene
  20324. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20325. * @param updatable defines if the mesh must be flagged as updatable
  20326. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20327. * @returns a new Mesh
  20328. */
  20329. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20330. /**
  20331. * Creates an extruded shape mesh.
  20332. * 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
  20333. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20334. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20335. * @param name defines the name of the mesh to create
  20336. * @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
  20337. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20338. * @param scale is the value to scale the shape
  20339. * @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
  20340. * @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
  20341. * @param scene defines the hosting scene
  20342. * @param updatable defines if the mesh must be flagged as updatable
  20343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20344. * @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)
  20345. * @returns a new Mesh
  20346. */
  20347. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20348. /**
  20349. * Creates an custom extruded shape mesh.
  20350. * The custom extrusion is a parametric shape.
  20351. * It has no predefined shape. Its final shape will depend on the input parameters.
  20352. * Please consider using the same method from the MeshBuilder class instead
  20353. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20354. * @param name defines the name of the mesh to create
  20355. * @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
  20356. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20357. * @param scaleFunction is a custom Javascript function called on each path point
  20358. * @param rotationFunction is a custom Javascript function called on each path point
  20359. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20360. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20361. * @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
  20362. * @param scene defines the hosting scene
  20363. * @param updatable defines if the mesh must be flagged as updatable
  20364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20365. * @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)
  20366. * @returns a new Mesh
  20367. */
  20368. 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;
  20369. /**
  20370. * Creates lathe mesh.
  20371. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20372. * Please consider using the same method from the MeshBuilder class instead
  20373. * @param name defines the name of the mesh to create
  20374. * @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
  20375. * @param radius is the radius value of the lathe
  20376. * @param tessellation is the side number of the lathe.
  20377. * @param scene defines the hosting scene
  20378. * @param updatable defines if the mesh must be flagged as updatable
  20379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20380. * @returns a new Mesh
  20381. */
  20382. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20383. /**
  20384. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20385. * @param name defines the name of the mesh to create
  20386. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20387. * @param scene defines the hosting scene
  20388. * @param updatable defines if the mesh must be flagged as updatable
  20389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20390. * @returns a new Mesh
  20391. */
  20392. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20393. /**
  20394. * Creates a ground mesh.
  20395. * Please consider using the same method from the MeshBuilder class instead
  20396. * @param name defines the name of the mesh to create
  20397. * @param width set the width of the ground
  20398. * @param height set the height of the ground
  20399. * @param subdivisions sets the number of subdivisions per side
  20400. * @param scene defines the hosting scene
  20401. * @param updatable defines if the mesh must be flagged as updatable
  20402. * @returns a new Mesh
  20403. */
  20404. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20405. /**
  20406. * Creates a tiled ground mesh.
  20407. * Please consider using the same method from the MeshBuilder class instead
  20408. * @param name defines the name of the mesh to create
  20409. * @param xmin set the ground minimum X coordinate
  20410. * @param zmin set the ground minimum Y coordinate
  20411. * @param xmax set the ground maximum X coordinate
  20412. * @param zmax set the ground maximum Z coordinate
  20413. * @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
  20414. * @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
  20415. * @param scene defines the hosting scene
  20416. * @param updatable defines if the mesh must be flagged as updatable
  20417. * @returns a new Mesh
  20418. */
  20419. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20420. w: number;
  20421. h: number;
  20422. }, precision: {
  20423. w: number;
  20424. h: number;
  20425. }, scene: Scene, updatable?: boolean): Mesh;
  20426. /**
  20427. * Creates a ground mesh from a height map.
  20428. * Please consider using the same method from the MeshBuilder class instead
  20429. * @see http://doc.babylonjs.com/babylon101/height_map
  20430. * @param name defines the name of the mesh to create
  20431. * @param url sets the URL of the height map image resource
  20432. * @param width set the ground width size
  20433. * @param height set the ground height size
  20434. * @param subdivisions sets the number of subdivision per side
  20435. * @param minHeight is the minimum altitude on the ground
  20436. * @param maxHeight is the maximum altitude on the ground
  20437. * @param scene defines the hosting scene
  20438. * @param updatable defines if the mesh must be flagged as updatable
  20439. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20440. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20441. * @returns a new Mesh
  20442. */
  20443. 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;
  20444. /**
  20445. * Creates a tube mesh.
  20446. * The tube is a parametric shape.
  20447. * It has no predefined shape. Its final shape will depend on the input parameters.
  20448. * Please consider using the same method from the MeshBuilder class instead
  20449. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20450. * @param name defines the name of the mesh to create
  20451. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20452. * @param radius sets the tube radius size
  20453. * @param tessellation is the number of sides on the tubular surface
  20454. * @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
  20455. * @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
  20456. * @param scene defines the hosting scene
  20457. * @param updatable defines if the mesh must be flagged as updatable
  20458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20459. * @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)
  20460. * @returns a new Mesh
  20461. */
  20462. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20463. (i: number, distance: number): number;
  20464. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20465. /**
  20466. * Creates a polyhedron mesh.
  20467. * Please consider using the same method from the MeshBuilder class instead.
  20468. * * 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
  20469. * * The parameter `size` (positive float, default 1) sets the polygon size
  20470. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20471. * * 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`
  20472. * * 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
  20473. * * 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)`)
  20474. * * 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
  20475. * * 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
  20476. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20477. * * If you create a double-sided mesh, you can choose what parts of 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
  20478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20479. * @param name defines the name of the mesh to create
  20480. * @param options defines the options used to create the mesh
  20481. * @param scene defines the hosting scene
  20482. * @returns a new Mesh
  20483. */
  20484. static CreatePolyhedron(name: string, options: {
  20485. type?: number;
  20486. size?: number;
  20487. sizeX?: number;
  20488. sizeY?: number;
  20489. sizeZ?: number;
  20490. custom?: any;
  20491. faceUV?: Vector4[];
  20492. faceColors?: Color4[];
  20493. updatable?: boolean;
  20494. sideOrientation?: number;
  20495. }, scene: Scene): Mesh;
  20496. /**
  20497. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20498. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20499. * * 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`)
  20500. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20501. * * 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
  20502. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20503. * * If you create a double-sided mesh, you can choose what parts of 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
  20504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20505. * @param name defines the name of the mesh
  20506. * @param options defines the options used to create the mesh
  20507. * @param scene defines the hosting scene
  20508. * @returns a new Mesh
  20509. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20510. */
  20511. static CreateIcoSphere(name: string, options: {
  20512. radius?: number;
  20513. flat?: boolean;
  20514. subdivisions?: number;
  20515. sideOrientation?: number;
  20516. updatable?: boolean;
  20517. }, scene: Scene): Mesh;
  20518. /**
  20519. * Creates a decal mesh.
  20520. * Please consider using the same method from the MeshBuilder class instead.
  20521. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20522. * @param name defines the name of the mesh
  20523. * @param sourceMesh defines the mesh receiving the decal
  20524. * @param position sets the position of the decal in world coordinates
  20525. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20526. * @param size sets the decal scaling
  20527. * @param angle sets the angle to rotate the decal
  20528. * @returns a new Mesh
  20529. */
  20530. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20531. /**
  20532. * Prepare internal position array for software CPU skinning
  20533. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20534. */
  20535. setPositionsForCPUSkinning(): Float32Array;
  20536. /**
  20537. * Prepare internal normal array for software CPU skinning
  20538. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20539. */
  20540. setNormalsForCPUSkinning(): Float32Array;
  20541. /**
  20542. * Updates the vertex buffer by applying transformation from the bones
  20543. * @param skeleton defines the skeleton to apply to current mesh
  20544. * @returns the current mesh
  20545. */
  20546. applySkeleton(skeleton: Skeleton): Mesh;
  20547. /**
  20548. * 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
  20549. * @param meshes defines the list of meshes to scan
  20550. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20551. */
  20552. static MinMax(meshes: AbstractMesh[]): {
  20553. min: Vector3;
  20554. max: Vector3;
  20555. };
  20556. /**
  20557. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20558. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20559. * @returns a vector3
  20560. */
  20561. static Center(meshesOrMinMaxVector: {
  20562. min: Vector3;
  20563. max: Vector3;
  20564. } | AbstractMesh[]): Vector3;
  20565. /**
  20566. * Merge the array of meshes into a single mesh for performance reasons.
  20567. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20568. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20569. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20570. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20571. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20572. * @returns a new mesh
  20573. */
  20574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20575. /** @hidden */
  20576. addInstance(instance: InstancedMesh): void;
  20577. /** @hidden */
  20578. removeInstance(instance: InstancedMesh): void;
  20579. }
  20580. }
  20581. declare module "babylonjs/Actions/action" {
  20582. import { Observable } from "babylonjs/Misc/observable";
  20583. import { Condition } from "babylonjs/Actions/condition";
  20584. import { ActionManager } from "babylonjs/Actions/actionManager";
  20585. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20586. /**
  20587. * The action to be carried out following a trigger
  20588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20589. */
  20590. export class Action {
  20591. /** the trigger, with or without parameters, for the action */
  20592. triggerOptions: any;
  20593. /**
  20594. * Trigger for the action
  20595. */
  20596. trigger: number;
  20597. /**
  20598. * Internal only - manager for action
  20599. * @hidden
  20600. */
  20601. _actionManager: ActionManager;
  20602. private _nextActiveAction;
  20603. private _child;
  20604. private _condition?;
  20605. private _triggerParameter;
  20606. /**
  20607. * An event triggered prior to action being executed.
  20608. */
  20609. onBeforeExecuteObservable: Observable<Action>;
  20610. /**
  20611. * Creates a new Action
  20612. * @param triggerOptions the trigger, with or without parameters, for the action
  20613. * @param condition an optional determinant of action
  20614. */
  20615. constructor(
  20616. /** the trigger, with or without parameters, for the action */
  20617. triggerOptions: any, condition?: Condition);
  20618. /**
  20619. * Internal only
  20620. * @hidden
  20621. */
  20622. _prepare(): void;
  20623. /**
  20624. * Gets the trigger parameters
  20625. * @returns the trigger parameters
  20626. */
  20627. getTriggerParameter(): any;
  20628. /**
  20629. * Internal only - executes current action event
  20630. * @hidden
  20631. */
  20632. _executeCurrent(evt?: ActionEvent): void;
  20633. /**
  20634. * Execute placeholder for child classes
  20635. * @param evt optional action event
  20636. */
  20637. execute(evt?: ActionEvent): void;
  20638. /**
  20639. * Skips to next active action
  20640. */
  20641. skipToNextActiveAction(): void;
  20642. /**
  20643. * Adds action to chain of actions, may be a DoNothingAction
  20644. * @param action defines the next action to execute
  20645. * @returns The action passed in
  20646. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20647. */
  20648. then(action: Action): Action;
  20649. /**
  20650. * Internal only
  20651. * @hidden
  20652. */
  20653. _getProperty(propertyPath: string): string;
  20654. /**
  20655. * Internal only
  20656. * @hidden
  20657. */
  20658. _getEffectiveTarget(target: any, propertyPath: string): any;
  20659. /**
  20660. * Serialize placeholder for child classes
  20661. * @param parent of child
  20662. * @returns the serialized object
  20663. */
  20664. serialize(parent: any): any;
  20665. /**
  20666. * Internal only called by serialize
  20667. * @hidden
  20668. */
  20669. protected _serialize(serializedAction: any, parent?: any): any;
  20670. /**
  20671. * Internal only
  20672. * @hidden
  20673. */
  20674. static _SerializeValueAsString: (value: any) => string;
  20675. /**
  20676. * Internal only
  20677. * @hidden
  20678. */
  20679. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  20680. name: string;
  20681. targetType: string;
  20682. value: string;
  20683. };
  20684. }
  20685. }
  20686. declare module "babylonjs/Actions/condition" {
  20687. import { ActionManager } from "babylonjs/Actions/actionManager";
  20688. /**
  20689. * A Condition applied to an Action
  20690. */
  20691. export class Condition {
  20692. /**
  20693. * Internal only - manager for action
  20694. * @hidden
  20695. */
  20696. _actionManager: ActionManager;
  20697. /**
  20698. * Internal only
  20699. * @hidden
  20700. */
  20701. _evaluationId: number;
  20702. /**
  20703. * Internal only
  20704. * @hidden
  20705. */
  20706. _currentResult: boolean;
  20707. /**
  20708. * Creates a new Condition
  20709. * @param actionManager the manager of the action the condition is applied to
  20710. */
  20711. constructor(actionManager: ActionManager);
  20712. /**
  20713. * Check if the current condition is valid
  20714. * @returns a boolean
  20715. */
  20716. isValid(): boolean;
  20717. /**
  20718. * Internal only
  20719. * @hidden
  20720. */
  20721. _getProperty(propertyPath: string): string;
  20722. /**
  20723. * Internal only
  20724. * @hidden
  20725. */
  20726. _getEffectiveTarget(target: any, propertyPath: string): any;
  20727. /**
  20728. * Serialize placeholder for child classes
  20729. * @returns the serialized object
  20730. */
  20731. serialize(): any;
  20732. /**
  20733. * Internal only
  20734. * @hidden
  20735. */
  20736. protected _serialize(serializedCondition: any): any;
  20737. }
  20738. /**
  20739. * Defines specific conditional operators as extensions of Condition
  20740. */
  20741. export class ValueCondition extends Condition {
  20742. /** path to specify the property of the target the conditional operator uses */
  20743. propertyPath: string;
  20744. /** the value compared by the conditional operator against the current value of the property */
  20745. value: any;
  20746. /** the conditional operator, default ValueCondition.IsEqual */
  20747. operator: number;
  20748. /**
  20749. * Internal only
  20750. * @hidden
  20751. */
  20752. private static _IsEqual;
  20753. /**
  20754. * Internal only
  20755. * @hidden
  20756. */
  20757. private static _IsDifferent;
  20758. /**
  20759. * Internal only
  20760. * @hidden
  20761. */
  20762. private static _IsGreater;
  20763. /**
  20764. * Internal only
  20765. * @hidden
  20766. */
  20767. private static _IsLesser;
  20768. /**
  20769. * returns the number for IsEqual
  20770. */
  20771. static readonly IsEqual: number;
  20772. /**
  20773. * Returns the number for IsDifferent
  20774. */
  20775. static readonly IsDifferent: number;
  20776. /**
  20777. * Returns the number for IsGreater
  20778. */
  20779. static readonly IsGreater: number;
  20780. /**
  20781. * Returns the number for IsLesser
  20782. */
  20783. static readonly IsLesser: number;
  20784. /**
  20785. * Internal only The action manager for the condition
  20786. * @hidden
  20787. */
  20788. _actionManager: ActionManager;
  20789. /**
  20790. * Internal only
  20791. * @hidden
  20792. */
  20793. private _target;
  20794. /**
  20795. * Internal only
  20796. * @hidden
  20797. */
  20798. private _effectiveTarget;
  20799. /**
  20800. * Internal only
  20801. * @hidden
  20802. */
  20803. private _property;
  20804. /**
  20805. * Creates a new ValueCondition
  20806. * @param actionManager manager for the action the condition applies to
  20807. * @param target for the action
  20808. * @param propertyPath path to specify the property of the target the conditional operator uses
  20809. * @param value the value compared by the conditional operator against the current value of the property
  20810. * @param operator the conditional operator, default ValueCondition.IsEqual
  20811. */
  20812. constructor(actionManager: ActionManager, target: any,
  20813. /** path to specify the property of the target the conditional operator uses */
  20814. propertyPath: string,
  20815. /** the value compared by the conditional operator against the current value of the property */
  20816. value: any,
  20817. /** the conditional operator, default ValueCondition.IsEqual */
  20818. operator?: number);
  20819. /**
  20820. * Compares the given value with the property value for the specified conditional operator
  20821. * @returns the result of the comparison
  20822. */
  20823. isValid(): boolean;
  20824. /**
  20825. * Serialize the ValueCondition into a JSON compatible object
  20826. * @returns serialization object
  20827. */
  20828. serialize(): any;
  20829. /**
  20830. * Gets the name of the conditional operator for the ValueCondition
  20831. * @param operator the conditional operator
  20832. * @returns the name
  20833. */
  20834. static GetOperatorName(operator: number): string;
  20835. }
  20836. /**
  20837. * Defines a predicate condition as an extension of Condition
  20838. */
  20839. export class PredicateCondition extends Condition {
  20840. /** defines the predicate function used to validate the condition */
  20841. predicate: () => boolean;
  20842. /**
  20843. * Internal only - manager for action
  20844. * @hidden
  20845. */
  20846. _actionManager: ActionManager;
  20847. /**
  20848. * Creates a new PredicateCondition
  20849. * @param actionManager manager for the action the condition applies to
  20850. * @param predicate defines the predicate function used to validate the condition
  20851. */
  20852. constructor(actionManager: ActionManager,
  20853. /** defines the predicate function used to validate the condition */
  20854. predicate: () => boolean);
  20855. /**
  20856. * @returns the validity of the predicate condition
  20857. */
  20858. isValid(): boolean;
  20859. }
  20860. /**
  20861. * Defines a state condition as an extension of Condition
  20862. */
  20863. export class StateCondition extends Condition {
  20864. /** Value to compare with target state */
  20865. value: string;
  20866. /**
  20867. * Internal only - manager for action
  20868. * @hidden
  20869. */
  20870. _actionManager: ActionManager;
  20871. /**
  20872. * Internal only
  20873. * @hidden
  20874. */
  20875. private _target;
  20876. /**
  20877. * Creates a new StateCondition
  20878. * @param actionManager manager for the action the condition applies to
  20879. * @param target of the condition
  20880. * @param value to compare with target state
  20881. */
  20882. constructor(actionManager: ActionManager, target: any,
  20883. /** Value to compare with target state */
  20884. value: string);
  20885. /**
  20886. * Gets a boolean indicating if the current condition is met
  20887. * @returns the validity of the state
  20888. */
  20889. isValid(): boolean;
  20890. /**
  20891. * Serialize the StateCondition into a JSON compatible object
  20892. * @returns serialization object
  20893. */
  20894. serialize(): any;
  20895. }
  20896. }
  20897. declare module "babylonjs/Actions/directActions" {
  20898. import { Action } from "babylonjs/Actions/action";
  20899. import { Condition } from "babylonjs/Actions/condition";
  20900. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20901. /**
  20902. * This defines an action responsible to toggle a boolean once triggered.
  20903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20904. */
  20905. export class SwitchBooleanAction extends Action {
  20906. /**
  20907. * The path to the boolean property in the target object
  20908. */
  20909. propertyPath: string;
  20910. private _target;
  20911. private _effectiveTarget;
  20912. private _property;
  20913. /**
  20914. * Instantiate the action
  20915. * @param triggerOptions defines the trigger options
  20916. * @param target defines the object containing the boolean
  20917. * @param propertyPath defines the path to the boolean property in the target object
  20918. * @param condition defines the trigger related conditions
  20919. */
  20920. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20921. /** @hidden */
  20922. _prepare(): void;
  20923. /**
  20924. * Execute the action toggle the boolean value.
  20925. */
  20926. execute(): void;
  20927. /**
  20928. * Serializes the actions and its related information.
  20929. * @param parent defines the object to serialize in
  20930. * @returns the serialized object
  20931. */
  20932. serialize(parent: any): any;
  20933. }
  20934. /**
  20935. * This defines an action responsible to set a the state field of the target
  20936. * to a desired value once triggered.
  20937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20938. */
  20939. export class SetStateAction extends Action {
  20940. /**
  20941. * The value to store in the state field.
  20942. */
  20943. value: string;
  20944. private _target;
  20945. /**
  20946. * Instantiate the action
  20947. * @param triggerOptions defines the trigger options
  20948. * @param target defines the object containing the state property
  20949. * @param value defines the value to store in the state field
  20950. * @param condition defines the trigger related conditions
  20951. */
  20952. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20953. /**
  20954. * Execute the action and store the value on the target state property.
  20955. */
  20956. execute(): void;
  20957. /**
  20958. * Serializes the actions and its related information.
  20959. * @param parent defines the object to serialize in
  20960. * @returns the serialized object
  20961. */
  20962. serialize(parent: any): any;
  20963. }
  20964. /**
  20965. * This defines an action responsible to set a property of the target
  20966. * to a desired value once triggered.
  20967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20968. */
  20969. export class SetValueAction extends Action {
  20970. /**
  20971. * The path of the property to set in the target.
  20972. */
  20973. propertyPath: string;
  20974. /**
  20975. * The value to set in the property
  20976. */
  20977. value: any;
  20978. private _target;
  20979. private _effectiveTarget;
  20980. private _property;
  20981. /**
  20982. * Instantiate the action
  20983. * @param triggerOptions defines the trigger options
  20984. * @param target defines the object containing the property
  20985. * @param propertyPath defines the path of the property to set in the target
  20986. * @param value defines the value to set in the property
  20987. * @param condition defines the trigger related conditions
  20988. */
  20989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20990. /** @hidden */
  20991. _prepare(): void;
  20992. /**
  20993. * Execute the action and set the targetted property to the desired value.
  20994. */
  20995. execute(): void;
  20996. /**
  20997. * Serializes the actions and its related information.
  20998. * @param parent defines the object to serialize in
  20999. * @returns the serialized object
  21000. */
  21001. serialize(parent: any): any;
  21002. }
  21003. /**
  21004. * This defines an action responsible to increment the target value
  21005. * to a desired value once triggered.
  21006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21007. */
  21008. export class IncrementValueAction extends Action {
  21009. /**
  21010. * The path of the property to increment in the target.
  21011. */
  21012. propertyPath: string;
  21013. /**
  21014. * The value we should increment the property by.
  21015. */
  21016. value: any;
  21017. private _target;
  21018. private _effectiveTarget;
  21019. private _property;
  21020. /**
  21021. * Instantiate the action
  21022. * @param triggerOptions defines the trigger options
  21023. * @param target defines the object containing the property
  21024. * @param propertyPath defines the path of the property to increment in the target
  21025. * @param value defines the value value we should increment the property by
  21026. * @param condition defines the trigger related conditions
  21027. */
  21028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21029. /** @hidden */
  21030. _prepare(): void;
  21031. /**
  21032. * Execute the action and increment the target of the value amount.
  21033. */
  21034. execute(): void;
  21035. /**
  21036. * Serializes the actions and its related information.
  21037. * @param parent defines the object to serialize in
  21038. * @returns the serialized object
  21039. */
  21040. serialize(parent: any): any;
  21041. }
  21042. /**
  21043. * This defines an action responsible to start an animation once triggered.
  21044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21045. */
  21046. export class PlayAnimationAction extends Action {
  21047. /**
  21048. * Where the animation should start (animation frame)
  21049. */
  21050. from: number;
  21051. /**
  21052. * Where the animation should stop (animation frame)
  21053. */
  21054. to: number;
  21055. /**
  21056. * Define if the animation should loop or stop after the first play.
  21057. */
  21058. loop?: boolean;
  21059. private _target;
  21060. /**
  21061. * Instantiate the action
  21062. * @param triggerOptions defines the trigger options
  21063. * @param target defines the target animation or animation name
  21064. * @param from defines from where the animation should start (animation frame)
  21065. * @param end defines where the animation should stop (animation frame)
  21066. * @param loop defines if the animation should loop or stop after the first play
  21067. * @param condition defines the trigger related conditions
  21068. */
  21069. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  21070. /** @hidden */
  21071. _prepare(): void;
  21072. /**
  21073. * Execute the action and play the animation.
  21074. */
  21075. execute(): void;
  21076. /**
  21077. * Serializes the actions and its related information.
  21078. * @param parent defines the object to serialize in
  21079. * @returns the serialized object
  21080. */
  21081. serialize(parent: any): any;
  21082. }
  21083. /**
  21084. * This defines an action responsible to stop an animation once triggered.
  21085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21086. */
  21087. export class StopAnimationAction extends Action {
  21088. private _target;
  21089. /**
  21090. * Instantiate the action
  21091. * @param triggerOptions defines the trigger options
  21092. * @param target defines the target animation or animation name
  21093. * @param condition defines the trigger related conditions
  21094. */
  21095. constructor(triggerOptions: any, target: any, condition?: Condition);
  21096. /** @hidden */
  21097. _prepare(): void;
  21098. /**
  21099. * Execute the action and stop the animation.
  21100. */
  21101. execute(): void;
  21102. /**
  21103. * Serializes the actions and its related information.
  21104. * @param parent defines the object to serialize in
  21105. * @returns the serialized object
  21106. */
  21107. serialize(parent: any): any;
  21108. }
  21109. /**
  21110. * This defines an action responsible that does nothing once triggered.
  21111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21112. */
  21113. export class DoNothingAction extends Action {
  21114. /**
  21115. * Instantiate the action
  21116. * @param triggerOptions defines the trigger options
  21117. * @param condition defines the trigger related conditions
  21118. */
  21119. constructor(triggerOptions?: any, condition?: Condition);
  21120. /**
  21121. * Execute the action and do nothing.
  21122. */
  21123. execute(): void;
  21124. /**
  21125. * Serializes the actions and its related information.
  21126. * @param parent defines the object to serialize in
  21127. * @returns the serialized object
  21128. */
  21129. serialize(parent: any): any;
  21130. }
  21131. /**
  21132. * This defines an action responsible to trigger several actions once triggered.
  21133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21134. */
  21135. export class CombineAction extends Action {
  21136. /**
  21137. * The list of aggregated animations to run.
  21138. */
  21139. children: Action[];
  21140. /**
  21141. * Instantiate the action
  21142. * @param triggerOptions defines the trigger options
  21143. * @param children defines the list of aggregated animations to run
  21144. * @param condition defines the trigger related conditions
  21145. */
  21146. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  21147. /** @hidden */
  21148. _prepare(): void;
  21149. /**
  21150. * Execute the action and executes all the aggregated actions.
  21151. */
  21152. execute(evt: ActionEvent): void;
  21153. /**
  21154. * Serializes the actions and its related information.
  21155. * @param parent defines the object to serialize in
  21156. * @returns the serialized object
  21157. */
  21158. serialize(parent: any): any;
  21159. }
  21160. /**
  21161. * This defines an action responsible to run code (external event) once triggered.
  21162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21163. */
  21164. export class ExecuteCodeAction extends Action {
  21165. /**
  21166. * The callback function to run.
  21167. */
  21168. func: (evt: ActionEvent) => void;
  21169. /**
  21170. * Instantiate the action
  21171. * @param triggerOptions defines the trigger options
  21172. * @param func defines the callback function to run
  21173. * @param condition defines the trigger related conditions
  21174. */
  21175. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  21176. /**
  21177. * Execute the action and run the attached code.
  21178. */
  21179. execute(evt: ActionEvent): void;
  21180. }
  21181. /**
  21182. * This defines an action responsible to set the parent property of the target once triggered.
  21183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21184. */
  21185. export class SetParentAction extends Action {
  21186. private _parent;
  21187. private _target;
  21188. /**
  21189. * Instantiate the action
  21190. * @param triggerOptions defines the trigger options
  21191. * @param target defines the target containing the parent property
  21192. * @param parent defines from where the animation should start (animation frame)
  21193. * @param condition defines the trigger related conditions
  21194. */
  21195. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  21196. /** @hidden */
  21197. _prepare(): void;
  21198. /**
  21199. * Execute the action and set the parent property.
  21200. */
  21201. execute(): void;
  21202. /**
  21203. * Serializes the actions and its related information.
  21204. * @param parent defines the object to serialize in
  21205. * @returns the serialized object
  21206. */
  21207. serialize(parent: any): any;
  21208. }
  21209. }
  21210. declare module "babylonjs/Actions/actionManager" {
  21211. import { Nullable } from "babylonjs/types";
  21212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21213. import { Scene } from "babylonjs/scene";
  21214. import { Action } from "babylonjs/Actions/action";
  21215. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  21216. /**
  21217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  21218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  21219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21220. */
  21221. export class ActionManager {
  21222. /**
  21223. * Nothing
  21224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21225. */
  21226. static readonly NothingTrigger: number;
  21227. /**
  21228. * On pick
  21229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21230. */
  21231. static readonly OnPickTrigger: number;
  21232. /**
  21233. * On left pick
  21234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21235. */
  21236. static readonly OnLeftPickTrigger: number;
  21237. /**
  21238. * On right pick
  21239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21240. */
  21241. static readonly OnRightPickTrigger: number;
  21242. /**
  21243. * On center pick
  21244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21245. */
  21246. static readonly OnCenterPickTrigger: number;
  21247. /**
  21248. * On pick down
  21249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21250. */
  21251. static readonly OnPickDownTrigger: number;
  21252. /**
  21253. * On double pick
  21254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21255. */
  21256. static readonly OnDoublePickTrigger: number;
  21257. /**
  21258. * On pick up
  21259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21260. */
  21261. static readonly OnPickUpTrigger: number;
  21262. /**
  21263. * On pick out.
  21264. * This trigger will only be raised if you also declared a OnPickDown
  21265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21266. */
  21267. static readonly OnPickOutTrigger: number;
  21268. /**
  21269. * On long press
  21270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21271. */
  21272. static readonly OnLongPressTrigger: number;
  21273. /**
  21274. * On pointer over
  21275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21276. */
  21277. static readonly OnPointerOverTrigger: number;
  21278. /**
  21279. * On pointer out
  21280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21281. */
  21282. static readonly OnPointerOutTrigger: number;
  21283. /**
  21284. * On every frame
  21285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21286. */
  21287. static readonly OnEveryFrameTrigger: number;
  21288. /**
  21289. * On intersection enter
  21290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21291. */
  21292. static readonly OnIntersectionEnterTrigger: number;
  21293. /**
  21294. * On intersection exit
  21295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21296. */
  21297. static readonly OnIntersectionExitTrigger: number;
  21298. /**
  21299. * On key down
  21300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21301. */
  21302. static readonly OnKeyDownTrigger: number;
  21303. /**
  21304. * On key up
  21305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21306. */
  21307. static readonly OnKeyUpTrigger: number;
  21308. /** Gets the list of active triggers */
  21309. static Triggers: {
  21310. [key: string]: number;
  21311. };
  21312. /** Gets the list of actions */
  21313. actions: Action[];
  21314. /** Gets the cursor to use when hovering items */
  21315. hoverCursor: string;
  21316. private _scene;
  21317. /**
  21318. * Creates a new action manager
  21319. * @param scene defines the hosting scene
  21320. */
  21321. constructor(scene: Scene);
  21322. /**
  21323. * Releases all associated resources
  21324. */
  21325. dispose(): void;
  21326. /**
  21327. * Gets hosting scene
  21328. * @returns the hosting scene
  21329. */
  21330. getScene(): Scene;
  21331. /**
  21332. * Does this action manager handles actions of any of the given triggers
  21333. * @param triggers defines the triggers to be tested
  21334. * @return a boolean indicating whether one (or more) of the triggers is handled
  21335. */
  21336. hasSpecificTriggers(triggers: number[]): boolean;
  21337. /**
  21338. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  21339. * speed.
  21340. * @param triggerA defines the trigger to be tested
  21341. * @param triggerB defines the trigger to be tested
  21342. * @return a boolean indicating whether one (or more) of the triggers is handled
  21343. */
  21344. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  21345. /**
  21346. * Does this action manager handles actions of a given trigger
  21347. * @param trigger defines the trigger to be tested
  21348. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  21349. * @return whether the trigger is handled
  21350. */
  21351. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  21352. /**
  21353. * Does this action manager has pointer triggers
  21354. */
  21355. readonly hasPointerTriggers: boolean;
  21356. /**
  21357. * Does this action manager has pick triggers
  21358. */
  21359. readonly hasPickTriggers: boolean;
  21360. /**
  21361. * Does exist one action manager with at least one trigger
  21362. **/
  21363. static readonly HasTriggers: boolean;
  21364. /**
  21365. * Does exist one action manager with at least one pick trigger
  21366. **/
  21367. static readonly HasPickTriggers: boolean;
  21368. /**
  21369. * Does exist one action manager that handles actions of a given trigger
  21370. * @param trigger defines the trigger to be tested
  21371. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  21372. **/
  21373. static HasSpecificTrigger(trigger: number): boolean;
  21374. /**
  21375. * Registers an action to this action manager
  21376. * @param action defines the action to be registered
  21377. * @return the action amended (prepared) after registration
  21378. */
  21379. registerAction(action: Action): Nullable<Action>;
  21380. /**
  21381. * Unregisters an action to this action manager
  21382. * @param action defines the action to be unregistered
  21383. * @return a boolean indicating whether the action has been unregistered
  21384. */
  21385. unregisterAction(action: Action): Boolean;
  21386. /**
  21387. * Process a specific trigger
  21388. * @param trigger defines the trigger to process
  21389. * @param evt defines the event details to be processed
  21390. */
  21391. processTrigger(trigger: number, evt?: ActionEvent): void;
  21392. /** @hidden */
  21393. _getEffectiveTarget(target: any, propertyPath: string): any;
  21394. /** @hidden */
  21395. _getProperty(propertyPath: string): string;
  21396. /**
  21397. * Serialize this manager to a JSON object
  21398. * @param name defines the property name to store this manager
  21399. * @returns a JSON representation of this manager
  21400. */
  21401. serialize(name: string): any;
  21402. /**
  21403. * Creates a new ActionManager from a JSON data
  21404. * @param parsedActions defines the JSON data to read from
  21405. * @param object defines the hosting mesh
  21406. * @param scene defines the hosting scene
  21407. */
  21408. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  21409. /**
  21410. * Get a trigger name by index
  21411. * @param trigger defines the trigger index
  21412. * @returns a trigger name
  21413. */
  21414. static GetTriggerName(trigger: number): string;
  21415. }
  21416. }
  21417. declare module "babylonjs/Sprites/sprite" {
  21418. import { Vector3, Color4 } from "babylonjs/Maths/math";
  21419. import { Nullable } from "babylonjs/types";
  21420. import { ActionManager } from "babylonjs/Actions/actionManager";
  21421. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21422. /**
  21423. * Class used to represent a sprite
  21424. * @see http://doc.babylonjs.com/babylon101/sprites
  21425. */
  21426. export class Sprite {
  21427. /** defines the name */
  21428. name: string;
  21429. /** Gets or sets the current world position */
  21430. position: Vector3;
  21431. /** Gets or sets the main color */
  21432. color: Color4;
  21433. /** Gets or sets the width */
  21434. width: number;
  21435. /** Gets or sets the height */
  21436. height: number;
  21437. /** Gets or sets rotation angle */
  21438. angle: number;
  21439. /** Gets or sets the cell index in the sprite sheet */
  21440. cellIndex: number;
  21441. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  21442. invertU: number;
  21443. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  21444. invertV: number;
  21445. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  21446. disposeWhenFinishedAnimating: boolean;
  21447. /** Gets the list of attached animations */
  21448. animations: Animation[];
  21449. /** Gets or sets a boolean indicating if the sprite can be picked */
  21450. isPickable: boolean;
  21451. /**
  21452. * Gets or sets the associated action manager
  21453. */
  21454. actionManager: Nullable<ActionManager>;
  21455. private _animationStarted;
  21456. private _loopAnimation;
  21457. private _fromIndex;
  21458. private _toIndex;
  21459. private _delay;
  21460. private _direction;
  21461. private _manager;
  21462. private _time;
  21463. private _onAnimationEnd;
  21464. /**
  21465. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  21466. */
  21467. isVisible: boolean;
  21468. /**
  21469. * Gets or sets the sprite size
  21470. */
  21471. size: number;
  21472. /**
  21473. * Creates a new Sprite
  21474. * @param name defines the name
  21475. * @param manager defines the manager
  21476. */
  21477. constructor(
  21478. /** defines the name */
  21479. name: string, manager: ISpriteManager);
  21480. /**
  21481. * Starts an animation
  21482. * @param from defines the initial key
  21483. * @param to defines the end key
  21484. * @param loop defines if the animation must loop
  21485. * @param delay defines the start delay (in ms)
  21486. * @param onAnimationEnd defines a callback to call when animation ends
  21487. */
  21488. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21489. /** Stops current animation (if any) */
  21490. stopAnimation(): void;
  21491. /** @hidden */
  21492. _animate(deltaTime: number): void;
  21493. /** Release associated resources */
  21494. dispose(): void;
  21495. }
  21496. }
  21497. declare module "babylonjs/Collisions/pickingInfo" {
  21498. import { Nullable } from "babylonjs/types";
  21499. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21501. import { Ray } from "babylonjs/Culling/ray";
  21502. import { Sprite } from "babylonjs/Sprites/sprite";
  21503. /**
  21504. * Information about the result of picking within a scene
  21505. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  21506. */
  21507. export class PickingInfo {
  21508. /**
  21509. * If the pick collided with an object
  21510. */
  21511. hit: boolean;
  21512. /**
  21513. * Distance away where the pick collided
  21514. */
  21515. distance: number;
  21516. /**
  21517. * The location of pick collision
  21518. */
  21519. pickedPoint: Nullable<Vector3>;
  21520. /**
  21521. * The mesh corresponding the the pick collision
  21522. */
  21523. pickedMesh: Nullable<AbstractMesh>;
  21524. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  21525. bu: number;
  21526. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  21527. bv: number;
  21528. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21529. faceId: number;
  21530. /** Id of the the submesh that was picked */
  21531. subMeshId: number;
  21532. /** If a sprite was picked, this will be the sprite the pick collided with */
  21533. pickedSprite: Nullable<Sprite>;
  21534. /**
  21535. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21536. */
  21537. originMesh: Nullable<AbstractMesh>;
  21538. /**
  21539. * The ray that was used to perform the picking.
  21540. */
  21541. ray: Nullable<Ray>;
  21542. /**
  21543. * Gets the normal correspodning to the face the pick collided with
  21544. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21545. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21546. * @returns The normal correspodning to the face the pick collided with
  21547. */
  21548. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21549. /**
  21550. * Gets the texture coordinates of where the pick occured
  21551. * @returns the vector containing the coordnates of the texture
  21552. */
  21553. getTextureCoordinates(): Nullable<Vector2>;
  21554. }
  21555. }
  21556. declare module "babylonjs/Culling/ray" {
  21557. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  21558. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21560. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21561. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21562. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  21563. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21564. /**
  21565. * Class representing a ray with position and direction
  21566. */
  21567. export class Ray {
  21568. /** origin point */
  21569. origin: Vector3;
  21570. /** direction */
  21571. direction: Vector3;
  21572. /** length of the ray */
  21573. length: number;
  21574. private static readonly TmpVector3;
  21575. private _tmpRay;
  21576. /**
  21577. * Creates a new ray
  21578. * @param origin origin point
  21579. * @param direction direction
  21580. * @param length length of the ray
  21581. */
  21582. constructor(
  21583. /** origin point */
  21584. origin: Vector3,
  21585. /** direction */
  21586. direction: Vector3,
  21587. /** length of the ray */
  21588. length?: number);
  21589. /**
  21590. * Checks if the ray intersects a box
  21591. * @param minimum bound of the box
  21592. * @param maximum bound of the box
  21593. * @param intersectionTreshold extra extend to be added to the box in all direction
  21594. * @returns if the box was hit
  21595. */
  21596. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21597. /**
  21598. * Checks if the ray intersects a box
  21599. * @param box the bounding box to check
  21600. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21601. * @returns if the box was hit
  21602. */
  21603. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21604. /**
  21605. * If the ray hits a sphere
  21606. * @param sphere the bounding sphere to check
  21607. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21608. * @returns true if it hits the sphere
  21609. */
  21610. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21611. /**
  21612. * If the ray hits a triange
  21613. * @param vertex0 triangle vertex
  21614. * @param vertex1 triangle vertex
  21615. * @param vertex2 triangle vertex
  21616. * @returns intersection information if hit
  21617. */
  21618. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21619. /**
  21620. * Checks if ray intersects a plane
  21621. * @param plane the plane to check
  21622. * @returns the distance away it was hit
  21623. */
  21624. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21625. /**
  21626. * Checks if ray intersects a mesh
  21627. * @param mesh the mesh to check
  21628. * @param fastCheck if only the bounding box should checked
  21629. * @returns picking info of the intersecton
  21630. */
  21631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21632. /**
  21633. * Checks if ray intersects a mesh
  21634. * @param meshes the meshes to check
  21635. * @param fastCheck if only the bounding box should checked
  21636. * @param results array to store result in
  21637. * @returns Array of picking infos
  21638. */
  21639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21640. private _comparePickingInfo;
  21641. private static smallnum;
  21642. private static rayl;
  21643. /**
  21644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21645. * @param sega the first point of the segment to test the intersection against
  21646. * @param segb the second point of the segment to test the intersection against
  21647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21649. */
  21650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21651. /**
  21652. * Update the ray from viewport position
  21653. * @param x position
  21654. * @param y y position
  21655. * @param viewportWidth viewport width
  21656. * @param viewportHeight viewport height
  21657. * @param world world matrix
  21658. * @param view view matrix
  21659. * @param projection projection matrix
  21660. * @returns this ray updated
  21661. */
  21662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21663. /**
  21664. * Creates a ray with origin and direction of 0,0,0
  21665. * @returns the new ray
  21666. */
  21667. static Zero(): Ray;
  21668. /**
  21669. * Creates a new ray from screen space and viewport
  21670. * @param x position
  21671. * @param y y position
  21672. * @param viewportWidth viewport width
  21673. * @param viewportHeight viewport height
  21674. * @param world world matrix
  21675. * @param view view matrix
  21676. * @param projection projection matrix
  21677. * @returns new ray
  21678. */
  21679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21680. /**
  21681. * 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
  21682. * transformed to the given world matrix.
  21683. * @param origin The origin point
  21684. * @param end The end point
  21685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21686. * @returns the new ray
  21687. */
  21688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21689. /**
  21690. * Transforms a ray by a matrix
  21691. * @param ray ray to transform
  21692. * @param matrix matrix to apply
  21693. * @returns the resulting new ray
  21694. */
  21695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21696. /**
  21697. * Transforms a ray by a matrix
  21698. * @param ray ray to transform
  21699. * @param matrix matrix to apply
  21700. * @param result ray to store result in
  21701. */
  21702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21703. /**
  21704. * Unproject a ray from screen space to object space
  21705. * @param sourceX defines the screen space x coordinate to use
  21706. * @param sourceY defines the screen space y coordinate to use
  21707. * @param viewportWidth defines the current width of the viewport
  21708. * @param viewportHeight defines the current height of the viewport
  21709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21710. * @param view defines the view matrix to use
  21711. * @param projection defines the projection matrix to use
  21712. */
  21713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21714. }
  21715. }
  21716. declare module "babylonjs/Materials/multiMaterial" {
  21717. import { Nullable } from "babylonjs/types";
  21718. import { Scene } from "babylonjs/scene";
  21719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21720. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21722. import { Material } from "babylonjs/Materials/material";
  21723. /**
  21724. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21725. * separate meshes. This can be use to improve performances.
  21726. * @see http://doc.babylonjs.com/how_to/multi_materials
  21727. */
  21728. export class MultiMaterial extends Material {
  21729. private _subMaterials;
  21730. /**
  21731. * Gets or Sets the list of Materials used within the multi material.
  21732. * They need to be ordered according to the submeshes order in the associated mesh
  21733. */
  21734. subMaterials: Nullable<Material>[];
  21735. /**
  21736. * Function used to align with Node.getChildren()
  21737. * @returns the list of Materials used within the multi material
  21738. */
  21739. getChildren(): Nullable<Material>[];
  21740. /**
  21741. * Instantiates a new Multi Material
  21742. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21743. * separate meshes. This can be use to improve performances.
  21744. * @see http://doc.babylonjs.com/how_to/multi_materials
  21745. * @param name Define the name in the scene
  21746. * @param scene Define the scene the material belongs to
  21747. */
  21748. constructor(name: string, scene: Scene);
  21749. private _hookArray;
  21750. /**
  21751. * Get one of the submaterial by its index in the submaterials array
  21752. * @param index The index to look the sub material at
  21753. * @returns The Material if the index has been defined
  21754. */
  21755. getSubMaterial(index: number): Nullable<Material>;
  21756. /**
  21757. * Get the list of active textures for the whole sub materials list.
  21758. * @returns All the textures that will be used during the rendering
  21759. */
  21760. getActiveTextures(): BaseTexture[];
  21761. /**
  21762. * Gets the current class name of the material e.g. "MultiMaterial"
  21763. * Mainly use in serialization.
  21764. * @returns the class name
  21765. */
  21766. getClassName(): string;
  21767. /**
  21768. * Checks if the material is ready to render the requested sub mesh
  21769. * @param mesh Define the mesh the submesh belongs to
  21770. * @param subMesh Define the sub mesh to look readyness for
  21771. * @param useInstances Define whether or not the material is used with instances
  21772. * @returns true if ready, otherwise false
  21773. */
  21774. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21775. /**
  21776. * Clones the current material and its related sub materials
  21777. * @param name Define the name of the newly cloned material
  21778. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21779. * @returns the cloned material
  21780. */
  21781. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21782. /**
  21783. * Serializes the materials into a JSON representation.
  21784. * @returns the JSON representation
  21785. */
  21786. serialize(): any;
  21787. /**
  21788. * Dispose the material and release its associated resources
  21789. * @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)
  21790. * @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)
  21791. * @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)
  21792. */
  21793. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21794. /**
  21795. * Creates a MultiMaterial from parsed MultiMaterial data.
  21796. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21797. * @param scene defines the hosting scene
  21798. * @returns a new MultiMaterial
  21799. */
  21800. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21801. }
  21802. }
  21803. declare module "babylonjs/Meshes/subMesh" {
  21804. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21805. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21806. import { Engine } from "babylonjs/Engines/engine";
  21807. import { Collider } from "babylonjs/Collisions/collider";
  21808. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21809. import { Ray } from "babylonjs/Culling/ray";
  21810. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21811. import { Effect } from "babylonjs/Materials/effect";
  21812. import { Material } from "babylonjs/Materials/material";
  21813. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21815. import { Mesh } from "babylonjs/Meshes/mesh";
  21816. /**
  21817. * Base class for submeshes
  21818. */
  21819. export class BaseSubMesh {
  21820. /** @hidden */
  21821. _materialDefines: Nullable<MaterialDefines>;
  21822. /** @hidden */
  21823. _materialEffect: Nullable<Effect>;
  21824. /**
  21825. * Gets associated effect
  21826. */
  21827. readonly effect: Nullable<Effect>;
  21828. /**
  21829. * Sets associated effect (effect used to render this submesh)
  21830. * @param effect defines the effect to associate with
  21831. * @param defines defines the set of defines used to compile this effect
  21832. */
  21833. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21834. }
  21835. /**
  21836. * Defines a subdivision inside a mesh
  21837. */
  21838. export class SubMesh extends BaseSubMesh implements ICullable {
  21839. /** the material index to use */
  21840. materialIndex: number;
  21841. /** vertex index start */
  21842. verticesStart: number;
  21843. /** vertices count */
  21844. verticesCount: number;
  21845. /** index start */
  21846. indexStart: number;
  21847. /** indices count */
  21848. indexCount: number;
  21849. /** @hidden */
  21850. _linesIndexCount: number;
  21851. private _mesh;
  21852. private _renderingMesh;
  21853. private _boundingInfo;
  21854. private _linesIndexBuffer;
  21855. /** @hidden */
  21856. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21857. /** @hidden */
  21858. _trianglePlanes: Plane[];
  21859. /** @hidden */
  21860. _lastColliderTransformMatrix: Matrix;
  21861. /** @hidden */
  21862. _renderId: number;
  21863. /** @hidden */
  21864. _alphaIndex: number;
  21865. /** @hidden */
  21866. _distanceToCamera: number;
  21867. /** @hidden */
  21868. _id: number;
  21869. private _currentMaterial;
  21870. /**
  21871. * Add a new submesh to a mesh
  21872. * @param materialIndex defines the material index to use
  21873. * @param verticesStart defines vertex index start
  21874. * @param verticesCount defines vertices count
  21875. * @param indexStart defines index start
  21876. * @param indexCount defines indices count
  21877. * @param mesh defines the parent mesh
  21878. * @param renderingMesh defines an optional rendering mesh
  21879. * @param createBoundingBox defines if bounding box should be created for this submesh
  21880. * @returns the new submesh
  21881. */
  21882. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21883. /**
  21884. * Creates a new submesh
  21885. * @param materialIndex defines the material index to use
  21886. * @param verticesStart defines vertex index start
  21887. * @param verticesCount defines vertices count
  21888. * @param indexStart defines index start
  21889. * @param indexCount defines indices count
  21890. * @param mesh defines the parent mesh
  21891. * @param renderingMesh defines an optional rendering mesh
  21892. * @param createBoundingBox defines if bounding box should be created for this submesh
  21893. */
  21894. constructor(
  21895. /** the material index to use */
  21896. materialIndex: number,
  21897. /** vertex index start */
  21898. verticesStart: number,
  21899. /** vertices count */
  21900. verticesCount: number,
  21901. /** index start */
  21902. indexStart: number,
  21903. /** indices count */
  21904. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21905. /**
  21906. * Returns true if this submesh covers the entire parent mesh
  21907. * @ignorenaming
  21908. */
  21909. readonly IsGlobal: boolean;
  21910. /**
  21911. * Returns the submesh BoudingInfo object
  21912. * @returns current bounding info (or mesh's one if the submesh is global)
  21913. */
  21914. getBoundingInfo(): BoundingInfo;
  21915. /**
  21916. * Sets the submesh BoundingInfo
  21917. * @param boundingInfo defines the new bounding info to use
  21918. * @returns the SubMesh
  21919. */
  21920. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21921. /**
  21922. * Returns the mesh of the current submesh
  21923. * @return the parent mesh
  21924. */
  21925. getMesh(): AbstractMesh;
  21926. /**
  21927. * Returns the rendering mesh of the submesh
  21928. * @returns the rendering mesh (could be different from parent mesh)
  21929. */
  21930. getRenderingMesh(): Mesh;
  21931. /**
  21932. * Returns the submesh material
  21933. * @returns null or the current material
  21934. */
  21935. getMaterial(): Nullable<Material>;
  21936. /**
  21937. * Sets a new updated BoundingInfo object to the submesh
  21938. * @returns the SubMesh
  21939. */
  21940. refreshBoundingInfo(): SubMesh;
  21941. /** @hidden */
  21942. _checkCollision(collider: Collider): boolean;
  21943. /**
  21944. * Updates the submesh BoundingInfo
  21945. * @param world defines the world matrix to use to update the bounding info
  21946. * @returns the submesh
  21947. */
  21948. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21949. /**
  21950. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21951. * @param frustumPlanes defines the frustum planes
  21952. * @returns true if the submesh is intersecting with the frustum
  21953. */
  21954. isInFrustum(frustumPlanes: Plane[]): boolean;
  21955. /**
  21956. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21957. * @param frustumPlanes defines the frustum planes
  21958. * @returns true if the submesh is inside the frustum
  21959. */
  21960. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21961. /**
  21962. * Renders the submesh
  21963. * @param enableAlphaMode defines if alpha needs to be used
  21964. * @returns the submesh
  21965. */
  21966. render(enableAlphaMode: boolean): SubMesh;
  21967. /**
  21968. * @hidden
  21969. */
  21970. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21971. /**
  21972. * Checks if the submesh intersects with a ray
  21973. * @param ray defines the ray to test
  21974. * @returns true is the passed ray intersects the submesh bounding box
  21975. */
  21976. canIntersects(ray: Ray): boolean;
  21977. /**
  21978. * Intersects current submesh with a ray
  21979. * @param ray defines the ray to test
  21980. * @param positions defines mesh's positions array
  21981. * @param indices defines mesh's indices array
  21982. * @param fastCheck defines if only bounding info should be used
  21983. * @returns intersection info or null if no intersection
  21984. */
  21985. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21986. /** @hidden */
  21987. private _intersectLines;
  21988. /** @hidden */
  21989. private _intersectTriangles;
  21990. /** @hidden */
  21991. _rebuild(): void;
  21992. /**
  21993. * Creates a new submesh from the passed mesh
  21994. * @param newMesh defines the new hosting mesh
  21995. * @param newRenderingMesh defines an optional rendering mesh
  21996. * @returns the new submesh
  21997. */
  21998. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21999. /**
  22000. * Release associated resources
  22001. */
  22002. dispose(): void;
  22003. /**
  22004. * Gets the class name
  22005. * @returns the string "SubMesh".
  22006. */
  22007. getClassName(): string;
  22008. /**
  22009. * Creates a new submesh from indices data
  22010. * @param materialIndex the index of the main mesh material
  22011. * @param startIndex the index where to start the copy in the mesh indices array
  22012. * @param indexCount the number of indices to copy then from the startIndex
  22013. * @param mesh the main mesh to create the submesh from
  22014. * @param renderingMesh the optional rendering mesh
  22015. * @returns a new submesh
  22016. */
  22017. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22018. }
  22019. }
  22020. declare module "babylonjs/Meshes/geometry" {
  22021. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22022. import { Scene } from "babylonjs/scene";
  22023. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22024. import { Engine } from "babylonjs/Engines/engine";
  22025. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22026. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22027. import { Effect } from "babylonjs/Materials/effect";
  22028. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22029. import { Mesh } from "babylonjs/Meshes/mesh";
  22030. /**
  22031. * Class used to store geometry data (vertex buffers + index buffer)
  22032. */
  22033. export class Geometry implements IGetSetVerticesData {
  22034. /**
  22035. * Gets or sets the ID of the geometry
  22036. */
  22037. id: string;
  22038. /**
  22039. * Gets or sets the unique ID of the geometry
  22040. */
  22041. uniqueId: number;
  22042. /**
  22043. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22044. */
  22045. delayLoadState: number;
  22046. /**
  22047. * Gets the file containing the data to load when running in delay load state
  22048. */
  22049. delayLoadingFile: Nullable<string>;
  22050. /**
  22051. * Callback called when the geometry is updated
  22052. */
  22053. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22054. private _scene;
  22055. private _engine;
  22056. private _meshes;
  22057. private _totalVertices;
  22058. /** @hidden */
  22059. _indices: IndicesArray;
  22060. /** @hidden */
  22061. _vertexBuffers: {
  22062. [key: string]: VertexBuffer;
  22063. };
  22064. private _isDisposed;
  22065. private _extend;
  22066. private _boundingBias;
  22067. /** @hidden */
  22068. _delayInfo: Array<string>;
  22069. private _indexBuffer;
  22070. private _indexBufferIsUpdatable;
  22071. /** @hidden */
  22072. _boundingInfo: Nullable<BoundingInfo>;
  22073. /** @hidden */
  22074. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22075. /** @hidden */
  22076. _softwareSkinningFrameId: number;
  22077. private _vertexArrayObjects;
  22078. private _updatable;
  22079. /** @hidden */
  22080. _positions: Nullable<Vector3[]>;
  22081. /**
  22082. * 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
  22083. */
  22084. /**
  22085. * 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
  22086. */
  22087. boundingBias: Vector2;
  22088. /**
  22089. * Static function used to attach a new empty geometry to a mesh
  22090. * @param mesh defines the mesh to attach the geometry to
  22091. * @returns the new Geometry
  22092. */
  22093. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22094. /**
  22095. * Creates a new geometry
  22096. * @param id defines the unique ID
  22097. * @param scene defines the hosting scene
  22098. * @param vertexData defines the VertexData used to get geometry data
  22099. * @param updatable defines if geometry must be updatable (false by default)
  22100. * @param mesh defines the mesh that will be associated with the geometry
  22101. */
  22102. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22103. /**
  22104. * Gets the current extend of the geometry
  22105. */
  22106. readonly extend: {
  22107. minimum: Vector3;
  22108. maximum: Vector3;
  22109. };
  22110. /**
  22111. * Gets the hosting scene
  22112. * @returns the hosting Scene
  22113. */
  22114. getScene(): Scene;
  22115. /**
  22116. * Gets the hosting engine
  22117. * @returns the hosting Engine
  22118. */
  22119. getEngine(): Engine;
  22120. /**
  22121. * Defines if the geometry is ready to use
  22122. * @returns true if the geometry is ready to be used
  22123. */
  22124. isReady(): boolean;
  22125. /**
  22126. * Gets a value indicating that the geometry should not be serialized
  22127. */
  22128. readonly doNotSerialize: boolean;
  22129. /** @hidden */
  22130. _rebuild(): void;
  22131. /**
  22132. * Affects all geometry data in one call
  22133. * @param vertexData defines the geometry data
  22134. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22135. */
  22136. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22137. /**
  22138. * Set specific vertex data
  22139. * @param kind defines the data kind (Position, normal, etc...)
  22140. * @param data defines the vertex data to use
  22141. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22142. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22143. */
  22144. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22145. /**
  22146. * Removes a specific vertex data
  22147. * @param kind defines the data kind (Position, normal, etc...)
  22148. */
  22149. removeVerticesData(kind: string): void;
  22150. /**
  22151. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22152. * @param buffer defines the vertex buffer to use
  22153. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22154. */
  22155. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22156. /**
  22157. * Update a specific vertex buffer
  22158. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22159. * It will do nothing if the buffer is not updatable
  22160. * @param kind defines the data kind (Position, normal, etc...)
  22161. * @param data defines the data to use
  22162. * @param offset defines the offset in the target buffer where to store the data
  22163. * @param useBytes set to true if the offset is in bytes
  22164. */
  22165. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22166. /**
  22167. * Update a specific vertex buffer
  22168. * This function will create a new buffer if the current one is not updatable
  22169. * @param kind defines the data kind (Position, normal, etc...)
  22170. * @param data defines the data to use
  22171. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22172. */
  22173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22174. private _updateBoundingInfo;
  22175. /** @hidden */
  22176. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22177. /**
  22178. * Gets total number of vertices
  22179. * @returns the total number of vertices
  22180. */
  22181. getTotalVertices(): number;
  22182. /**
  22183. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22184. * @param kind defines the data kind (Position, normal, etc...)
  22185. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22186. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22187. * @returns a float array containing vertex data
  22188. */
  22189. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22190. /**
  22191. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22192. * @param kind defines the data kind (Position, normal, etc...)
  22193. * @returns true if the vertex buffer with the specified kind is updatable
  22194. */
  22195. isVertexBufferUpdatable(kind: string): boolean;
  22196. /**
  22197. * Gets a specific vertex buffer
  22198. * @param kind defines the data kind (Position, normal, etc...)
  22199. * @returns a VertexBuffer
  22200. */
  22201. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22202. /**
  22203. * Returns all vertex buffers
  22204. * @return an object holding all vertex buffers indexed by kind
  22205. */
  22206. getVertexBuffers(): Nullable<{
  22207. [key: string]: VertexBuffer;
  22208. }>;
  22209. /**
  22210. * Gets a boolean indicating if specific vertex buffer is present
  22211. * @param kind defines the data kind (Position, normal, etc...)
  22212. * @returns true if data is present
  22213. */
  22214. isVerticesDataPresent(kind: string): boolean;
  22215. /**
  22216. * Gets a list of all attached data kinds (Position, normal, etc...)
  22217. * @returns a list of string containing all kinds
  22218. */
  22219. getVerticesDataKinds(): string[];
  22220. /**
  22221. * Update index buffer
  22222. * @param indices defines the indices to store in the index buffer
  22223. * @param offset defines the offset in the target buffer where to store the data
  22224. */
  22225. updateIndices(indices: IndicesArray, offset?: number): void;
  22226. /**
  22227. * Creates a new index buffer
  22228. * @param indices defines the indices to store in the index buffer
  22229. * @param totalVertices defines the total number of vertices (could be null)
  22230. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22231. */
  22232. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22233. /**
  22234. * Return the total number of indices
  22235. * @returns the total number of indices
  22236. */
  22237. getTotalIndices(): number;
  22238. /**
  22239. * Gets the index buffer array
  22240. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22242. * @returns the index buffer array
  22243. */
  22244. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22245. /**
  22246. * Gets the index buffer
  22247. * @return the index buffer
  22248. */
  22249. getIndexBuffer(): Nullable<WebGLBuffer>;
  22250. /** @hidden */
  22251. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22252. /**
  22253. * Release the associated resources for a specific mesh
  22254. * @param mesh defines the source mesh
  22255. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22256. */
  22257. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22258. /**
  22259. * Apply current geometry to a given mesh
  22260. * @param mesh defines the mesh to apply geometry to
  22261. */
  22262. applyToMesh(mesh: Mesh): void;
  22263. private _updateExtend;
  22264. private _applyToMesh;
  22265. private notifyUpdate;
  22266. /**
  22267. * Load the geometry if it was flagged as delay loaded
  22268. * @param scene defines the hosting scene
  22269. * @param onLoaded defines a callback called when the geometry is loaded
  22270. */
  22271. load(scene: Scene, onLoaded?: () => void): void;
  22272. private _queueLoad;
  22273. /**
  22274. * Invert the geometry to move from a right handed system to a left handed one.
  22275. */
  22276. toLeftHanded(): void;
  22277. /** @hidden */
  22278. _resetPointsArrayCache(): void;
  22279. /** @hidden */
  22280. _generatePointsArray(): boolean;
  22281. /**
  22282. * Gets a value indicating if the geometry is disposed
  22283. * @returns true if the geometry was disposed
  22284. */
  22285. isDisposed(): boolean;
  22286. private _disposeVertexArrayObjects;
  22287. /**
  22288. * Free all associated resources
  22289. */
  22290. dispose(): void;
  22291. /**
  22292. * Clone the current geometry into a new geometry
  22293. * @param id defines the unique ID of the new geometry
  22294. * @returns a new geometry object
  22295. */
  22296. copy(id: string): Geometry;
  22297. /**
  22298. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22299. * @return a JSON representation of the current geometry data (without the vertices data)
  22300. */
  22301. serialize(): any;
  22302. private toNumberArray;
  22303. /**
  22304. * Serialize all vertices data into a JSON oject
  22305. * @returns a JSON representation of the current geometry data
  22306. */
  22307. serializeVerticeData(): any;
  22308. /**
  22309. * Extracts a clone of a mesh geometry
  22310. * @param mesh defines the source mesh
  22311. * @param id defines the unique ID of the new geometry object
  22312. * @returns the new geometry object
  22313. */
  22314. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22315. /**
  22316. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22317. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22318. * Be aware Math.random() could cause collisions, but:
  22319. * "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"
  22320. * @returns a string containing a new GUID
  22321. */
  22322. static RandomId(): string;
  22323. /** @hidden */
  22324. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22325. private static _CleanMatricesWeights;
  22326. /**
  22327. * Create a new geometry from persisted data (Using .babylon file format)
  22328. * @param parsedVertexData defines the persisted data
  22329. * @param scene defines the hosting scene
  22330. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22331. * @returns the new geometry object
  22332. */
  22333. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22334. }
  22335. /**
  22336. * Abstract class used to provide common services for all typed geometries
  22337. * @hidden
  22338. */
  22339. export class _PrimitiveGeometry extends Geometry {
  22340. private _canBeRegenerated;
  22341. private _beingRegenerated;
  22342. /**
  22343. * Creates a new typed geometry
  22344. * @param id defines the unique ID of the geometry
  22345. * @param scene defines the hosting scene
  22346. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22347. * @param mesh defines the hosting mesh (can be null)
  22348. */
  22349. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22350. /**
  22351. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  22352. * @returns true if the geometry can be regenerated
  22353. */
  22354. canBeRegenerated(): boolean;
  22355. /**
  22356. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  22357. */
  22358. regenerate(): void;
  22359. /**
  22360. * Clone the geometry
  22361. * @param id defines the unique ID of the new geometry
  22362. * @returns the new geometry
  22363. */
  22364. asNewGeometry(id: string): Geometry;
  22365. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22366. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  22367. /** @hidden */
  22368. _regenerateVertexData(): VertexData;
  22369. copy(id: string): Geometry;
  22370. serialize(): any;
  22371. }
  22372. /**
  22373. * Creates a ribbon geometry
  22374. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  22375. */
  22376. export class RibbonGeometry extends _PrimitiveGeometry {
  22377. /**
  22378. * Defines the array of paths to use
  22379. */
  22380. pathArray: Vector3[][];
  22381. /**
  22382. * Defines if the last and first points of each path in your pathArray must be joined
  22383. */
  22384. closeArray: boolean;
  22385. /**
  22386. * Defines if the last and first points of each path in your pathArray must be joined
  22387. */
  22388. closePath: boolean;
  22389. /**
  22390. * Defines the offset between points
  22391. */
  22392. offset: number;
  22393. /**
  22394. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22395. */
  22396. side: number;
  22397. /**
  22398. * Creates a ribbon geometry
  22399. * @param id defines the unique ID of the geometry
  22400. * @param scene defines the hosting scene
  22401. * @param pathArray defines the array of paths to use
  22402. * @param closeArray defines if the last path and the first path must be joined
  22403. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  22404. * @param offset defines the offset between points
  22405. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22406. * @param mesh defines the hosting mesh (can be null)
  22407. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22408. */
  22409. constructor(id: string, scene: Scene,
  22410. /**
  22411. * Defines the array of paths to use
  22412. */
  22413. pathArray: Vector3[][],
  22414. /**
  22415. * Defines if the last and first points of each path in your pathArray must be joined
  22416. */
  22417. closeArray: boolean,
  22418. /**
  22419. * Defines if the last and first points of each path in your pathArray must be joined
  22420. */
  22421. closePath: boolean,
  22422. /**
  22423. * Defines the offset between points
  22424. */
  22425. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  22426. /**
  22427. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22428. */
  22429. side?: number);
  22430. /** @hidden */
  22431. _regenerateVertexData(): VertexData;
  22432. copy(id: string): Geometry;
  22433. }
  22434. /**
  22435. * Creates a box geometry
  22436. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  22437. */
  22438. export class BoxGeometry extends _PrimitiveGeometry {
  22439. /**
  22440. * Defines the zise of the box (width, height and depth are the same)
  22441. */
  22442. size: number;
  22443. /**
  22444. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22445. */
  22446. side: number;
  22447. /**
  22448. * Creates a box geometry
  22449. * @param id defines the unique ID of the geometry
  22450. * @param scene defines the hosting scene
  22451. * @param size defines the zise of the box (width, height and depth are the same)
  22452. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22453. * @param mesh defines the hosting mesh (can be null)
  22454. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22455. */
  22456. constructor(id: string, scene: Scene,
  22457. /**
  22458. * Defines the zise of the box (width, height and depth are the same)
  22459. */
  22460. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22461. /**
  22462. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22463. */
  22464. side?: number);
  22465. /** @hidden */
  22466. _regenerateVertexData(): VertexData;
  22467. copy(id: string): Geometry;
  22468. serialize(): any;
  22469. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  22470. }
  22471. /**
  22472. * Creates a sphere geometry
  22473. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  22474. */
  22475. export class SphereGeometry extends _PrimitiveGeometry {
  22476. /**
  22477. * Defines the number of segments to use to create the sphere
  22478. */
  22479. segments: number;
  22480. /**
  22481. * Defines the diameter of the sphere
  22482. */
  22483. diameter: number;
  22484. /**
  22485. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22486. */
  22487. side: number;
  22488. /**
  22489. * Create a new sphere geometry
  22490. * @param id defines the unique ID of the geometry
  22491. * @param scene defines the hosting scene
  22492. * @param segments defines the number of segments to use to create the sphere
  22493. * @param diameter defines the diameter of the sphere
  22494. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22495. * @param mesh defines the hosting mesh (can be null)
  22496. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22497. */
  22498. constructor(id: string, scene: Scene,
  22499. /**
  22500. * Defines the number of segments to use to create the sphere
  22501. */
  22502. segments: number,
  22503. /**
  22504. * Defines the diameter of the sphere
  22505. */
  22506. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22507. /**
  22508. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22509. */
  22510. side?: number);
  22511. /** @hidden */
  22512. _regenerateVertexData(): VertexData;
  22513. copy(id: string): Geometry;
  22514. serialize(): any;
  22515. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  22516. }
  22517. /**
  22518. * Creates a disc geometry
  22519. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22520. */
  22521. export class DiscGeometry extends _PrimitiveGeometry {
  22522. /**
  22523. * Defines the radius of the disc
  22524. */
  22525. radius: number;
  22526. /**
  22527. * Defines the tesselation factor to apply to the disc
  22528. */
  22529. tessellation: number;
  22530. /**
  22531. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22532. */
  22533. side: number;
  22534. /**
  22535. * Creates a new disc geometry
  22536. * @param id defines the unique ID of the geometry
  22537. * @param scene defines the hosting scene
  22538. * @param radius defines the radius of the disc
  22539. * @param tessellation defines the tesselation factor to apply to the disc
  22540. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22541. * @param mesh defines the hosting mesh (can be null)
  22542. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22543. */
  22544. constructor(id: string, scene: Scene,
  22545. /**
  22546. * Defines the radius of the disc
  22547. */
  22548. radius: number,
  22549. /**
  22550. * Defines the tesselation factor to apply to the disc
  22551. */
  22552. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22553. /**
  22554. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22555. */
  22556. side?: number);
  22557. /** @hidden */
  22558. _regenerateVertexData(): VertexData;
  22559. copy(id: string): Geometry;
  22560. }
  22561. /**
  22562. * Creates a new cylinder geometry
  22563. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22564. */
  22565. export class CylinderGeometry extends _PrimitiveGeometry {
  22566. /**
  22567. * Defines the height of the cylinder
  22568. */
  22569. height: number;
  22570. /**
  22571. * Defines the diameter of the cylinder's top cap
  22572. */
  22573. diameterTop: number;
  22574. /**
  22575. * Defines the diameter of the cylinder's bottom cap
  22576. */
  22577. diameterBottom: number;
  22578. /**
  22579. * Defines the tessellation factor to apply to the cylinder
  22580. */
  22581. tessellation: number;
  22582. /**
  22583. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22584. */
  22585. subdivisions: number;
  22586. /**
  22587. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22588. */
  22589. side: number;
  22590. /**
  22591. * Creates a new cylinder geometry
  22592. * @param id defines the unique ID of the geometry
  22593. * @param scene defines the hosting scene
  22594. * @param height defines the height of the cylinder
  22595. * @param diameterTop defines the diameter of the cylinder's top cap
  22596. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22597. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22598. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22599. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22600. * @param mesh defines the hosting mesh (can be null)
  22601. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22602. */
  22603. constructor(id: string, scene: Scene,
  22604. /**
  22605. * Defines the height of the cylinder
  22606. */
  22607. height: number,
  22608. /**
  22609. * Defines the diameter of the cylinder's top cap
  22610. */
  22611. diameterTop: number,
  22612. /**
  22613. * Defines the diameter of the cylinder's bottom cap
  22614. */
  22615. diameterBottom: number,
  22616. /**
  22617. * Defines the tessellation factor to apply to the cylinder
  22618. */
  22619. tessellation: number,
  22620. /**
  22621. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22622. */
  22623. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22624. /**
  22625. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22626. */
  22627. side?: number);
  22628. /** @hidden */
  22629. _regenerateVertexData(): VertexData;
  22630. copy(id: string): Geometry;
  22631. serialize(): any;
  22632. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22633. }
  22634. /**
  22635. * Creates a new torus geometry
  22636. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22637. */
  22638. export class TorusGeometry extends _PrimitiveGeometry {
  22639. /**
  22640. * Defines the diameter of the torus
  22641. */
  22642. diameter: number;
  22643. /**
  22644. * Defines the thickness of the torus (ie. internal diameter)
  22645. */
  22646. thickness: number;
  22647. /**
  22648. * Defines the tesselation factor to apply to the torus
  22649. */
  22650. tessellation: number;
  22651. /**
  22652. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22653. */
  22654. side: number;
  22655. /**
  22656. * Creates a new torus geometry
  22657. * @param id defines the unique ID of the geometry
  22658. * @param scene defines the hosting scene
  22659. * @param diameter defines the diameter of the torus
  22660. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22661. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22662. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22663. * @param mesh defines the hosting mesh (can be null)
  22664. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22665. */
  22666. constructor(id: string, scene: Scene,
  22667. /**
  22668. * Defines the diameter of the torus
  22669. */
  22670. diameter: number,
  22671. /**
  22672. * Defines the thickness of the torus (ie. internal diameter)
  22673. */
  22674. thickness: number,
  22675. /**
  22676. * Defines the tesselation factor to apply to the torus
  22677. */
  22678. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22679. /**
  22680. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22681. */
  22682. side?: number);
  22683. /** @hidden */
  22684. _regenerateVertexData(): VertexData;
  22685. copy(id: string): Geometry;
  22686. serialize(): any;
  22687. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22688. }
  22689. /**
  22690. * Creates a new ground geometry
  22691. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22692. */
  22693. export class GroundGeometry extends _PrimitiveGeometry {
  22694. /**
  22695. * Defines the width of the ground
  22696. */
  22697. width: number;
  22698. /**
  22699. * Defines the height of the ground
  22700. */
  22701. height: number;
  22702. /**
  22703. * Defines the subdivisions to apply to the ground
  22704. */
  22705. subdivisions: number;
  22706. /**
  22707. * Creates a new ground geometry
  22708. * @param id defines the unique ID of the geometry
  22709. * @param scene defines the hosting scene
  22710. * @param width defines the width of the ground
  22711. * @param height defines the height of the ground
  22712. * @param subdivisions defines the subdivisions to apply to the ground
  22713. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22714. * @param mesh defines the hosting mesh (can be null)
  22715. */
  22716. constructor(id: string, scene: Scene,
  22717. /**
  22718. * Defines the width of the ground
  22719. */
  22720. width: number,
  22721. /**
  22722. * Defines the height of the ground
  22723. */
  22724. height: number,
  22725. /**
  22726. * Defines the subdivisions to apply to the ground
  22727. */
  22728. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22729. /** @hidden */
  22730. _regenerateVertexData(): VertexData;
  22731. copy(id: string): Geometry;
  22732. serialize(): any;
  22733. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22734. }
  22735. /**
  22736. * Creates a tiled ground geometry
  22737. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22738. */
  22739. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22740. /**
  22741. * Defines the minimum value on X axis
  22742. */
  22743. xmin: number;
  22744. /**
  22745. * Defines the minimum value on Z axis
  22746. */
  22747. zmin: number;
  22748. /**
  22749. * Defines the maximum value on X axis
  22750. */
  22751. xmax: number;
  22752. /**
  22753. * Defines the maximum value on Z axis
  22754. */
  22755. zmax: number;
  22756. /**
  22757. * Defines the subdivisions to apply to the ground
  22758. */
  22759. subdivisions: {
  22760. w: number;
  22761. h: number;
  22762. };
  22763. /**
  22764. * Defines the precision to use when computing the tiles
  22765. */
  22766. precision: {
  22767. w: number;
  22768. h: number;
  22769. };
  22770. /**
  22771. * Creates a tiled ground geometry
  22772. * @param id defines the unique ID of the geometry
  22773. * @param scene defines the hosting scene
  22774. * @param xmin defines the minimum value on X axis
  22775. * @param zmin defines the minimum value on Z axis
  22776. * @param xmax defines the maximum value on X axis
  22777. * @param zmax defines the maximum value on Z axis
  22778. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22779. * @param precision defines the precision to use when computing the tiles
  22780. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22781. * @param mesh defines the hosting mesh (can be null)
  22782. */
  22783. constructor(id: string, scene: Scene,
  22784. /**
  22785. * Defines the minimum value on X axis
  22786. */
  22787. xmin: number,
  22788. /**
  22789. * Defines the minimum value on Z axis
  22790. */
  22791. zmin: number,
  22792. /**
  22793. * Defines the maximum value on X axis
  22794. */
  22795. xmax: number,
  22796. /**
  22797. * Defines the maximum value on Z axis
  22798. */
  22799. zmax: number,
  22800. /**
  22801. * Defines the subdivisions to apply to the ground
  22802. */
  22803. subdivisions: {
  22804. w: number;
  22805. h: number;
  22806. },
  22807. /**
  22808. * Defines the precision to use when computing the tiles
  22809. */
  22810. precision: {
  22811. w: number;
  22812. h: number;
  22813. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22814. /** @hidden */
  22815. _regenerateVertexData(): VertexData;
  22816. copy(id: string): Geometry;
  22817. }
  22818. /**
  22819. * Creates a plane geometry
  22820. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22821. */
  22822. export class PlaneGeometry extends _PrimitiveGeometry {
  22823. /**
  22824. * Defines the size of the plane (width === height)
  22825. */
  22826. size: number;
  22827. /**
  22828. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22829. */
  22830. side: number;
  22831. /**
  22832. * Creates a plane geometry
  22833. * @param id defines the unique ID of the geometry
  22834. * @param scene defines the hosting scene
  22835. * @param size defines the size of the plane (width === height)
  22836. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22837. * @param mesh defines the hosting mesh (can be null)
  22838. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22839. */
  22840. constructor(id: string, scene: Scene,
  22841. /**
  22842. * Defines the size of the plane (width === height)
  22843. */
  22844. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22845. /**
  22846. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22847. */
  22848. side?: number);
  22849. /** @hidden */
  22850. _regenerateVertexData(): VertexData;
  22851. copy(id: string): Geometry;
  22852. serialize(): any;
  22853. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22854. }
  22855. /**
  22856. * Creates a torus knot geometry
  22857. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22858. */
  22859. export class TorusKnotGeometry extends _PrimitiveGeometry {
  22860. /**
  22861. * Defines the radius of the torus knot
  22862. */
  22863. radius: number;
  22864. /**
  22865. * Defines the thickness of the torus knot tube
  22866. */
  22867. tube: number;
  22868. /**
  22869. * Defines the number of radial segments
  22870. */
  22871. radialSegments: number;
  22872. /**
  22873. * Defines the number of tubular segments
  22874. */
  22875. tubularSegments: number;
  22876. /**
  22877. * Defines the first number of windings
  22878. */
  22879. p: number;
  22880. /**
  22881. * Defines the second number of windings
  22882. */
  22883. q: number;
  22884. /**
  22885. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22886. */
  22887. side: number;
  22888. /**
  22889. * Creates a torus knot geometry
  22890. * @param id defines the unique ID of the geometry
  22891. * @param scene defines the hosting scene
  22892. * @param radius defines the radius of the torus knot
  22893. * @param tube defines the thickness of the torus knot tube
  22894. * @param radialSegments defines the number of radial segments
  22895. * @param tubularSegments defines the number of tubular segments
  22896. * @param p defines the first number of windings
  22897. * @param q defines the second number of windings
  22898. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22899. * @param mesh defines the hosting mesh (can be null)
  22900. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22901. */
  22902. constructor(id: string, scene: Scene,
  22903. /**
  22904. * Defines the radius of the torus knot
  22905. */
  22906. radius: number,
  22907. /**
  22908. * Defines the thickness of the torus knot tube
  22909. */
  22910. tube: number,
  22911. /**
  22912. * Defines the number of radial segments
  22913. */
  22914. radialSegments: number,
  22915. /**
  22916. * Defines the number of tubular segments
  22917. */
  22918. tubularSegments: number,
  22919. /**
  22920. * Defines the first number of windings
  22921. */
  22922. p: number,
  22923. /**
  22924. * Defines the second number of windings
  22925. */
  22926. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22927. /**
  22928. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22929. */
  22930. side?: number);
  22931. /** @hidden */
  22932. _regenerateVertexData(): VertexData;
  22933. copy(id: string): Geometry;
  22934. serialize(): any;
  22935. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22936. }
  22937. }
  22938. declare module "babylonjs/Meshes/mesh.vertexData" {
  22939. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22940. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22941. import { Geometry } from "babylonjs/Meshes/geometry";
  22942. import { Mesh } from "babylonjs/Meshes/mesh";
  22943. /**
  22944. * Define an interface for all classes that will get and set the data on vertices
  22945. */
  22946. export interface IGetSetVerticesData {
  22947. /**
  22948. * Gets a boolean indicating if specific vertex data is present
  22949. * @param kind defines the vertex data kind to use
  22950. * @returns true is data kind is present
  22951. */
  22952. isVerticesDataPresent(kind: string): boolean;
  22953. /**
  22954. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22955. * @param kind defines the data kind (Position, normal, etc...)
  22956. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22957. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22958. * @returns a float array containing vertex data
  22959. */
  22960. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22961. /**
  22962. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22963. * @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.
  22964. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22965. * @returns the indices array or an empty array if the mesh has no geometry
  22966. */
  22967. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22968. /**
  22969. * Set specific vertex data
  22970. * @param kind defines the data kind (Position, normal, etc...)
  22971. * @param data defines the vertex data to use
  22972. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22973. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22974. */
  22975. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22976. /**
  22977. * Update a specific associated vertex buffer
  22978. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22979. * - VertexBuffer.PositionKind
  22980. * - VertexBuffer.UVKind
  22981. * - VertexBuffer.UV2Kind
  22982. * - VertexBuffer.UV3Kind
  22983. * - VertexBuffer.UV4Kind
  22984. * - VertexBuffer.UV5Kind
  22985. * - VertexBuffer.UV6Kind
  22986. * - VertexBuffer.ColorKind
  22987. * - VertexBuffer.MatricesIndicesKind
  22988. * - VertexBuffer.MatricesIndicesExtraKind
  22989. * - VertexBuffer.MatricesWeightsKind
  22990. * - VertexBuffer.MatricesWeightsExtraKind
  22991. * @param data defines the data source
  22992. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22993. * @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)
  22994. */
  22995. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22996. /**
  22997. * Creates a new index buffer
  22998. * @param indices defines the indices to store in the index buffer
  22999. * @param totalVertices defines the total number of vertices (could be null)
  23000. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23001. */
  23002. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23003. }
  23004. /**
  23005. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23006. */
  23007. export class VertexData {
  23008. /**
  23009. * Mesh side orientation : usually the external or front surface
  23010. */
  23011. static readonly FRONTSIDE: number;
  23012. /**
  23013. * Mesh side orientation : usually the internal or back surface
  23014. */
  23015. static readonly BACKSIDE: number;
  23016. /**
  23017. * Mesh side orientation : both internal and external or front and back surfaces
  23018. */
  23019. static readonly DOUBLESIDE: number;
  23020. /**
  23021. * Mesh side orientation : by default, `FRONTSIDE`
  23022. */
  23023. static readonly DEFAULTSIDE: number;
  23024. /**
  23025. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23026. */
  23027. positions: Nullable<FloatArray>;
  23028. /**
  23029. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23030. */
  23031. normals: Nullable<FloatArray>;
  23032. /**
  23033. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23034. */
  23035. tangents: Nullable<FloatArray>;
  23036. /**
  23037. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23038. */
  23039. uvs: Nullable<FloatArray>;
  23040. /**
  23041. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23042. */
  23043. uvs2: Nullable<FloatArray>;
  23044. /**
  23045. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23046. */
  23047. uvs3: Nullable<FloatArray>;
  23048. /**
  23049. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23050. */
  23051. uvs4: Nullable<FloatArray>;
  23052. /**
  23053. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23054. */
  23055. uvs5: Nullable<FloatArray>;
  23056. /**
  23057. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23058. */
  23059. uvs6: Nullable<FloatArray>;
  23060. /**
  23061. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23062. */
  23063. colors: Nullable<FloatArray>;
  23064. /**
  23065. * 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).
  23066. */
  23067. matricesIndices: Nullable<FloatArray>;
  23068. /**
  23069. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23070. */
  23071. matricesWeights: Nullable<FloatArray>;
  23072. /**
  23073. * An array extending the number of possible indices
  23074. */
  23075. matricesIndicesExtra: Nullable<FloatArray>;
  23076. /**
  23077. * An array extending the number of possible weights when the number of indices is extended
  23078. */
  23079. matricesWeightsExtra: Nullable<FloatArray>;
  23080. /**
  23081. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23082. */
  23083. indices: Nullable<IndicesArray>;
  23084. /**
  23085. * Uses the passed data array to set the set the values for the specified kind of data
  23086. * @param data a linear array of floating numbers
  23087. * @param kind the type of data that is being set, eg positions, colors etc
  23088. */
  23089. set(data: FloatArray, kind: string): void;
  23090. /**
  23091. * Associates the vertexData to the passed Mesh.
  23092. * Sets it as updatable or not (default `false`)
  23093. * @param mesh the mesh the vertexData is applied to
  23094. * @param updatable when used and having the value true allows new data to update the vertexData
  23095. * @returns the VertexData
  23096. */
  23097. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23098. /**
  23099. * Associates the vertexData to the passed Geometry.
  23100. * Sets it as updatable or not (default `false`)
  23101. * @param geometry the geometry the vertexData is applied to
  23102. * @param updatable when used and having the value true allows new data to update the vertexData
  23103. * @returns VertexData
  23104. */
  23105. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23106. /**
  23107. * Updates the associated mesh
  23108. * @param mesh the mesh to be updated
  23109. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23110. * @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
  23111. * @returns VertexData
  23112. */
  23113. updateMesh(mesh: Mesh): VertexData;
  23114. /**
  23115. * Updates the associated geometry
  23116. * @param geometry the geometry to be updated
  23117. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23118. * @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
  23119. * @returns VertexData.
  23120. */
  23121. updateGeometry(geometry: Geometry): VertexData;
  23122. private _applyTo;
  23123. private _update;
  23124. /**
  23125. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23126. * @param matrix the transforming matrix
  23127. * @returns the VertexData
  23128. */
  23129. transform(matrix: Matrix): VertexData;
  23130. /**
  23131. * Merges the passed VertexData into the current one
  23132. * @param other the VertexData to be merged into the current one
  23133. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23134. * @returns the modified VertexData
  23135. */
  23136. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23137. private _mergeElement;
  23138. private _validate;
  23139. /**
  23140. * Serializes the VertexData
  23141. * @returns a serialized object
  23142. */
  23143. serialize(): any;
  23144. /**
  23145. * Extracts the vertexData from a mesh
  23146. * @param mesh the mesh from which to extract the VertexData
  23147. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23148. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23149. * @returns the object VertexData associated to the passed mesh
  23150. */
  23151. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23152. /**
  23153. * Extracts the vertexData from the geometry
  23154. * @param geometry the geometry from which to extract the VertexData
  23155. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23156. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23157. * @returns the object VertexData associated to the passed mesh
  23158. */
  23159. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23160. private static _ExtractFrom;
  23161. /**
  23162. * Creates the VertexData for a Ribbon
  23163. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23164. * * pathArray array of paths, each of which an array of successive Vector3
  23165. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23166. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23167. * * 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
  23168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23169. * * 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)
  23170. * * 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)
  23171. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23172. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23173. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23174. * @returns the VertexData of the ribbon
  23175. */
  23176. static CreateRibbon(options: {
  23177. pathArray: Vector3[][];
  23178. closeArray?: boolean;
  23179. closePath?: boolean;
  23180. offset?: number;
  23181. sideOrientation?: number;
  23182. frontUVs?: Vector4;
  23183. backUVs?: Vector4;
  23184. invertUV?: boolean;
  23185. uvs?: Vector2[];
  23186. colors?: Color4[];
  23187. }): VertexData;
  23188. /**
  23189. * Creates the VertexData for a box
  23190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23191. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23192. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23193. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23194. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23195. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23196. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23198. * * 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)
  23199. * * 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)
  23200. * @returns the VertexData of the box
  23201. */
  23202. static CreateBox(options: {
  23203. size?: number;
  23204. width?: number;
  23205. height?: number;
  23206. depth?: number;
  23207. faceUV?: Vector4[];
  23208. faceColors?: Color4[];
  23209. sideOrientation?: number;
  23210. frontUVs?: Vector4;
  23211. backUVs?: Vector4;
  23212. }): VertexData;
  23213. /**
  23214. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23216. * * segments sets the number of horizontal strips optional, default 32
  23217. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23218. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23219. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23220. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23221. * * 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
  23222. * * 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
  23223. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23224. * * 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)
  23225. * * 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)
  23226. * @returns the VertexData of the ellipsoid
  23227. */
  23228. static CreateSphere(options: {
  23229. segments?: number;
  23230. diameter?: number;
  23231. diameterX?: number;
  23232. diameterY?: number;
  23233. diameterZ?: number;
  23234. arc?: number;
  23235. slice?: number;
  23236. sideOrientation?: number;
  23237. frontUVs?: Vector4;
  23238. backUVs?: Vector4;
  23239. }): VertexData;
  23240. /**
  23241. * Creates the VertexData for a cylinder, cone or prism
  23242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23243. * * height sets the height (y direction) of the cylinder, optional, default 2
  23244. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23245. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23246. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23247. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23248. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23249. * * 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
  23250. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23251. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23252. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23253. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23255. * * 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)
  23256. * * 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)
  23257. * @returns the VertexData of the cylinder, cone or prism
  23258. */
  23259. static CreateCylinder(options: {
  23260. height?: number;
  23261. diameterTop?: number;
  23262. diameterBottom?: number;
  23263. diameter?: number;
  23264. tessellation?: number;
  23265. subdivisions?: number;
  23266. arc?: number;
  23267. faceColors?: Color4[];
  23268. faceUV?: Vector4[];
  23269. hasRings?: boolean;
  23270. enclose?: boolean;
  23271. sideOrientation?: number;
  23272. frontUVs?: Vector4;
  23273. backUVs?: Vector4;
  23274. }): VertexData;
  23275. /**
  23276. * Creates the VertexData for a torus
  23277. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23278. * * diameter the diameter of the torus, optional default 1
  23279. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23280. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23282. * * 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)
  23283. * * 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)
  23284. * @returns the VertexData of the torus
  23285. */
  23286. static CreateTorus(options: {
  23287. diameter?: number;
  23288. thickness?: number;
  23289. tessellation?: number;
  23290. sideOrientation?: number;
  23291. frontUVs?: Vector4;
  23292. backUVs?: Vector4;
  23293. }): VertexData;
  23294. /**
  23295. * Creates the VertexData of the LineSystem
  23296. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23297. * - lines an array of lines, each line being an array of successive Vector3
  23298. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23299. * @returns the VertexData of the LineSystem
  23300. */
  23301. static CreateLineSystem(options: {
  23302. lines: Vector3[][];
  23303. colors?: Nullable<Color4[][]>;
  23304. }): VertexData;
  23305. /**
  23306. * Create the VertexData for a DashedLines
  23307. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23308. * - points an array successive Vector3
  23309. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23310. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23311. * - dashNb the intended total number of dashes, optional, default 200
  23312. * @returns the VertexData for the DashedLines
  23313. */
  23314. static CreateDashedLines(options: {
  23315. points: Vector3[];
  23316. dashSize?: number;
  23317. gapSize?: number;
  23318. dashNb?: number;
  23319. }): VertexData;
  23320. /**
  23321. * Creates the VertexData for a Ground
  23322. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23323. * - width the width (x direction) of the ground, optional, default 1
  23324. * - height the height (z direction) of the ground, optional, default 1
  23325. * - subdivisions the number of subdivisions per side, optional, default 1
  23326. * @returns the VertexData of the Ground
  23327. */
  23328. static CreateGround(options: {
  23329. width?: number;
  23330. height?: number;
  23331. subdivisions?: number;
  23332. subdivisionsX?: number;
  23333. subdivisionsY?: number;
  23334. }): VertexData;
  23335. /**
  23336. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23337. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23338. * * xmin the ground minimum X coordinate, optional, default -1
  23339. * * zmin the ground minimum Z coordinate, optional, default -1
  23340. * * xmax the ground maximum X coordinate, optional, default 1
  23341. * * zmax the ground maximum Z coordinate, optional, default 1
  23342. * * 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}
  23343. * * 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}
  23344. * @returns the VertexData of the TiledGround
  23345. */
  23346. static CreateTiledGround(options: {
  23347. xmin: number;
  23348. zmin: number;
  23349. xmax: number;
  23350. zmax: number;
  23351. subdivisions?: {
  23352. w: number;
  23353. h: number;
  23354. };
  23355. precision?: {
  23356. w: number;
  23357. h: number;
  23358. };
  23359. }): VertexData;
  23360. /**
  23361. * Creates the VertexData of the Ground designed from a heightmap
  23362. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23363. * * width the width (x direction) of the ground
  23364. * * height the height (z direction) of the ground
  23365. * * subdivisions the number of subdivisions per side
  23366. * * minHeight the minimum altitude on the ground, optional, default 0
  23367. * * maxHeight the maximum altitude on the ground, optional default 1
  23368. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23369. * * buffer the array holding the image color data
  23370. * * bufferWidth the width of image
  23371. * * bufferHeight the height of image
  23372. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23373. * @returns the VertexData of the Ground designed from a heightmap
  23374. */
  23375. static CreateGroundFromHeightMap(options: {
  23376. width: number;
  23377. height: number;
  23378. subdivisions: number;
  23379. minHeight: number;
  23380. maxHeight: number;
  23381. colorFilter: Color3;
  23382. buffer: Uint8Array;
  23383. bufferWidth: number;
  23384. bufferHeight: number;
  23385. alphaFilter: number;
  23386. }): VertexData;
  23387. /**
  23388. * Creates the VertexData for a Plane
  23389. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23390. * * size sets the width and height of the plane to the value of size, optional default 1
  23391. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23392. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23393. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23394. * * 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)
  23395. * * 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)
  23396. * @returns the VertexData of the box
  23397. */
  23398. static CreatePlane(options: {
  23399. size?: number;
  23400. width?: number;
  23401. height?: number;
  23402. sideOrientation?: number;
  23403. frontUVs?: Vector4;
  23404. backUVs?: Vector4;
  23405. }): VertexData;
  23406. /**
  23407. * Creates the VertexData of the Disc or regular Polygon
  23408. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23409. * * radius the radius of the disc, optional default 0.5
  23410. * * tessellation the number of polygon sides, optional, default 64
  23411. * * 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
  23412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23413. * * 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)
  23414. * * 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)
  23415. * @returns the VertexData of the box
  23416. */
  23417. static CreateDisc(options: {
  23418. radius?: number;
  23419. tessellation?: number;
  23420. arc?: number;
  23421. sideOrientation?: number;
  23422. frontUVs?: Vector4;
  23423. backUVs?: Vector4;
  23424. }): VertexData;
  23425. /**
  23426. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23427. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23428. * @param polygon a mesh built from polygonTriangulation.build()
  23429. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23430. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23431. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23432. * @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)
  23433. * @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)
  23434. * @returns the VertexData of the Polygon
  23435. */
  23436. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23437. /**
  23438. * Creates the VertexData of the IcoSphere
  23439. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23440. * * radius the radius of the IcoSphere, optional default 1
  23441. * * radiusX allows stretching in the x direction, optional, default radius
  23442. * * radiusY allows stretching in the y direction, optional, default radius
  23443. * * radiusZ allows stretching in the z direction, optional, default radius
  23444. * * flat when true creates a flat shaded mesh, optional, default true
  23445. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23447. * * 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)
  23448. * * 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)
  23449. * @returns the VertexData of the IcoSphere
  23450. */
  23451. static CreateIcoSphere(options: {
  23452. radius?: number;
  23453. radiusX?: number;
  23454. radiusY?: number;
  23455. radiusZ?: number;
  23456. flat?: boolean;
  23457. subdivisions?: number;
  23458. sideOrientation?: number;
  23459. frontUVs?: Vector4;
  23460. backUVs?: Vector4;
  23461. }): VertexData;
  23462. /**
  23463. * Creates the VertexData for a Polyhedron
  23464. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23465. * * type provided types are:
  23466. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23467. * * 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)
  23468. * * size the size of the IcoSphere, optional default 1
  23469. * * sizeX allows stretching in the x direction, optional, default size
  23470. * * sizeY allows stretching in the y direction, optional, default size
  23471. * * sizeZ allows stretching in the z direction, optional, default size
  23472. * * 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
  23473. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23474. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23475. * * flat when true creates a flat shaded mesh, optional, default true
  23476. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23478. * * 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)
  23479. * * 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)
  23480. * @returns the VertexData of the Polyhedron
  23481. */
  23482. static CreatePolyhedron(options: {
  23483. type?: number;
  23484. size?: number;
  23485. sizeX?: number;
  23486. sizeY?: number;
  23487. sizeZ?: number;
  23488. custom?: any;
  23489. faceUV?: Vector4[];
  23490. faceColors?: Color4[];
  23491. flat?: boolean;
  23492. sideOrientation?: number;
  23493. frontUVs?: Vector4;
  23494. backUVs?: Vector4;
  23495. }): VertexData;
  23496. /**
  23497. * Creates the VertexData for a TorusKnot
  23498. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23499. * * radius the radius of the torus knot, optional, default 2
  23500. * * tube the thickness of the tube, optional, default 0.5
  23501. * * radialSegments the number of sides on each tube segments, optional, default 32
  23502. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23503. * * p the number of windings around the z axis, optional, default 2
  23504. * * q the number of windings around the x axis, optional, default 3
  23505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23506. * * 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)
  23507. * * 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)
  23508. * @returns the VertexData of the Torus Knot
  23509. */
  23510. static CreateTorusKnot(options: {
  23511. radius?: number;
  23512. tube?: number;
  23513. radialSegments?: number;
  23514. tubularSegments?: number;
  23515. p?: number;
  23516. q?: number;
  23517. sideOrientation?: number;
  23518. frontUVs?: Vector4;
  23519. backUVs?: Vector4;
  23520. }): VertexData;
  23521. /**
  23522. * Compute normals for given positions and indices
  23523. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23524. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23525. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23526. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23527. * * facetNormals : optional array of facet normals (vector3)
  23528. * * facetPositions : optional array of facet positions (vector3)
  23529. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23530. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23531. * * bInfo : optional bounding info, required for facetPartitioning computation
  23532. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23533. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23534. * * useRightHandedSystem: optional boolean to for right handed system computation
  23535. * * depthSort : optional boolean to enable the facet depth sort computation
  23536. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23537. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23538. */
  23539. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23540. facetNormals?: any;
  23541. facetPositions?: any;
  23542. facetPartitioning?: any;
  23543. ratio?: number;
  23544. bInfo?: any;
  23545. bbSize?: Vector3;
  23546. subDiv?: any;
  23547. useRightHandedSystem?: boolean;
  23548. depthSort?: boolean;
  23549. distanceTo?: Vector3;
  23550. depthSortedFacets?: any;
  23551. }): void;
  23552. private static _ComputeSides;
  23553. /**
  23554. * Applies VertexData created from the imported parameters to the geometry
  23555. * @param parsedVertexData the parsed data from an imported file
  23556. * @param geometry the geometry to apply the VertexData to
  23557. */
  23558. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23559. }
  23560. }
  23561. declare module "babylonjs/Meshes/polygonMesh" {
  23562. import { Scene } from "babylonjs/scene";
  23563. import { Vector2, Path2 } from "babylonjs/Maths/math";
  23564. import { Mesh } from "babylonjs/Meshes/mesh";
  23565. /**
  23566. * Polygon
  23567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23568. */
  23569. export class Polygon {
  23570. /**
  23571. * Creates a rectangle
  23572. * @param xmin bottom X coord
  23573. * @param ymin bottom Y coord
  23574. * @param xmax top X coord
  23575. * @param ymax top Y coord
  23576. * @returns points that make the resulting rectation
  23577. */
  23578. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23579. /**
  23580. * Creates a circle
  23581. * @param radius radius of circle
  23582. * @param cx scale in x
  23583. * @param cy scale in y
  23584. * @param numberOfSides number of sides that make up the circle
  23585. * @returns points that make the resulting circle
  23586. */
  23587. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23588. /**
  23589. * Creates a polygon from input string
  23590. * @param input Input polygon data
  23591. * @returns the parsed points
  23592. */
  23593. static Parse(input: string): Vector2[];
  23594. /**
  23595. * Starts building a polygon from x and y coordinates
  23596. * @param x x coordinate
  23597. * @param y y coordinate
  23598. * @returns the started path2
  23599. */
  23600. static StartingAt(x: number, y: number): Path2;
  23601. }
  23602. /**
  23603. * Builds a polygon
  23604. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23605. */
  23606. export class PolygonMeshBuilder {
  23607. private _points;
  23608. private _outlinepoints;
  23609. private _holes;
  23610. private _name;
  23611. private _scene;
  23612. private _epoints;
  23613. private _eholes;
  23614. private _addToepoint;
  23615. /**
  23616. * Babylon reference to the earcut plugin.
  23617. */
  23618. bjsEarcut: any;
  23619. /**
  23620. * Creates a PolygonMeshBuilder
  23621. * @param name name of the builder
  23622. * @param contours Path of the polygon
  23623. * @param scene scene to add to
  23624. */
  23625. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23626. /**
  23627. * Adds a whole within the polygon
  23628. * @param hole Array of points defining the hole
  23629. * @returns this
  23630. */
  23631. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23632. /**
  23633. * Creates the polygon
  23634. * @param updatable If the mesh should be updatable
  23635. * @param depth The depth of the mesh created
  23636. * @returns the created mesh
  23637. */
  23638. build(updatable?: boolean, depth?: number): Mesh;
  23639. /**
  23640. * Adds a side to the polygon
  23641. * @param positions points that make the polygon
  23642. * @param normals normals of the polygon
  23643. * @param uvs uvs of the polygon
  23644. * @param indices indices of the polygon
  23645. * @param bounds bounds of the polygon
  23646. * @param points points of the polygon
  23647. * @param depth depth of the polygon
  23648. * @param flip flip of the polygon
  23649. */
  23650. private addSide;
  23651. }
  23652. }
  23653. declare module "babylonjs/Meshes/meshBuilder" {
  23654. import { Nullable } from "babylonjs/types";
  23655. import { Scene } from "babylonjs/scene";
  23656. import { Vector3, Vector2, Color3, Color4, Plane, Vector4 } from "babylonjs/Maths/math";
  23657. import { Mesh } from "babylonjs/Meshes/mesh";
  23658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23659. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23660. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23661. /**
  23662. * Class containing static functions to help procedurally build meshes
  23663. */
  23664. export class MeshBuilder {
  23665. private static _UpdateSideOrientation;
  23666. /**
  23667. * Creates a box mesh
  23668. * * The parameter `size` sets the size (float) of each box side (default 1)
  23669. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23670. * * 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)
  23671. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23675. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23676. * @param name defines the name of the mesh
  23677. * @param options defines the options used to create the mesh
  23678. * @param scene defines the hosting scene
  23679. * @returns the box mesh
  23680. */
  23681. static CreateBox(name: string, options: {
  23682. size?: number;
  23683. width?: number;
  23684. height?: number;
  23685. depth?: number;
  23686. faceUV?: Vector4[];
  23687. faceColors?: Color4[];
  23688. sideOrientation?: number;
  23689. frontUVs?: Vector4;
  23690. backUVs?: Vector4;
  23691. updatable?: boolean;
  23692. }, scene?: Nullable<Scene>): Mesh;
  23693. /**
  23694. * Creates a sphere mesh
  23695. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23696. * * 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`)
  23697. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23698. * * 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
  23699. * * 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)
  23700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23703. * @param name defines the name of the mesh
  23704. * @param options defines the options used to create the mesh
  23705. * @param scene defines the hosting scene
  23706. * @returns the sphere mesh
  23707. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23708. */
  23709. static CreateSphere(name: string, options: {
  23710. segments?: number;
  23711. diameter?: number;
  23712. diameterX?: number;
  23713. diameterY?: number;
  23714. diameterZ?: number;
  23715. arc?: number;
  23716. slice?: number;
  23717. sideOrientation?: number;
  23718. frontUVs?: Vector4;
  23719. backUVs?: Vector4;
  23720. updatable?: boolean;
  23721. }, scene: any): Mesh;
  23722. /**
  23723. * Creates a plane polygonal mesh. By default, this is a disc
  23724. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23725. * * 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
  23726. * * 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
  23727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23730. * @param name defines the name of the mesh
  23731. * @param options defines the options used to create the mesh
  23732. * @param scene defines the hosting scene
  23733. * @returns the plane polygonal mesh
  23734. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23735. */
  23736. static CreateDisc(name: string, options: {
  23737. radius?: number;
  23738. tessellation?: number;
  23739. arc?: number;
  23740. updatable?: boolean;
  23741. sideOrientation?: number;
  23742. frontUVs?: Vector4;
  23743. backUVs?: Vector4;
  23744. }, scene?: Nullable<Scene>): Mesh;
  23745. /**
  23746. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23747. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23748. * * 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`)
  23749. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23750. * * 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
  23751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23754. * @param name defines the name of the mesh
  23755. * @param options defines the options used to create the mesh
  23756. * @param scene defines the hosting scene
  23757. * @returns the icosahedron mesh
  23758. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23759. */
  23760. static CreateIcoSphere(name: string, options: {
  23761. radius?: number;
  23762. radiusX?: number;
  23763. radiusY?: number;
  23764. radiusZ?: number;
  23765. flat?: boolean;
  23766. subdivisions?: number;
  23767. sideOrientation?: number;
  23768. frontUVs?: Vector4;
  23769. backUVs?: Vector4;
  23770. updatable?: boolean;
  23771. }, scene: Scene): Mesh;
  23772. /**
  23773. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23774. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23775. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23776. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23777. * * 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
  23778. * * 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
  23779. * * 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
  23780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23783. * * 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
  23784. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23785. * * 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
  23786. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23788. * @param name defines the name of the mesh
  23789. * @param options defines the options used to create the mesh
  23790. * @param scene defines the hosting scene
  23791. * @returns the ribbon mesh
  23792. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23794. */
  23795. static CreateRibbon(name: string, options: {
  23796. pathArray: Vector3[][];
  23797. closeArray?: boolean;
  23798. closePath?: boolean;
  23799. offset?: number;
  23800. updatable?: boolean;
  23801. sideOrientation?: number;
  23802. frontUVs?: Vector4;
  23803. backUVs?: Vector4;
  23804. instance?: Mesh;
  23805. invertUV?: boolean;
  23806. uvs?: Vector2[];
  23807. colors?: Color4[];
  23808. }, scene?: Nullable<Scene>): Mesh;
  23809. /**
  23810. * Creates a cylinder or a cone mesh
  23811. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23812. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23813. * * 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.
  23814. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23815. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23816. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23817. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23818. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23819. * * 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).
  23820. * * 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
  23821. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23822. * * 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
  23823. * * 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.
  23824. * * If `enclose` is false, a ring surface is one element.
  23825. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23826. * * 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
  23827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23830. * @param name defines the name of the mesh
  23831. * @param options defines the options used to create the mesh
  23832. * @param scene defines the hosting scene
  23833. * @returns the cylinder mesh
  23834. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23835. */
  23836. static CreateCylinder(name: string, options: {
  23837. height?: number;
  23838. diameterTop?: number;
  23839. diameterBottom?: number;
  23840. diameter?: number;
  23841. tessellation?: number;
  23842. subdivisions?: number;
  23843. arc?: number;
  23844. faceColors?: Color4[];
  23845. faceUV?: Vector4[];
  23846. updatable?: boolean;
  23847. hasRings?: boolean;
  23848. enclose?: boolean;
  23849. sideOrientation?: number;
  23850. frontUVs?: Vector4;
  23851. backUVs?: Vector4;
  23852. }, scene: any): Mesh;
  23853. /**
  23854. * Creates a torus mesh
  23855. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23856. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23857. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23861. * @param name defines the name of the mesh
  23862. * @param options defines the options used to create the mesh
  23863. * @param scene defines the hosting scene
  23864. * @returns the torus mesh
  23865. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  23866. */
  23867. static CreateTorus(name: string, options: {
  23868. diameter?: number;
  23869. thickness?: number;
  23870. tessellation?: number;
  23871. updatable?: boolean;
  23872. sideOrientation?: number;
  23873. frontUVs?: Vector4;
  23874. backUVs?: Vector4;
  23875. }, scene: any): Mesh;
  23876. /**
  23877. * Creates a torus knot mesh
  23878. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23879. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23880. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23881. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23885. * @param name defines the name of the mesh
  23886. * @param options defines the options used to create the mesh
  23887. * @param scene defines the hosting scene
  23888. * @returns the torus knot mesh
  23889. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23890. */
  23891. static CreateTorusKnot(name: string, options: {
  23892. radius?: number;
  23893. tube?: number;
  23894. radialSegments?: number;
  23895. tubularSegments?: number;
  23896. p?: number;
  23897. q?: number;
  23898. updatable?: boolean;
  23899. sideOrientation?: number;
  23900. frontUVs?: Vector4;
  23901. backUVs?: Vector4;
  23902. }, scene: any): Mesh;
  23903. /**
  23904. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23905. * * 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
  23906. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23907. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23908. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23909. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23910. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23911. * * 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
  23912. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23915. * @param name defines the name of the new line system
  23916. * @param options defines the options used to create the line system
  23917. * @param scene defines the hosting scene
  23918. * @returns a new line system mesh
  23919. */
  23920. static CreateLineSystem(name: string, options: {
  23921. lines: Vector3[][];
  23922. updatable?: boolean;
  23923. instance?: Nullable<LinesMesh>;
  23924. colors?: Nullable<Color4[][]>;
  23925. useVertexAlpha?: boolean;
  23926. }, scene: Nullable<Scene>): LinesMesh;
  23927. /**
  23928. * Creates a line mesh
  23929. * 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
  23930. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23931. * * The parameter `points` is an array successive Vector3
  23932. * * 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
  23933. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23934. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23935. * * When updating an instance, remember that only point positions can change, not the number of points
  23936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  23938. * @param name defines the name of the new line system
  23939. * @param options defines the options used to create the line system
  23940. * @param scene defines the hosting scene
  23941. * @returns a new line mesh
  23942. */
  23943. static CreateLines(name: string, options: {
  23944. points: Vector3[];
  23945. updatable?: boolean;
  23946. instance?: Nullable<LinesMesh>;
  23947. colors?: Color4[];
  23948. useVertexAlpha?: boolean;
  23949. }, scene?: Nullable<Scene>): LinesMesh;
  23950. /**
  23951. * Creates a dashed line mesh
  23952. * * 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
  23953. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23954. * * The parameter `points` is an array successive Vector3
  23955. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23956. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23957. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23958. * * 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
  23959. * * When updating an instance, remember that only point positions can change, not the number of points
  23960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23961. * @param name defines the name of the mesh
  23962. * @param options defines the options used to create the mesh
  23963. * @param scene defines the hosting scene
  23964. * @returns the dashed line mesh
  23965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23966. */
  23967. static CreateDashedLines(name: string, options: {
  23968. points: Vector3[];
  23969. dashSize?: number;
  23970. gapSize?: number;
  23971. dashNb?: number;
  23972. updatable?: boolean;
  23973. instance?: LinesMesh;
  23974. }, scene?: Nullable<Scene>): LinesMesh;
  23975. /**
  23976. * 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.
  23977. * * 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.
  23978. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23979. * * 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.
  23980. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23981. * * 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
  23982. * * 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
  23983. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23988. * @param name defines the name of the mesh
  23989. * @param options defines the options used to create the mesh
  23990. * @param scene defines the hosting scene
  23991. * @returns the extruded shape mesh
  23992. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23994. */
  23995. static ExtrudeShape(name: string, options: {
  23996. shape: Vector3[];
  23997. path: Vector3[];
  23998. scale?: number;
  23999. rotation?: number;
  24000. cap?: number;
  24001. updatable?: boolean;
  24002. sideOrientation?: number;
  24003. frontUVs?: Vector4;
  24004. backUVs?: Vector4;
  24005. instance?: Mesh;
  24006. invertUV?: boolean;
  24007. }, scene?: Nullable<Scene>): Mesh;
  24008. /**
  24009. * Creates an custom extruded shape mesh.
  24010. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  24011. * * 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.
  24012. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  24013. * * 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
  24014. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  24015. * * 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
  24016. * * It must returns a float value that will be the scale value applied to the shape on each path point
  24017. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24018. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  24019. * * 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
  24020. * * 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
  24021. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  24022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24026. * @param name defines the name of the mesh
  24027. * @param options defines the options used to create the mesh
  24028. * @param scene defines the hosting scene
  24029. * @returns the custom extruded shape mesh
  24030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  24031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24033. */
  24034. static ExtrudeShapeCustom(name: string, options: {
  24035. shape: Vector3[];
  24036. path: Vector3[];
  24037. scaleFunction?: any;
  24038. rotationFunction?: any;
  24039. ribbonCloseArray?: boolean;
  24040. ribbonClosePath?: boolean;
  24041. cap?: number;
  24042. updatable?: boolean;
  24043. sideOrientation?: number;
  24044. frontUVs?: Vector4;
  24045. backUVs?: Vector4;
  24046. instance?: Mesh;
  24047. invertUV?: boolean;
  24048. }, scene: Scene): Mesh;
  24049. /**
  24050. * Creates lathe mesh.
  24051. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  24052. * * 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
  24053. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  24054. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  24055. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  24056. * * 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
  24057. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  24058. * * 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
  24059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24063. * @param name defines the name of the mesh
  24064. * @param options defines the options used to create the mesh
  24065. * @param scene defines the hosting scene
  24066. * @returns the lathe mesh
  24067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  24068. */
  24069. static CreateLathe(name: string, options: {
  24070. shape: Vector3[];
  24071. radius?: number;
  24072. tessellation?: number;
  24073. clip?: number;
  24074. arc?: number;
  24075. closed?: boolean;
  24076. updatable?: boolean;
  24077. sideOrientation?: number;
  24078. frontUVs?: Vector4;
  24079. backUVs?: Vector4;
  24080. cap?: number;
  24081. invertUV?: boolean;
  24082. }, scene: Scene): Mesh;
  24083. /**
  24084. * Creates a plane mesh
  24085. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  24086. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  24087. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  24088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24091. * @param name defines the name of the mesh
  24092. * @param options defines the options used to create the mesh
  24093. * @param scene defines the hosting scene
  24094. * @returns the plane mesh
  24095. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  24096. */
  24097. static CreatePlane(name: string, options: {
  24098. size?: number;
  24099. width?: number;
  24100. height?: number;
  24101. sideOrientation?: number;
  24102. frontUVs?: Vector4;
  24103. backUVs?: Vector4;
  24104. updatable?: boolean;
  24105. sourcePlane?: Plane;
  24106. }, scene: Scene): Mesh;
  24107. /**
  24108. * Creates a ground mesh
  24109. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  24110. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  24111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24112. * @param name defines the name of the mesh
  24113. * @param options defines the options used to create the mesh
  24114. * @param scene defines the hosting scene
  24115. * @returns the ground mesh
  24116. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  24117. */
  24118. static CreateGround(name: string, options: {
  24119. width?: number;
  24120. height?: number;
  24121. subdivisions?: number;
  24122. subdivisionsX?: number;
  24123. subdivisionsY?: number;
  24124. updatable?: boolean;
  24125. }, scene: any): Mesh;
  24126. /**
  24127. * Creates a tiled ground mesh
  24128. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  24129. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  24130. * * 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
  24131. * * 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
  24132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24133. * @param name defines the name of the mesh
  24134. * @param options defines the options used to create the mesh
  24135. * @param scene defines the hosting scene
  24136. * @returns the tiled ground mesh
  24137. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24138. */
  24139. static CreateTiledGround(name: string, options: {
  24140. xmin: number;
  24141. zmin: number;
  24142. xmax: number;
  24143. zmax: number;
  24144. subdivisions?: {
  24145. w: number;
  24146. h: number;
  24147. };
  24148. precision?: {
  24149. w: number;
  24150. h: number;
  24151. };
  24152. updatable?: boolean;
  24153. }, scene: Scene): Mesh;
  24154. /**
  24155. * Creates a ground mesh from a height map
  24156. * * The parameter `url` sets the URL of the height map image resource.
  24157. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  24158. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  24159. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  24160. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  24161. * * 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.
  24162. * * 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).
  24163. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24165. * @param name defines the name of the mesh
  24166. * @param url defines the url to the height map
  24167. * @param options defines the options used to create the mesh
  24168. * @param scene defines the hosting scene
  24169. * @returns the ground mesh
  24170. * @see https://doc.babylonjs.com/babylon101/height_map
  24171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  24172. */
  24173. static CreateGroundFromHeightMap(name: string, url: string, options: {
  24174. width?: number;
  24175. height?: number;
  24176. subdivisions?: number;
  24177. minHeight?: number;
  24178. maxHeight?: number;
  24179. colorFilter?: Color3;
  24180. alphaFilter?: number;
  24181. updatable?: boolean;
  24182. onReady?: (mesh: GroundMesh) => void;
  24183. }, scene: Scene): GroundMesh;
  24184. /**
  24185. * Creates a polygon mesh
  24186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  24187. * * 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
  24188. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  24191. * * Remember you can only change the shape positions, not their number when updating a polygon
  24192. * @param name defines the name of the mesh
  24193. * @param options defines the options used to create the mesh
  24194. * @param scene defines the hosting scene
  24195. * @returns the polygon mesh
  24196. */
  24197. static CreatePolygon(name: string, options: {
  24198. shape: Vector3[];
  24199. holes?: Vector3[][];
  24200. depth?: number;
  24201. faceUV?: Vector4[];
  24202. faceColors?: Color4[];
  24203. updatable?: boolean;
  24204. sideOrientation?: number;
  24205. frontUVs?: Vector4;
  24206. backUVs?: Vector4;
  24207. }, scene: Scene): Mesh;
  24208. /**
  24209. * Creates an extruded polygon mesh, with depth in the Y direction.
  24210. * * 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)
  24211. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24212. * @param name defines the name of the mesh
  24213. * @param options defines the options used to create the mesh
  24214. * @param scene defines the hosting scene
  24215. * @returns the polygon mesh
  24216. */
  24217. static ExtrudePolygon(name: string, options: {
  24218. shape: Vector3[];
  24219. holes?: Vector3[][];
  24220. depth?: number;
  24221. faceUV?: Vector4[];
  24222. faceColors?: Color4[];
  24223. updatable?: boolean;
  24224. sideOrientation?: number;
  24225. frontUVs?: Vector4;
  24226. backUVs?: Vector4;
  24227. }, scene: Scene): Mesh;
  24228. /**
  24229. * Creates a tube mesh.
  24230. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  24231. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  24232. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  24233. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  24234. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  24235. * * 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)
  24236. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  24237. * * 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
  24238. * * 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
  24239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  24242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24243. * @param name defines the name of the mesh
  24244. * @param options defines the options used to create the mesh
  24245. * @param scene defines the hosting scene
  24246. * @returns the tube mesh
  24247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  24248. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  24249. */
  24250. static CreateTube(name: string, options: {
  24251. path: Vector3[];
  24252. radius?: number;
  24253. tessellation?: number;
  24254. radiusFunction?: {
  24255. (i: number, distance: number): number;
  24256. };
  24257. cap?: number;
  24258. arc?: number;
  24259. updatable?: boolean;
  24260. sideOrientation?: number;
  24261. frontUVs?: Vector4;
  24262. backUVs?: Vector4;
  24263. instance?: Mesh;
  24264. invertUV?: boolean;
  24265. }, scene: Scene): Mesh;
  24266. /**
  24267. * Creates a polyhedron mesh
  24268. * * 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
  24269. * * The parameter `size` (positive float, default 1) sets the polygon size
  24270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24271. * * 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`
  24272. * * 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
  24273. * * 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)`)
  24274. * * 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
  24275. * * 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
  24276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24279. * @param name defines the name of the mesh
  24280. * @param options defines the options used to create the mesh
  24281. * @param scene defines the hosting scene
  24282. * @returns the polyhedron mesh
  24283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  24284. */
  24285. static CreatePolyhedron(name: string, options: {
  24286. type?: number;
  24287. size?: number;
  24288. sizeX?: number;
  24289. sizeY?: number;
  24290. sizeZ?: number;
  24291. custom?: any;
  24292. faceUV?: Vector4[];
  24293. faceColors?: Color4[];
  24294. flat?: boolean;
  24295. updatable?: boolean;
  24296. sideOrientation?: number;
  24297. frontUVs?: Vector4;
  24298. backUVs?: Vector4;
  24299. }, scene: Scene): Mesh;
  24300. /**
  24301. * Creates a decal mesh.
  24302. * 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
  24303. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  24304. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  24305. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  24306. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  24307. * @param name defines the name of the mesh
  24308. * @param sourceMesh defines the mesh where the decal must be applied
  24309. * @param options defines the options used to create the mesh
  24310. * @param scene defines the hosting scene
  24311. * @returns the decal mesh
  24312. * @see https://doc.babylonjs.com/how_to/decals
  24313. */
  24314. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  24315. position?: Vector3;
  24316. normal?: Vector3;
  24317. size?: Vector3;
  24318. angle?: number;
  24319. }): Mesh;
  24320. private static _ExtrudeShapeGeneric;
  24321. }
  24322. }
  24323. declare module "babylonjs/Particles/solidParticleSystem" {
  24324. import { Vector3 } from "babylonjs/Maths/math";
  24325. import { Mesh } from "babylonjs/Meshes/mesh";
  24326. import { Scene, IDisposable } from "babylonjs/scene";
  24327. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24328. /**
  24329. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24330. *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.
  24331. * The SPS is also a particle system. It provides some methods to manage the particles.
  24332. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24333. *
  24334. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24335. */
  24336. export class SolidParticleSystem implements IDisposable {
  24337. /**
  24338. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24339. * Example : var p = SPS.particles[i];
  24340. */
  24341. particles: SolidParticle[];
  24342. /**
  24343. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24344. */
  24345. nbParticles: number;
  24346. /**
  24347. * If the particles must ever face the camera (default false). Useful for planar particles.
  24348. */
  24349. billboard: boolean;
  24350. /**
  24351. * Recompute normals when adding a shape
  24352. */
  24353. recomputeNormals: boolean;
  24354. /**
  24355. * This a counter ofr your own usage. It's not set by any SPS functions.
  24356. */
  24357. counter: number;
  24358. /**
  24359. * The SPS name. This name is also given to the underlying mesh.
  24360. */
  24361. name: string;
  24362. /**
  24363. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24364. */
  24365. mesh: Mesh;
  24366. /**
  24367. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24368. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24369. */
  24370. vars: any;
  24371. /**
  24372. * This array is populated when the SPS is set as 'pickable'.
  24373. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24374. * Each element of this array is an object `{idx: int, faceId: int}`.
  24375. * `idx` is the picked particle index in the `SPS.particles` array
  24376. * `faceId` is the picked face index counted within this particle.
  24377. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24378. */
  24379. pickedParticles: {
  24380. idx: number;
  24381. faceId: number;
  24382. }[];
  24383. /**
  24384. * This array is populated when `enableDepthSort` is set to true.
  24385. * Each element of this array is an instance of the class DepthSortedParticle.
  24386. */
  24387. depthSortedParticles: DepthSortedParticle[];
  24388. /**
  24389. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24390. * @hidden
  24391. */
  24392. _bSphereOnly: boolean;
  24393. /**
  24394. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24395. * @hidden
  24396. */
  24397. _bSphereRadiusFactor: number;
  24398. private _scene;
  24399. private _positions;
  24400. private _indices;
  24401. private _normals;
  24402. private _colors;
  24403. private _uvs;
  24404. private _indices32;
  24405. private _positions32;
  24406. private _normals32;
  24407. private _fixedNormal32;
  24408. private _colors32;
  24409. private _uvs32;
  24410. private _index;
  24411. private _updatable;
  24412. private _pickable;
  24413. private _isVisibilityBoxLocked;
  24414. private _alwaysVisible;
  24415. private _depthSort;
  24416. private _shapeCounter;
  24417. private _copy;
  24418. private _color;
  24419. private _computeParticleColor;
  24420. private _computeParticleTexture;
  24421. private _computeParticleRotation;
  24422. private _computeParticleVertex;
  24423. private _computeBoundingBox;
  24424. private _depthSortParticles;
  24425. private _camera;
  24426. private _mustUnrotateFixedNormals;
  24427. private _particlesIntersect;
  24428. private _needs32Bits;
  24429. /**
  24430. * Creates a SPS (Solid Particle System) object.
  24431. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24432. * @param scene (Scene) is the scene in which the SPS is added.
  24433. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24434. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24435. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24436. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24437. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24438. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24439. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24440. */
  24441. constructor(name: string, scene: Scene, options?: {
  24442. updatable?: boolean;
  24443. isPickable?: boolean;
  24444. enableDepthSort?: boolean;
  24445. particleIntersection?: boolean;
  24446. boundingSphereOnly?: boolean;
  24447. bSphereRadiusFactor?: number;
  24448. });
  24449. /**
  24450. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24451. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24452. * @returns the created mesh
  24453. */
  24454. buildMesh(): Mesh;
  24455. /**
  24456. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24457. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24458. * Thus the particles generated from `digest()` have their property `position` set yet.
  24459. * @param mesh ( Mesh ) is the mesh to be digested
  24460. * @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
  24461. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24462. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24463. * @returns the current SPS
  24464. */
  24465. digest(mesh: Mesh, options?: {
  24466. facetNb?: number;
  24467. number?: number;
  24468. delta?: number;
  24469. }): SolidParticleSystem;
  24470. private _unrotateFixedNormals;
  24471. private _resetCopy;
  24472. private _meshBuilder;
  24473. private _posToShape;
  24474. private _uvsToShapeUV;
  24475. private _addParticle;
  24476. /**
  24477. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24478. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24479. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24480. * @param nb (positive integer) the number of particles to be created from this model
  24481. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24482. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24483. * @returns the number of shapes in the system
  24484. */
  24485. addShape(mesh: Mesh, nb: number, options?: {
  24486. positionFunction?: any;
  24487. vertexFunction?: any;
  24488. }): number;
  24489. private _rebuildParticle;
  24490. /**
  24491. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24492. * @returns the SPS.
  24493. */
  24494. rebuildMesh(): SolidParticleSystem;
  24495. /**
  24496. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24497. * This method calls `updateParticle()` for each particle of the SPS.
  24498. * For an animated SPS, it is usually called within the render loop.
  24499. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24500. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24501. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24502. * @returns the SPS.
  24503. */
  24504. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24505. /**
  24506. * Disposes the SPS.
  24507. */
  24508. dispose(): void;
  24509. /**
  24510. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24511. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24512. * @returns the SPS.
  24513. */
  24514. refreshVisibleSize(): SolidParticleSystem;
  24515. /**
  24516. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24517. * @param size the size (float) of the visibility box
  24518. * note : this doesn't lock the SPS mesh bounding box.
  24519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24520. */
  24521. setVisibilityBox(size: number): void;
  24522. /**
  24523. * Gets whether the SPS as always visible or not
  24524. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24525. */
  24526. /**
  24527. * Sets the SPS as always visible or not
  24528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24529. */
  24530. isAlwaysVisible: boolean;
  24531. /**
  24532. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24533. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24534. */
  24535. /**
  24536. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24537. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24538. */
  24539. isVisibilityBoxLocked: boolean;
  24540. /**
  24541. * Tells to `setParticles()` to compute the particle rotations or not.
  24542. * Default value : true. The SPS is faster when it's set to false.
  24543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24544. */
  24545. /**
  24546. * Gets if `setParticles()` computes the particle rotations or not.
  24547. * Default value : true. The SPS is faster when it's set to false.
  24548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24549. */
  24550. computeParticleRotation: boolean;
  24551. /**
  24552. * Tells to `setParticles()` to compute the particle colors or not.
  24553. * Default value : true. The SPS is faster when it's set to false.
  24554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24555. */
  24556. /**
  24557. * Gets if `setParticles()` computes the particle colors or not.
  24558. * Default value : true. The SPS is faster when it's set to false.
  24559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24560. */
  24561. computeParticleColor: boolean;
  24562. /**
  24563. * Gets if `setParticles()` computes the particle textures or not.
  24564. * Default value : true. The SPS is faster when it's set to false.
  24565. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24566. */
  24567. computeParticleTexture: boolean;
  24568. /**
  24569. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24570. * Default value : false. The SPS is faster when it's set to false.
  24571. * Note : the particle custom vertex positions aren't stored values.
  24572. */
  24573. /**
  24574. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24575. * Default value : false. The SPS is faster when it's set to false.
  24576. * Note : the particle custom vertex positions aren't stored values.
  24577. */
  24578. computeParticleVertex: boolean;
  24579. /**
  24580. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24581. */
  24582. /**
  24583. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24584. */
  24585. computeBoundingBox: boolean;
  24586. /**
  24587. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24588. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24589. * Default : `true`
  24590. */
  24591. /**
  24592. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24593. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24594. * Default : `true`
  24595. */
  24596. depthSortParticles: boolean;
  24597. /**
  24598. * This function does nothing. It may be overwritten to set all the particle first values.
  24599. * The SPS doesn't call this function, you may have to call it by your own.
  24600. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24601. */
  24602. initParticles(): void;
  24603. /**
  24604. * This function does nothing. It may be overwritten to recycle a particle.
  24605. * The SPS doesn't call this function, you may have to call it by your own.
  24606. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24607. * @param particle The particle to recycle
  24608. * @returns the recycled particle
  24609. */
  24610. recycleParticle(particle: SolidParticle): SolidParticle;
  24611. /**
  24612. * Updates a particle : this function should be overwritten by the user.
  24613. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24614. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24615. * @example : just set a particle position or velocity and recycle conditions
  24616. * @param particle The particle to update
  24617. * @returns the updated particle
  24618. */
  24619. updateParticle(particle: SolidParticle): SolidParticle;
  24620. /**
  24621. * Updates a vertex of a particle : it can be overwritten by the user.
  24622. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24623. * @param particle the current particle
  24624. * @param vertex the current index of the current particle
  24625. * @param pt the index of the current vertex in the particle shape
  24626. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24627. * @example : just set a vertex particle position
  24628. * @returns the updated vertex
  24629. */
  24630. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24631. /**
  24632. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24633. * This does nothing and may be overwritten by the user.
  24634. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24635. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24636. * @param update the boolean update value actually passed to setParticles()
  24637. */
  24638. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24639. /**
  24640. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24641. * This will be passed three parameters.
  24642. * This does nothing and may be overwritten by the user.
  24643. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24644. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24645. * @param update the boolean update value actually passed to setParticles()
  24646. */
  24647. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24648. }
  24649. }
  24650. declare module "babylonjs/Particles/solidParticle" {
  24651. import { Nullable } from "babylonjs/types";
  24652. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24653. import { Mesh } from "babylonjs/Meshes/mesh";
  24654. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24655. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24656. /**
  24657. * Represents one particle of a solid particle system.
  24658. */
  24659. export class SolidParticle {
  24660. /**
  24661. * particle global index
  24662. */
  24663. idx: number;
  24664. /**
  24665. * The color of the particle
  24666. */
  24667. color: Nullable<Color4>;
  24668. /**
  24669. * The world space position of the particle.
  24670. */
  24671. position: Vector3;
  24672. /**
  24673. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24674. */
  24675. rotation: Vector3;
  24676. /**
  24677. * The world space rotation quaternion of the particle.
  24678. */
  24679. rotationQuaternion: Nullable<Quaternion>;
  24680. /**
  24681. * The scaling of the particle.
  24682. */
  24683. scaling: Vector3;
  24684. /**
  24685. * The uvs of the particle.
  24686. */
  24687. uvs: Vector4;
  24688. /**
  24689. * The current speed of the particle.
  24690. */
  24691. velocity: Vector3;
  24692. /**
  24693. * The pivot point in the particle local space.
  24694. */
  24695. pivot: Vector3;
  24696. /**
  24697. * Must the particle be translated from its pivot point in its local space ?
  24698. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24699. * Default : false
  24700. */
  24701. translateFromPivot: boolean;
  24702. /**
  24703. * Is the particle active or not ?
  24704. */
  24705. alive: boolean;
  24706. /**
  24707. * Is the particle visible or not ?
  24708. */
  24709. isVisible: boolean;
  24710. /**
  24711. * Index of this particle in the global "positions" array (Internal use)
  24712. * @hidden
  24713. */
  24714. _pos: number;
  24715. /**
  24716. * @hidden Index of this particle in the global "indices" array (Internal use)
  24717. */
  24718. _ind: number;
  24719. /**
  24720. * @hidden ModelShape of this particle (Internal use)
  24721. */
  24722. _model: ModelShape;
  24723. /**
  24724. * ModelShape id of this particle
  24725. */
  24726. shapeId: number;
  24727. /**
  24728. * Index of the particle in its shape id (Internal use)
  24729. */
  24730. idxInShape: number;
  24731. /**
  24732. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24733. */
  24734. _modelBoundingInfo: BoundingInfo;
  24735. /**
  24736. * @hidden Particle BoundingInfo object (Internal use)
  24737. */
  24738. _boundingInfo: BoundingInfo;
  24739. /**
  24740. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24741. */
  24742. _sps: SolidParticleSystem;
  24743. /**
  24744. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24745. */
  24746. _stillInvisible: boolean;
  24747. /**
  24748. * @hidden Last computed particle rotation matrix
  24749. */
  24750. _rotationMatrix: number[];
  24751. /**
  24752. * Parent particle Id, if any.
  24753. * Default null.
  24754. */
  24755. parentId: Nullable<number>;
  24756. /**
  24757. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24758. * The possible values are :
  24759. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24760. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24761. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24762. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24763. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24764. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24765. * */
  24766. cullingStrategy: number;
  24767. /**
  24768. * @hidden Internal global position in the SPS.
  24769. */
  24770. _globalPosition: Vector3;
  24771. /**
  24772. * Creates a Solid Particle object.
  24773. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24774. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24775. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24776. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24777. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24778. * @param shapeId (integer) is the model shape identifier in the SPS.
  24779. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24780. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24781. */
  24782. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24783. /**
  24784. * Legacy support, changed scale to scaling
  24785. */
  24786. /**
  24787. * Legacy support, changed scale to scaling
  24788. */
  24789. scale: Vector3;
  24790. /**
  24791. * Legacy support, changed quaternion to rotationQuaternion
  24792. */
  24793. /**
  24794. * Legacy support, changed quaternion to rotationQuaternion
  24795. */
  24796. quaternion: Nullable<Quaternion>;
  24797. /**
  24798. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24799. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24800. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24801. * @returns true if it intersects
  24802. */
  24803. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24804. /**
  24805. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24806. * A particle is in the frustum if its bounding box intersects the frustum
  24807. * @param frustumPlanes defines the frustum to test
  24808. * @returns true if the particle is in the frustum planes
  24809. */
  24810. isInFrustum(frustumPlanes: Plane[]): boolean;
  24811. /**
  24812. * get the rotation matrix of the particle
  24813. * @hidden
  24814. */
  24815. getRotationMatrix(m: Matrix): void;
  24816. }
  24817. /**
  24818. * Represents the shape of the model used by one particle of a solid particle system.
  24819. * SPS internal tool, don't use it manually.
  24820. */
  24821. export class ModelShape {
  24822. /**
  24823. * The shape id
  24824. * @hidden
  24825. */
  24826. shapeID: number;
  24827. /**
  24828. * flat array of model positions (internal use)
  24829. * @hidden
  24830. */
  24831. _shape: Vector3[];
  24832. /**
  24833. * flat array of model UVs (internal use)
  24834. * @hidden
  24835. */
  24836. _shapeUV: number[];
  24837. /**
  24838. * length of the shape in the model indices array (internal use)
  24839. * @hidden
  24840. */
  24841. _indicesLength: number;
  24842. /**
  24843. * Custom position function (internal use)
  24844. * @hidden
  24845. */
  24846. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24847. /**
  24848. * Custom vertex function (internal use)
  24849. * @hidden
  24850. */
  24851. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24852. /**
  24853. * 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.
  24854. * SPS internal tool, don't use it manually.
  24855. * @hidden
  24856. */
  24857. 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>);
  24858. }
  24859. /**
  24860. * Represents a Depth Sorted Particle in the solid particle system.
  24861. */
  24862. export class DepthSortedParticle {
  24863. /**
  24864. * Index of the particle in the "indices" array
  24865. */
  24866. ind: number;
  24867. /**
  24868. * Length of the particle shape in the "indices" array
  24869. */
  24870. indicesLength: number;
  24871. /**
  24872. * Squared distance from the particle to the camera
  24873. */
  24874. sqDistance: number;
  24875. }
  24876. }
  24877. declare module "babylonjs/Meshes/abstractMesh" {
  24878. import { Observable } from "babylonjs/Misc/observable";
  24879. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24880. import { Camera } from "babylonjs/Cameras/camera";
  24881. import { Scene, IDisposable } from "babylonjs/scene";
  24882. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24883. import { Node } from "babylonjs/node";
  24884. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24887. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24888. import { Collider } from "babylonjs/Collisions/collider";
  24889. import { Ray } from "babylonjs/Culling/ray";
  24890. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24891. import { Material } from "babylonjs/Materials/material";
  24892. import { Light } from "babylonjs/Lights/light";
  24893. import { ActionManager } from "babylonjs/Actions/actionManager";
  24894. import { Skeleton } from "babylonjs/Bones/skeleton";
  24895. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24896. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24897. /**
  24898. * Class used to store all common mesh properties
  24899. */
  24900. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24901. /** No occlusion */
  24902. static OCCLUSION_TYPE_NONE: number;
  24903. /** Occlusion set to optimisitic */
  24904. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24905. /** Occlusion set to strict */
  24906. static OCCLUSION_TYPE_STRICT: number;
  24907. /** Use an accurante occlusion algorithm */
  24908. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24909. /** Use a conservative occlusion algorithm */
  24910. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24911. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24912. * Test order :
  24913. * Is the bounding sphere outside the frustum ?
  24914. * If not, are the bounding box vertices outside the frustum ?
  24915. * It not, then the cullable object is in the frustum.
  24916. */
  24917. static readonly CULLINGSTRATEGY_STANDARD: number;
  24918. /** Culling strategy : Bounding Sphere Only.
  24919. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24920. * It's also less accurate than the standard because some not visible objects can still be selected.
  24921. * Test : is the bounding sphere outside the frustum ?
  24922. * If not, then the cullable object is in the frustum.
  24923. */
  24924. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24925. /** Culling strategy : Optimistic Inclusion.
  24926. * This in an inclusion test first, then the standard exclusion test.
  24927. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24928. * 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.
  24929. * Anyway, it's as accurate as the standard strategy.
  24930. * Test :
  24931. * Is the cullable object bounding sphere center in the frustum ?
  24932. * If not, apply the default culling strategy.
  24933. */
  24934. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24935. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24936. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24937. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24938. * 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.
  24939. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24940. * Test :
  24941. * Is the cullable object bounding sphere center in the frustum ?
  24942. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24943. */
  24944. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24945. /**
  24946. * No billboard
  24947. */
  24948. static readonly BILLBOARDMODE_NONE: number;
  24949. /** Billboard on X axis */
  24950. static readonly BILLBOARDMODE_X: number;
  24951. /** Billboard on Y axis */
  24952. static readonly BILLBOARDMODE_Y: number;
  24953. /** Billboard on Z axis */
  24954. static readonly BILLBOARDMODE_Z: number;
  24955. /** Billboard on all axes */
  24956. static readonly BILLBOARDMODE_ALL: number;
  24957. private _facetData;
  24958. /**
  24959. * The culling strategy to use to check whether the mesh must be rendered or not.
  24960. * This value can be changed at any time and will be used on the next render mesh selection.
  24961. * The possible values are :
  24962. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24963. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24966. * Please read each static variable documentation to get details about the culling process.
  24967. * */
  24968. cullingStrategy: number;
  24969. /**
  24970. * Gets the number of facets in the mesh
  24971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24972. */
  24973. readonly facetNb: number;
  24974. /**
  24975. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24977. */
  24978. partitioningSubdivisions: number;
  24979. /**
  24980. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24981. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24983. */
  24984. partitioningBBoxRatio: number;
  24985. /**
  24986. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24987. * Works only for updatable meshes.
  24988. * Doesn't work with multi-materials
  24989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24990. */
  24991. mustDepthSortFacets: boolean;
  24992. /**
  24993. * The location (Vector3) where the facet depth sort must be computed from.
  24994. * By default, the active camera position.
  24995. * Used only when facet depth sort is enabled
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24997. */
  24998. facetDepthSortFrom: Vector3;
  24999. /**
  25000. * gets a boolean indicating if facetData is enabled
  25001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25002. */
  25003. readonly isFacetDataEnabled: boolean;
  25004. /** @hidden */
  25005. _updateNonUniformScalingState(value: boolean): boolean;
  25006. /**
  25007. * An event triggered when this mesh collides with another one
  25008. */
  25009. onCollideObservable: Observable<AbstractMesh>;
  25010. private _onCollideObserver;
  25011. /** Set a function to call when this mesh collides with another one */
  25012. onCollide: () => void;
  25013. /**
  25014. * An event triggered when the collision's position changes
  25015. */
  25016. onCollisionPositionChangeObservable: Observable<Vector3>;
  25017. private _onCollisionPositionChangeObserver;
  25018. /** Set a function to call when the collision's position changes */
  25019. onCollisionPositionChange: () => void;
  25020. /**
  25021. * An event triggered when material is changed
  25022. */
  25023. onMaterialChangedObservable: Observable<AbstractMesh>;
  25024. /**
  25025. * Gets or sets the orientation for POV movement & rotation
  25026. */
  25027. definedFacingForward: boolean;
  25028. /** @hidden */
  25029. _occlusionQuery: Nullable<WebGLQuery>;
  25030. private _visibility;
  25031. /**
  25032. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25033. */
  25034. /**
  25035. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25036. */
  25037. visibility: number;
  25038. /** Gets or sets the alpha index used to sort transparent meshes
  25039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25040. */
  25041. alphaIndex: number;
  25042. /**
  25043. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25044. */
  25045. isVisible: boolean;
  25046. /**
  25047. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25048. */
  25049. isPickable: boolean;
  25050. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25051. showSubMeshesBoundingBox: boolean;
  25052. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25054. */
  25055. isBlocker: boolean;
  25056. /**
  25057. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25058. */
  25059. enablePointerMoveEvents: boolean;
  25060. /**
  25061. * Specifies the rendering group id for this mesh (0 by default)
  25062. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25063. */
  25064. renderingGroupId: number;
  25065. private _material;
  25066. /** Gets or sets current material */
  25067. material: Nullable<Material>;
  25068. private _receiveShadows;
  25069. /**
  25070. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25071. * @see http://doc.babylonjs.com/babylon101/shadows
  25072. */
  25073. receiveShadows: boolean;
  25074. /** Defines color to use when rendering outline */
  25075. outlineColor: Color3;
  25076. /** Define width to use when rendering outline */
  25077. outlineWidth: number;
  25078. /** Defines color to use when rendering overlay */
  25079. overlayColor: Color3;
  25080. /** Defines alpha to use when rendering overlay */
  25081. overlayAlpha: number;
  25082. private _hasVertexAlpha;
  25083. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25084. hasVertexAlpha: boolean;
  25085. private _useVertexColors;
  25086. /** 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) */
  25087. useVertexColors: boolean;
  25088. private _computeBonesUsingShaders;
  25089. /**
  25090. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25091. */
  25092. computeBonesUsingShaders: boolean;
  25093. private _numBoneInfluencers;
  25094. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25095. numBoneInfluencers: number;
  25096. private _applyFog;
  25097. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25098. applyFog: boolean;
  25099. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25100. useOctreeForRenderingSelection: boolean;
  25101. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25102. useOctreeForPicking: boolean;
  25103. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25104. useOctreeForCollisions: boolean;
  25105. private _layerMask;
  25106. /**
  25107. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25108. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25109. */
  25110. layerMask: number;
  25111. /**
  25112. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25113. */
  25114. alwaysSelectAsActiveMesh: boolean;
  25115. /**
  25116. * Gets or sets the current action manager
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25118. */
  25119. actionManager: Nullable<ActionManager>;
  25120. private _checkCollisions;
  25121. private _collisionMask;
  25122. private _collisionGroup;
  25123. /**
  25124. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25126. */
  25127. ellipsoid: Vector3;
  25128. /**
  25129. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25130. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25131. */
  25132. ellipsoidOffset: Vector3;
  25133. private _collider;
  25134. private _oldPositionForCollisions;
  25135. private _diffPositionForCollisions;
  25136. /**
  25137. * Gets or sets a collision mask used to mask collisions (default is -1).
  25138. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25139. */
  25140. collisionMask: number;
  25141. /**
  25142. * Gets or sets the current collision group mask (-1 by default).
  25143. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25144. */
  25145. collisionGroup: number;
  25146. /**
  25147. * Defines edge width used when edgesRenderer is enabled
  25148. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25149. */
  25150. edgesWidth: number;
  25151. /**
  25152. * Defines edge color used when edgesRenderer is enabled
  25153. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25154. */
  25155. edgesColor: Color4;
  25156. /** @hidden */
  25157. _edgesRenderer: Nullable<IEdgesRenderer>;
  25158. /** @hidden */
  25159. _masterMesh: Nullable<AbstractMesh>;
  25160. /** @hidden */
  25161. _boundingInfo: Nullable<BoundingInfo>;
  25162. /** @hidden */
  25163. _renderId: number;
  25164. /**
  25165. * Gets or sets the list of subMeshes
  25166. * @see http://doc.babylonjs.com/how_to/multi_materials
  25167. */
  25168. subMeshes: SubMesh[];
  25169. /** @hidden */
  25170. _intersectionsInProgress: AbstractMesh[];
  25171. /** @hidden */
  25172. _unIndexed: boolean;
  25173. /** @hidden */
  25174. _lightSources: Light[];
  25175. /** @hidden */
  25176. readonly _positions: Nullable<Vector3[]>;
  25177. /** @hidden */
  25178. _waitingActions: any;
  25179. /** @hidden */
  25180. _waitingFreezeWorldMatrix: Nullable<boolean>;
  25181. private _skeleton;
  25182. /** @hidden */
  25183. _bonesTransformMatrices: Nullable<Float32Array>;
  25184. /**
  25185. * Gets or sets a skeleton to apply skining transformations
  25186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25187. */
  25188. skeleton: Nullable<Skeleton>;
  25189. /**
  25190. * An event triggered when the mesh is rebuilt.
  25191. */
  25192. onRebuildObservable: Observable<AbstractMesh>;
  25193. /**
  25194. * Creates a new AbstractMesh
  25195. * @param name defines the name of the mesh
  25196. * @param scene defines the hosting scene
  25197. */
  25198. constructor(name: string, scene?: Nullable<Scene>);
  25199. /**
  25200. * Returns the string "AbstractMesh"
  25201. * @returns "AbstractMesh"
  25202. */
  25203. getClassName(): string;
  25204. /**
  25205. * Gets a string representation of the current mesh
  25206. * @param fullDetails defines a boolean indicating if full details must be included
  25207. * @returns a string representation of the current mesh
  25208. */
  25209. toString(fullDetails?: boolean): string;
  25210. /** @hidden */
  25211. _rebuild(): void;
  25212. /** @hidden */
  25213. _resyncLightSources(): void;
  25214. /** @hidden */
  25215. _resyncLighSource(light: Light): void;
  25216. /** @hidden */
  25217. _unBindEffect(): void;
  25218. /** @hidden */
  25219. _removeLightSource(light: Light): void;
  25220. private _markSubMeshesAsDirty;
  25221. /** @hidden */
  25222. _markSubMeshesAsLightDirty(): void;
  25223. /** @hidden */
  25224. _markSubMeshesAsAttributesDirty(): void;
  25225. /** @hidden */
  25226. _markSubMeshesAsMiscDirty(): void;
  25227. /**
  25228. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25229. */
  25230. scaling: Vector3;
  25231. /**
  25232. * Returns true if the mesh is blocked. Implemented by child classes
  25233. */
  25234. readonly isBlocked: boolean;
  25235. /**
  25236. * Returns the mesh itself by default. Implemented by child classes
  25237. * @param camera defines the camera to use to pick the right LOD level
  25238. * @returns the currentAbstractMesh
  25239. */
  25240. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25241. /**
  25242. * Returns 0 by default. Implemented by child classes
  25243. * @returns an integer
  25244. */
  25245. getTotalVertices(): number;
  25246. /**
  25247. * Returns a positive integer : the total number of indices in this mesh geometry.
  25248. * @returns the numner of indices or zero if the mesh has no geometry.
  25249. */
  25250. getTotalIndices(): number;
  25251. /**
  25252. * Returns null by default. Implemented by child classes
  25253. * @returns null
  25254. */
  25255. getIndices(): Nullable<IndicesArray>;
  25256. /**
  25257. * Returns the array of the requested vertex data kind. Implemented by child classes
  25258. * @param kind defines the vertex data kind to use
  25259. * @returns null
  25260. */
  25261. getVerticesData(kind: string): Nullable<FloatArray>;
  25262. /**
  25263. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25264. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25265. * Note that a new underlying VertexBuffer object is created each call.
  25266. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25267. * @param kind defines vertex data kind:
  25268. * * VertexBuffer.PositionKind
  25269. * * VertexBuffer.UVKind
  25270. * * VertexBuffer.UV2Kind
  25271. * * VertexBuffer.UV3Kind
  25272. * * VertexBuffer.UV4Kind
  25273. * * VertexBuffer.UV5Kind
  25274. * * VertexBuffer.UV6Kind
  25275. * * VertexBuffer.ColorKind
  25276. * * VertexBuffer.MatricesIndicesKind
  25277. * * VertexBuffer.MatricesIndicesExtraKind
  25278. * * VertexBuffer.MatricesWeightsKind
  25279. * * VertexBuffer.MatricesWeightsExtraKind
  25280. * @param data defines the data source
  25281. * @param updatable defines if the data must be flagged as updatable (or static)
  25282. * @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
  25283. * @returns the current mesh
  25284. */
  25285. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25286. /**
  25287. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25288. * If the mesh has no geometry, it is simply returned as it is.
  25289. * @param kind defines vertex data kind:
  25290. * * VertexBuffer.PositionKind
  25291. * * VertexBuffer.UVKind
  25292. * * VertexBuffer.UV2Kind
  25293. * * VertexBuffer.UV3Kind
  25294. * * VertexBuffer.UV4Kind
  25295. * * VertexBuffer.UV5Kind
  25296. * * VertexBuffer.UV6Kind
  25297. * * VertexBuffer.ColorKind
  25298. * * VertexBuffer.MatricesIndicesKind
  25299. * * VertexBuffer.MatricesIndicesExtraKind
  25300. * * VertexBuffer.MatricesWeightsKind
  25301. * * VertexBuffer.MatricesWeightsExtraKind
  25302. * @param data defines the data source
  25303. * @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
  25304. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25305. * @returns the current mesh
  25306. */
  25307. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25308. /**
  25309. * Sets the mesh indices,
  25310. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25311. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25312. * @param totalVertices Defines the total number of vertices
  25313. * @returns the current mesh
  25314. */
  25315. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25316. /**
  25317. * Gets a boolean indicating if specific vertex data is present
  25318. * @param kind defines the vertex data kind to use
  25319. * @returns true is data kind is present
  25320. */
  25321. isVerticesDataPresent(kind: string): boolean;
  25322. /**
  25323. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25324. * @returns a BoundingInfo
  25325. */
  25326. getBoundingInfo(): BoundingInfo;
  25327. /**
  25328. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25329. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  25330. * @returns the current mesh
  25331. */
  25332. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  25333. /**
  25334. * Overwrite the current bounding info
  25335. * @param boundingInfo defines the new bounding info
  25336. * @returns the current mesh
  25337. */
  25338. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25339. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25340. readonly useBones: boolean;
  25341. /** @hidden */
  25342. _preActivate(): void;
  25343. /** @hidden */
  25344. _preActivateForIntermediateRendering(renderId: number): void;
  25345. /** @hidden */
  25346. _activate(renderId: number): void;
  25347. /**
  25348. * Gets the current world matrix
  25349. * @returns a Matrix
  25350. */
  25351. getWorldMatrix(): Matrix;
  25352. /** @hidden */
  25353. _getWorldMatrixDeterminant(): number;
  25354. /**
  25355. * Perform relative position change from the point of view of behind the front of the mesh.
  25356. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25357. * Supports definition of mesh facing forward or backward
  25358. * @param amountRight defines the distance on the right axis
  25359. * @param amountUp defines the distance on the up axis
  25360. * @param amountForward defines the distance on the forward axis
  25361. * @returns the current mesh
  25362. */
  25363. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25364. /**
  25365. * Calculate relative position change from the point of view of behind the front of the mesh.
  25366. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25367. * Supports definition of mesh facing forward or backward
  25368. * @param amountRight defines the distance on the right axis
  25369. * @param amountUp defines the distance on the up axis
  25370. * @param amountForward defines the distance on the forward axis
  25371. * @returns the new displacement vector
  25372. */
  25373. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25374. /**
  25375. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25376. * Supports definition of mesh facing forward or backward
  25377. * @param flipBack defines the flip
  25378. * @param twirlClockwise defines the twirl
  25379. * @param tiltRight defines the tilt
  25380. * @returns the current mesh
  25381. */
  25382. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25383. /**
  25384. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25385. * Supports definition of mesh facing forward or backward.
  25386. * @param flipBack defines the flip
  25387. * @param twirlClockwise defines the twirl
  25388. * @param tiltRight defines the tilt
  25389. * @returns the new rotation vector
  25390. */
  25391. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25392. /**
  25393. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  25394. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25395. * @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
  25396. * @returns the new bounding vectors
  25397. */
  25398. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25399. min: Vector3;
  25400. max: Vector3;
  25401. };
  25402. /**
  25403. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25404. * This means the mesh underlying bounding box and sphere are recomputed.
  25405. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25406. * @returns the current mesh
  25407. */
  25408. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25409. /** @hidden */
  25410. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25411. /** @hidden */
  25412. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25413. /** @hidden */
  25414. _updateBoundingInfo(): AbstractMesh;
  25415. /** @hidden */
  25416. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25417. /** @hidden */
  25418. protected _afterComputeWorldMatrix(): void;
  25419. /**
  25420. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25421. * A mesh is in the frustum if its bounding box intersects the frustum
  25422. * @param frustumPlanes defines the frustum to test
  25423. * @returns true if the mesh is in the frustum planes
  25424. */
  25425. isInFrustum(frustumPlanes: Plane[]): boolean;
  25426. /**
  25427. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25428. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25429. * @param frustumPlanes defines the frustum to test
  25430. * @returns true if the mesh is completely in the frustum planes
  25431. */
  25432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25433. /**
  25434. * True if the mesh intersects another mesh or a SolidParticle object
  25435. * @param mesh defines a target mesh or SolidParticle to test
  25436. * @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)
  25437. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25438. * @returns true if there is an intersection
  25439. */
  25440. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25441. /**
  25442. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25443. * @param point defines the point to test
  25444. * @returns true if there is an intersection
  25445. */
  25446. intersectsPoint(point: Vector3): boolean;
  25447. /**
  25448. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25450. */
  25451. checkCollisions: boolean;
  25452. /**
  25453. * Gets Collider object used to compute collisions (not physics)
  25454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25455. */
  25456. readonly collider: Collider;
  25457. /**
  25458. * Move the mesh using collision engine
  25459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25460. * @param displacement defines the requested displacement vector
  25461. * @returns the current mesh
  25462. */
  25463. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25464. private _onCollisionPositionChange;
  25465. /** @hidden */
  25466. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25467. /** @hidden */
  25468. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25469. /** @hidden */
  25470. _checkCollision(collider: Collider): AbstractMesh;
  25471. /** @hidden */
  25472. _generatePointsArray(): boolean;
  25473. /**
  25474. * Checks if the passed Ray intersects with the mesh
  25475. * @param ray defines the ray to use
  25476. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25477. * @returns the picking info
  25478. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25479. */
  25480. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  25481. /**
  25482. * Clones the current mesh
  25483. * @param name defines the mesh name
  25484. * @param newParent defines the new mesh parent
  25485. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25486. * @returns the new mesh
  25487. */
  25488. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25489. /**
  25490. * Disposes all the submeshes of the current meshnp
  25491. * @returns the current mesh
  25492. */
  25493. releaseSubMeshes(): AbstractMesh;
  25494. /**
  25495. * Releases resources associated with this abstract mesh.
  25496. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25497. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25498. */
  25499. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25500. /**
  25501. * Adds the passed mesh as a child to the current mesh
  25502. * @param mesh defines the child mesh
  25503. * @returns the current mesh
  25504. */
  25505. addChild(mesh: AbstractMesh): AbstractMesh;
  25506. /**
  25507. * Removes the passed mesh from the current mesh children list
  25508. * @param mesh defines the child mesh
  25509. * @returns the current mesh
  25510. */
  25511. removeChild(mesh: AbstractMesh): AbstractMesh;
  25512. /** @hidden */
  25513. private _initFacetData;
  25514. /**
  25515. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25516. * This method can be called within the render loop.
  25517. * 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
  25518. * @returns the current mesh
  25519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25520. */
  25521. updateFacetData(): AbstractMesh;
  25522. /**
  25523. * Returns the facetLocalNormals array.
  25524. * The normals are expressed in the mesh local spac
  25525. * @returns an array of Vector3
  25526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25527. */
  25528. getFacetLocalNormals(): Vector3[];
  25529. /**
  25530. * Returns the facetLocalPositions array.
  25531. * The facet positions are expressed in the mesh local space
  25532. * @returns an array of Vector3
  25533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25534. */
  25535. getFacetLocalPositions(): Vector3[];
  25536. /**
  25537. * Returns the facetLocalPartioning array
  25538. * @returns an array of array of numbers
  25539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25540. */
  25541. getFacetLocalPartitioning(): number[][];
  25542. /**
  25543. * Returns the i-th facet position in the world system.
  25544. * This method allocates a new Vector3 per call
  25545. * @param i defines the facet index
  25546. * @returns a new Vector3
  25547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25548. */
  25549. getFacetPosition(i: number): Vector3;
  25550. /**
  25551. * Sets the reference Vector3 with the i-th facet position in the world system
  25552. * @param i defines the facet index
  25553. * @param ref defines the target vector
  25554. * @returns the current mesh
  25555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25556. */
  25557. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25558. /**
  25559. * Returns the i-th facet normal in the world system.
  25560. * This method allocates a new Vector3 per call
  25561. * @param i defines the facet index
  25562. * @returns a new Vector3
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25564. */
  25565. getFacetNormal(i: number): Vector3;
  25566. /**
  25567. * Sets the reference Vector3 with the i-th facet normal in the world system
  25568. * @param i defines the facet index
  25569. * @param ref defines the target vector
  25570. * @returns the current mesh
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25572. */
  25573. getFacetNormalToRef(i: number, ref: Vector3): this;
  25574. /**
  25575. * 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)
  25576. * @param x defines x coordinate
  25577. * @param y defines y coordinate
  25578. * @param z defines z coordinate
  25579. * @returns the array of facet indexes
  25580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25581. */
  25582. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25583. /**
  25584. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25585. * @param projected sets as the (x,y,z) world projection on the facet
  25586. * @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
  25587. * @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
  25588. * @param x defines x coordinate
  25589. * @param y defines y coordinate
  25590. * @param z defines z coordinate
  25591. * @returns the face index if found (or null instead)
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25593. */
  25594. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25595. /**
  25596. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25597. * @param projected sets as the (x,y,z) local projection on the facet
  25598. * @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
  25599. * @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
  25600. * @param x defines x coordinate
  25601. * @param y defines y coordinate
  25602. * @param z defines z coordinate
  25603. * @returns the face index if found (or null instead)
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25605. */
  25606. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25607. /**
  25608. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25609. * @returns the parameters
  25610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25611. */
  25612. getFacetDataParameters(): any;
  25613. /**
  25614. * Disables the feature FacetData and frees the related memory
  25615. * @returns the current mesh
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. disableFacetData(): AbstractMesh;
  25619. /**
  25620. * Updates the AbstractMesh indices array
  25621. * @param indices defines the data source
  25622. * @returns the current mesh
  25623. */
  25624. updateIndices(indices: IndicesArray): AbstractMesh;
  25625. /**
  25626. * Creates new normals data for the mesh
  25627. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25628. * @returns the current mesh
  25629. */
  25630. createNormals(updatable: boolean): AbstractMesh;
  25631. /**
  25632. * Align the mesh with a normal
  25633. * @param normal defines the normal to use
  25634. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25635. * @returns the current mesh
  25636. */
  25637. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25638. /** @hidden */
  25639. _checkOcclusionQuery(): boolean;
  25640. }
  25641. }
  25642. declare module "babylonjs/node" {
  25643. import { Scene } from "babylonjs/scene";
  25644. import { Nullable } from "babylonjs/types";
  25645. import { Matrix } from "babylonjs/Maths/math";
  25646. import { Engine } from "babylonjs/Engines/engine";
  25647. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25648. import { Observable } from "babylonjs/Misc/observable";
  25649. import { Animatable } from "babylonjs/Animations/animatable";
  25650. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25651. import { Animation } from "babylonjs/Animations/animation";
  25652. import { AnimationRange } from "babylonjs/Animations/animation";
  25653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25654. /**
  25655. * Defines how a node can be built from a string name.
  25656. */
  25657. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25658. /**
  25659. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25660. */
  25661. export class Node implements IBehaviorAware<Node> {
  25662. /** @hidden */
  25663. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  25664. private static _NodeConstructors;
  25665. /**
  25666. * Add a new node constructor
  25667. * @param type defines the type name of the node to construct
  25668. * @param constructorFunc defines the constructor function
  25669. */
  25670. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25671. /**
  25672. * Returns a node constructor based on type name
  25673. * @param type defines the type name
  25674. * @param name defines the new node name
  25675. * @param scene defines the hosting scene
  25676. * @param options defines optional options to transmit to constructors
  25677. * @returns the new constructor or null
  25678. */
  25679. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25680. /**
  25681. * Gets or sets the name of the node
  25682. */
  25683. name: string;
  25684. /**
  25685. * Gets or sets the id of the node
  25686. */
  25687. id: string;
  25688. /**
  25689. * Gets or sets the unique id of the node
  25690. */
  25691. uniqueId: number;
  25692. /**
  25693. * Gets or sets a string used to store user defined state for the node
  25694. */
  25695. state: string;
  25696. /**
  25697. * Gets or sets an object used to store user defined information for the node
  25698. */
  25699. metadata: any;
  25700. /**
  25701. * For internal use only. Please do not use.
  25702. */
  25703. reservedDataStore: any;
  25704. /**
  25705. * Gets or sets a boolean used to define if the node must be serialized
  25706. */
  25707. doNotSerialize: boolean;
  25708. /** @hidden */
  25709. _isDisposed: boolean;
  25710. /**
  25711. * Gets a list of Animations associated with the node
  25712. */
  25713. animations: import("babylonjs/Animations/animation").Animation[];
  25714. protected _ranges: {
  25715. [name: string]: Nullable<AnimationRange>;
  25716. };
  25717. /**
  25718. * Callback raised when the node is ready to be used
  25719. */
  25720. onReady: (node: Node) => void;
  25721. private _isEnabled;
  25722. private _isParentEnabled;
  25723. private _isReady;
  25724. /** @hidden */
  25725. _currentRenderId: number;
  25726. private _parentRenderId;
  25727. protected _childRenderId: number;
  25728. /** @hidden */
  25729. _waitingParentId: Nullable<string>;
  25730. /** @hidden */
  25731. _scene: Scene;
  25732. /** @hidden */
  25733. _cache: any;
  25734. private _parentNode;
  25735. private _children;
  25736. /** @hidden */
  25737. _worldMatrix: Matrix;
  25738. /** @hidden */
  25739. _worldMatrixDeterminant: number;
  25740. /** @hidden */
  25741. private _sceneRootNodesIndex;
  25742. /**
  25743. * Gets a boolean indicating if the node has been disposed
  25744. * @returns true if the node was disposed
  25745. */
  25746. isDisposed(): boolean;
  25747. /**
  25748. * Gets or sets the parent of the node
  25749. */
  25750. parent: Nullable<Node>;
  25751. private addToSceneRootNodes;
  25752. private removeFromSceneRootNodes;
  25753. private _animationPropertiesOverride;
  25754. /**
  25755. * Gets or sets the animation properties override
  25756. */
  25757. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25758. /**
  25759. * Gets a string idenfifying the name of the class
  25760. * @returns "Node" string
  25761. */
  25762. getClassName(): string;
  25763. /** @hidden */
  25764. readonly _isNode: boolean;
  25765. /**
  25766. * An event triggered when the mesh is disposed
  25767. */
  25768. onDisposeObservable: Observable<Node>;
  25769. private _onDisposeObserver;
  25770. /**
  25771. * Sets a callback that will be raised when the node will be disposed
  25772. */
  25773. onDispose: () => void;
  25774. /**
  25775. * Creates a new Node
  25776. * @param name the name and id to be given to this node
  25777. * @param scene the scene this node will be added to
  25778. * @param addToRootNodes the node will be added to scene.rootNodes
  25779. */
  25780. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25781. /**
  25782. * Gets the scene of the node
  25783. * @returns a scene
  25784. */
  25785. getScene(): Scene;
  25786. /**
  25787. * Gets the engine of the node
  25788. * @returns a Engine
  25789. */
  25790. getEngine(): Engine;
  25791. private _behaviors;
  25792. /**
  25793. * Attach a behavior to the node
  25794. * @see http://doc.babylonjs.com/features/behaviour
  25795. * @param behavior defines the behavior to attach
  25796. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25797. * @returns the current Node
  25798. */
  25799. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25800. /**
  25801. * Remove an attached behavior
  25802. * @see http://doc.babylonjs.com/features/behaviour
  25803. * @param behavior defines the behavior to attach
  25804. * @returns the current Node
  25805. */
  25806. removeBehavior(behavior: Behavior<Node>): Node;
  25807. /**
  25808. * Gets the list of attached behaviors
  25809. * @see http://doc.babylonjs.com/features/behaviour
  25810. */
  25811. readonly behaviors: Behavior<Node>[];
  25812. /**
  25813. * Gets an attached behavior by name
  25814. * @param name defines the name of the behavior to look for
  25815. * @see http://doc.babylonjs.com/features/behaviour
  25816. * @returns null if behavior was not found else the requested behavior
  25817. */
  25818. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25819. /**
  25820. * Returns the latest update of the World matrix
  25821. * @returns a Matrix
  25822. */
  25823. getWorldMatrix(): Matrix;
  25824. /** @hidden */
  25825. _getWorldMatrixDeterminant(): number;
  25826. /**
  25827. * Returns directly the latest state of the mesh World matrix.
  25828. * A Matrix is returned.
  25829. */
  25830. readonly worldMatrixFromCache: Matrix;
  25831. /** @hidden */
  25832. _initCache(): void;
  25833. /** @hidden */
  25834. updateCache(force?: boolean): void;
  25835. /** @hidden */
  25836. _updateCache(ignoreParentClass?: boolean): void;
  25837. /** @hidden */
  25838. _isSynchronized(): boolean;
  25839. /** @hidden */
  25840. _markSyncedWithParent(): void;
  25841. /** @hidden */
  25842. isSynchronizedWithParent(): boolean;
  25843. /** @hidden */
  25844. isSynchronized(): boolean;
  25845. /**
  25846. * Is this node ready to be used/rendered
  25847. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25848. * @return true if the node is ready
  25849. */
  25850. isReady(completeCheck?: boolean): boolean;
  25851. /**
  25852. * Is this node enabled?
  25853. * 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
  25854. * @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
  25855. * @return whether this node (and its parent) is enabled
  25856. */
  25857. isEnabled(checkAncestors?: boolean): boolean;
  25858. /** @hidden */
  25859. protected _syncParentEnabledState(): void;
  25860. /**
  25861. * Set the enabled state of this node
  25862. * @param value defines the new enabled state
  25863. */
  25864. setEnabled(value: boolean): void;
  25865. /**
  25866. * Is this node a descendant of the given node?
  25867. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25868. * @param ancestor defines the parent node to inspect
  25869. * @returns a boolean indicating if this node is a descendant of the given node
  25870. */
  25871. isDescendantOf(ancestor: Node): boolean;
  25872. /** @hidden */
  25873. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25874. /**
  25875. * Will return all nodes that have this node as ascendant
  25876. * @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
  25877. * @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
  25878. * @return all children nodes of all types
  25879. */
  25880. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25881. /**
  25882. * Get all child-meshes of this node
  25883. * @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
  25884. * @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
  25885. * @returns an array of AbstractMesh
  25886. */
  25887. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25888. /**
  25889. * Get all direct children of this node
  25890. * @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
  25891. * @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)
  25892. * @returns an array of Node
  25893. */
  25894. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25895. /** @hidden */
  25896. _setReady(state: boolean): void;
  25897. /**
  25898. * Get an animation by name
  25899. * @param name defines the name of the animation to look for
  25900. * @returns null if not found else the requested animation
  25901. */
  25902. getAnimationByName(name: string): Nullable<Animation>;
  25903. /**
  25904. * Creates an animation range for this node
  25905. * @param name defines the name of the range
  25906. * @param from defines the starting key
  25907. * @param to defines the end key
  25908. */
  25909. createAnimationRange(name: string, from: number, to: number): void;
  25910. /**
  25911. * Delete a specific animation range
  25912. * @param name defines the name of the range to delete
  25913. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25914. */
  25915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25916. /**
  25917. * Get an animation range by name
  25918. * @param name defines the name of the animation range to look for
  25919. * @returns null if not found else the requested animation range
  25920. */
  25921. getAnimationRange(name: string): Nullable<AnimationRange>;
  25922. /**
  25923. * Will start the animation sequence
  25924. * @param name defines the range frames for animation sequence
  25925. * @param loop defines if the animation should loop (false by default)
  25926. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25927. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25928. * @returns the object created for this animation. If range does not exist, it will return null
  25929. */
  25930. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25931. /**
  25932. * Serialize animation ranges into a JSON compatible object
  25933. * @returns serialization object
  25934. */
  25935. serializeAnimationRanges(): any;
  25936. /**
  25937. * Computes the world matrix of the node
  25938. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25939. * @returns the world matrix
  25940. */
  25941. computeWorldMatrix(force?: boolean): Matrix;
  25942. /**
  25943. * Releases resources associated with this node.
  25944. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25945. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25946. */
  25947. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25948. /**
  25949. * Parse animation range data from a serialization object and store them into a given node
  25950. * @param node defines where to store the animation ranges
  25951. * @param parsedNode defines the serialization object to read data from
  25952. * @param scene defines the hosting scene
  25953. */
  25954. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25955. }
  25956. }
  25957. declare module "babylonjs/Animations/animation" {
  25958. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25959. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25960. import { Nullable } from "babylonjs/types";
  25961. import { Scene } from "babylonjs/scene";
  25962. import { IAnimatable } from "babylonjs/Misc/tools";
  25963. import { Node } from "babylonjs/node";
  25964. import { Animatable } from "babylonjs/Animations/animatable";
  25965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25966. /**
  25967. * Represents the range of an animation
  25968. */
  25969. export class AnimationRange {
  25970. /**The name of the animation range**/
  25971. name: string;
  25972. /**The starting frame of the animation */
  25973. from: number;
  25974. /**The ending frame of the animation*/
  25975. to: number;
  25976. /**
  25977. * Initializes the range of an animation
  25978. * @param name The name of the animation range
  25979. * @param from The starting frame of the animation
  25980. * @param to The ending frame of the animation
  25981. */
  25982. constructor(
  25983. /**The name of the animation range**/
  25984. name: string,
  25985. /**The starting frame of the animation */
  25986. from: number,
  25987. /**The ending frame of the animation*/
  25988. to: number);
  25989. /**
  25990. * Makes a copy of the animation range
  25991. * @returns A copy of the animation range
  25992. */
  25993. clone(): AnimationRange;
  25994. }
  25995. /**
  25996. * Composed of a frame, and an action function
  25997. */
  25998. export class AnimationEvent {
  25999. /** The frame for which the event is triggered **/
  26000. frame: number;
  26001. /** The event to perform when triggered **/
  26002. action: (currentFrame: number) => void;
  26003. /** Specifies if the event should be triggered only once**/
  26004. onlyOnce?: boolean | undefined;
  26005. /**
  26006. * Specifies if the animation event is done
  26007. */
  26008. isDone: boolean;
  26009. /**
  26010. * Initializes the animation event
  26011. * @param frame The frame for which the event is triggered
  26012. * @param action The event to perform when triggered
  26013. * @param onlyOnce Specifies if the event should be triggered only once
  26014. */
  26015. constructor(
  26016. /** The frame for which the event is triggered **/
  26017. frame: number,
  26018. /** The event to perform when triggered **/
  26019. action: (currentFrame: number) => void,
  26020. /** Specifies if the event should be triggered only once**/
  26021. onlyOnce?: boolean | undefined);
  26022. /** @hidden */
  26023. _clone(): AnimationEvent;
  26024. }
  26025. /**
  26026. * A cursor which tracks a point on a path
  26027. */
  26028. export class PathCursor {
  26029. private path;
  26030. /**
  26031. * Stores path cursor callbacks for when an onchange event is triggered
  26032. */
  26033. private _onchange;
  26034. /**
  26035. * The value of the path cursor
  26036. */
  26037. value: number;
  26038. /**
  26039. * The animation array of the path cursor
  26040. */
  26041. animations: Animation[];
  26042. /**
  26043. * Initializes the path cursor
  26044. * @param path The path to track
  26045. */
  26046. constructor(path: Path2);
  26047. /**
  26048. * Gets the cursor point on the path
  26049. * @returns A point on the path cursor at the cursor location
  26050. */
  26051. getPoint(): Vector3;
  26052. /**
  26053. * Moves the cursor ahead by the step amount
  26054. * @param step The amount to move the cursor forward
  26055. * @returns This path cursor
  26056. */
  26057. moveAhead(step?: number): PathCursor;
  26058. /**
  26059. * Moves the cursor behind by the step amount
  26060. * @param step The amount to move the cursor back
  26061. * @returns This path cursor
  26062. */
  26063. moveBack(step?: number): PathCursor;
  26064. /**
  26065. * Moves the cursor by the step amount
  26066. * If the step amount is greater than one, an exception is thrown
  26067. * @param step The amount to move the cursor
  26068. * @returns This path cursor
  26069. */
  26070. move(step: number): PathCursor;
  26071. /**
  26072. * Ensures that the value is limited between zero and one
  26073. * @returns This path cursor
  26074. */
  26075. private ensureLimits;
  26076. /**
  26077. * Runs onchange callbacks on change (used by the animation engine)
  26078. * @returns This path cursor
  26079. */
  26080. private raiseOnChange;
  26081. /**
  26082. * Executes a function on change
  26083. * @param f A path cursor onchange callback
  26084. * @returns This path cursor
  26085. */
  26086. onchange(f: (cursor: PathCursor) => void): PathCursor;
  26087. }
  26088. /**
  26089. * Defines an interface which represents an animation key frame
  26090. */
  26091. export interface IAnimationKey {
  26092. /**
  26093. * Frame of the key frame
  26094. */
  26095. frame: number;
  26096. /**
  26097. * Value at the specifies key frame
  26098. */
  26099. value: any;
  26100. /**
  26101. * The input tangent for the cubic hermite spline
  26102. */
  26103. inTangent?: any;
  26104. /**
  26105. * The output tangent for the cubic hermite spline
  26106. */
  26107. outTangent?: any;
  26108. /**
  26109. * The animation interpolation type
  26110. */
  26111. interpolation?: AnimationKeyInterpolation;
  26112. }
  26113. /**
  26114. * Enum for the animation key frame interpolation type
  26115. */
  26116. export enum AnimationKeyInterpolation {
  26117. /**
  26118. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  26119. */
  26120. STEP = 1
  26121. }
  26122. /**
  26123. * Class used to store any kind of animation
  26124. */
  26125. export class Animation {
  26126. /**Name of the animation */
  26127. name: string;
  26128. /**Property to animate */
  26129. targetProperty: string;
  26130. /**The frames per second of the animation */
  26131. framePerSecond: number;
  26132. /**The data type of the animation */
  26133. dataType: number;
  26134. /**The loop mode of the animation */
  26135. loopMode?: number | undefined;
  26136. /**Specifies if blending should be enabled */
  26137. enableBlending?: boolean | undefined;
  26138. /**
  26139. * Use matrix interpolation instead of using direct key value when animating matrices
  26140. */
  26141. static AllowMatricesInterpolation: boolean;
  26142. /**
  26143. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26144. */
  26145. static AllowMatrixDecomposeForInterpolation: boolean;
  26146. /**
  26147. * Stores the key frames of the animation
  26148. */
  26149. private _keys;
  26150. /**
  26151. * Stores the easing function of the animation
  26152. */
  26153. private _easingFunction;
  26154. /**
  26155. * @hidden Internal use only
  26156. */
  26157. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26158. /**
  26159. * The set of event that will be linked to this animation
  26160. */
  26161. private _events;
  26162. /**
  26163. * Stores an array of target property paths
  26164. */
  26165. targetPropertyPath: string[];
  26166. /**
  26167. * Stores the blending speed of the animation
  26168. */
  26169. blendingSpeed: number;
  26170. /**
  26171. * Stores the animation ranges for the animation
  26172. */
  26173. private _ranges;
  26174. /**
  26175. * @hidden Internal use
  26176. */
  26177. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26178. /**
  26179. * Sets up an animation
  26180. * @param property The property to animate
  26181. * @param animationType The animation type to apply
  26182. * @param framePerSecond The frames per second of the animation
  26183. * @param easingFunction The easing function used in the animation
  26184. * @returns The created animation
  26185. */
  26186. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26187. /**
  26188. * Create and start an animation on a node
  26189. * @param name defines the name of the global animation that will be run on all nodes
  26190. * @param node defines the root node where the animation will take place
  26191. * @param targetProperty defines property to animate
  26192. * @param framePerSecond defines the number of frame per second yo use
  26193. * @param totalFrame defines the number of frames in total
  26194. * @param from defines the initial value
  26195. * @param to defines the final value
  26196. * @param loopMode defines which loop mode you want to use (off by default)
  26197. * @param easingFunction defines the easing function to use (linear by default)
  26198. * @param onAnimationEnd defines the callback to call when animation end
  26199. * @returns the animatable created for this animation
  26200. */
  26201. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26202. /**
  26203. * Create and start an animation on a node and its descendants
  26204. * @param name defines the name of the global animation that will be run on all nodes
  26205. * @param node defines the root node where the animation will take place
  26206. * @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
  26207. * @param targetProperty defines property to animate
  26208. * @param framePerSecond defines the number of frame per second to use
  26209. * @param totalFrame defines the number of frames in total
  26210. * @param from defines the initial value
  26211. * @param to defines the final value
  26212. * @param loopMode defines which loop mode you want to use (off by default)
  26213. * @param easingFunction defines the easing function to use (linear by default)
  26214. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26215. * @returns the list of animatables created for all nodes
  26216. * @example https://www.babylonjs-playground.com/#MH0VLI
  26217. */
  26218. 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[]>;
  26219. /**
  26220. * Creates a new animation, merges it with the existing animations and starts it
  26221. * @param name Name of the animation
  26222. * @param node Node which contains the scene that begins the animations
  26223. * @param targetProperty Specifies which property to animate
  26224. * @param framePerSecond The frames per second of the animation
  26225. * @param totalFrame The total number of frames
  26226. * @param from The frame at the beginning of the animation
  26227. * @param to The frame at the end of the animation
  26228. * @param loopMode Specifies the loop mode of the animation
  26229. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26230. * @param onAnimationEnd Callback to run once the animation is complete
  26231. * @returns Nullable animation
  26232. */
  26233. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26234. /**
  26235. * Transition property of an host to the target Value
  26236. * @param property The property to transition
  26237. * @param targetValue The target Value of the property
  26238. * @param host The object where the property to animate belongs
  26239. * @param scene Scene used to run the animation
  26240. * @param frameRate Framerate (in frame/s) to use
  26241. * @param transition The transition type we want to use
  26242. * @param duration The duration of the animation, in milliseconds
  26243. * @param onAnimationEnd Callback trigger at the end of the animation
  26244. * @returns Nullable animation
  26245. */
  26246. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26247. /**
  26248. * Return the array of runtime animations currently using this animation
  26249. */
  26250. readonly runtimeAnimations: RuntimeAnimation[];
  26251. /**
  26252. * Specifies if any of the runtime animations are currently running
  26253. */
  26254. readonly hasRunningRuntimeAnimations: boolean;
  26255. /**
  26256. * Initializes the animation
  26257. * @param name Name of the animation
  26258. * @param targetProperty Property to animate
  26259. * @param framePerSecond The frames per second of the animation
  26260. * @param dataType The data type of the animation
  26261. * @param loopMode The loop mode of the animation
  26262. * @param enableBlendings Specifies if blending should be enabled
  26263. */
  26264. constructor(
  26265. /**Name of the animation */
  26266. name: string,
  26267. /**Property to animate */
  26268. targetProperty: string,
  26269. /**The frames per second of the animation */
  26270. framePerSecond: number,
  26271. /**The data type of the animation */
  26272. dataType: number,
  26273. /**The loop mode of the animation */
  26274. loopMode?: number | undefined,
  26275. /**Specifies if blending should be enabled */
  26276. enableBlending?: boolean | undefined);
  26277. /**
  26278. * Converts the animation to a string
  26279. * @param fullDetails support for multiple levels of logging within scene loading
  26280. * @returns String form of the animation
  26281. */
  26282. toString(fullDetails?: boolean): string;
  26283. /**
  26284. * Add an event to this animation
  26285. * @param event Event to add
  26286. */
  26287. addEvent(event: AnimationEvent): void;
  26288. /**
  26289. * Remove all events found at the given frame
  26290. * @param frame The frame to remove events from
  26291. */
  26292. removeEvents(frame: number): void;
  26293. /**
  26294. * Retrieves all the events from the animation
  26295. * @returns Events from the animation
  26296. */
  26297. getEvents(): AnimationEvent[];
  26298. /**
  26299. * Creates an animation range
  26300. * @param name Name of the animation range
  26301. * @param from Starting frame of the animation range
  26302. * @param to Ending frame of the animation
  26303. */
  26304. createRange(name: string, from: number, to: number): void;
  26305. /**
  26306. * Deletes an animation range by name
  26307. * @param name Name of the animation range to delete
  26308. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26309. */
  26310. deleteRange(name: string, deleteFrames?: boolean): void;
  26311. /**
  26312. * Gets the animation range by name, or null if not defined
  26313. * @param name Name of the animation range
  26314. * @returns Nullable animation range
  26315. */
  26316. getRange(name: string): Nullable<AnimationRange>;
  26317. /**
  26318. * Gets the key frames from the animation
  26319. * @returns The key frames of the animation
  26320. */
  26321. getKeys(): Array<IAnimationKey>;
  26322. /**
  26323. * Gets the highest frame rate of the animation
  26324. * @returns Highest frame rate of the animation
  26325. */
  26326. getHighestFrame(): number;
  26327. /**
  26328. * Gets the easing function of the animation
  26329. * @returns Easing function of the animation
  26330. */
  26331. getEasingFunction(): IEasingFunction;
  26332. /**
  26333. * Sets the easing function of the animation
  26334. * @param easingFunction A custom mathematical formula for animation
  26335. */
  26336. setEasingFunction(easingFunction: EasingFunction): void;
  26337. /**
  26338. * Interpolates a scalar linearly
  26339. * @param startValue Start value of the animation curve
  26340. * @param endValue End value of the animation curve
  26341. * @param gradient Scalar amount to interpolate
  26342. * @returns Interpolated scalar value
  26343. */
  26344. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26345. /**
  26346. * Interpolates a scalar cubically
  26347. * @param startValue Start value of the animation curve
  26348. * @param outTangent End tangent of the animation
  26349. * @param endValue End value of the animation curve
  26350. * @param inTangent Start tangent of the animation curve
  26351. * @param gradient Scalar amount to interpolate
  26352. * @returns Interpolated scalar value
  26353. */
  26354. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26355. /**
  26356. * Interpolates a quaternion using a spherical linear interpolation
  26357. * @param startValue Start value of the animation curve
  26358. * @param endValue End value of the animation curve
  26359. * @param gradient Scalar amount to interpolate
  26360. * @returns Interpolated quaternion value
  26361. */
  26362. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26363. /**
  26364. * Interpolates a quaternion cubically
  26365. * @param startValue Start value of the animation curve
  26366. * @param outTangent End tangent of the animation curve
  26367. * @param endValue End value of the animation curve
  26368. * @param inTangent Start tangent of the animation curve
  26369. * @param gradient Scalar amount to interpolate
  26370. * @returns Interpolated quaternion value
  26371. */
  26372. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26373. /**
  26374. * Interpolates a Vector3 linearl
  26375. * @param startValue Start value of the animation curve
  26376. * @param endValue End value of the animation curve
  26377. * @param gradient Scalar amount to interpolate
  26378. * @returns Interpolated scalar value
  26379. */
  26380. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26381. /**
  26382. * Interpolates a Vector3 cubically
  26383. * @param startValue Start value of the animation curve
  26384. * @param outTangent End tangent of the animation
  26385. * @param endValue End value of the animation curve
  26386. * @param inTangent Start tangent of the animation curve
  26387. * @param gradient Scalar amount to interpolate
  26388. * @returns InterpolatedVector3 value
  26389. */
  26390. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26391. /**
  26392. * Interpolates a Vector2 linearly
  26393. * @param startValue Start value of the animation curve
  26394. * @param endValue End value of the animation curve
  26395. * @param gradient Scalar amount to interpolate
  26396. * @returns Interpolated Vector2 value
  26397. */
  26398. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26399. /**
  26400. * Interpolates a Vector2 cubically
  26401. * @param startValue Start value of the animation curve
  26402. * @param outTangent End tangent of the animation
  26403. * @param endValue End value of the animation curve
  26404. * @param inTangent Start tangent of the animation curve
  26405. * @param gradient Scalar amount to interpolate
  26406. * @returns Interpolated Vector2 value
  26407. */
  26408. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26409. /**
  26410. * Interpolates a size linearly
  26411. * @param startValue Start value of the animation curve
  26412. * @param endValue End value of the animation curve
  26413. * @param gradient Scalar amount to interpolate
  26414. * @returns Interpolated Size value
  26415. */
  26416. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26417. /**
  26418. * Interpolates a Color3 linearly
  26419. * @param startValue Start value of the animation curve
  26420. * @param endValue End value of the animation curve
  26421. * @param gradient Scalar amount to interpolate
  26422. * @returns Interpolated Color3 value
  26423. */
  26424. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26425. /**
  26426. * @hidden Internal use only
  26427. */
  26428. _getKeyValue(value: any): any;
  26429. /**
  26430. * @hidden Internal use only
  26431. */
  26432. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26433. /**
  26434. * Defines the function to use to interpolate matrices
  26435. * @param startValue defines the start matrix
  26436. * @param endValue defines the end matrix
  26437. * @param gradient defines the gradient between both matrices
  26438. * @param result defines an optional target matrix where to store the interpolation
  26439. * @returns the interpolated matrix
  26440. */
  26441. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26442. /**
  26443. * Makes a copy of the animation
  26444. * @returns Cloned animation
  26445. */
  26446. clone(): Animation;
  26447. /**
  26448. * Sets the key frames of the animation
  26449. * @param values The animation key frames to set
  26450. */
  26451. setKeys(values: Array<IAnimationKey>): void;
  26452. /**
  26453. * Serializes the animation to an object
  26454. * @returns Serialized object
  26455. */
  26456. serialize(): any;
  26457. /**
  26458. * Float animation type
  26459. */
  26460. private static _ANIMATIONTYPE_FLOAT;
  26461. /**
  26462. * Vector3 animation type
  26463. */
  26464. private static _ANIMATIONTYPE_VECTOR3;
  26465. /**
  26466. * Quaternion animation type
  26467. */
  26468. private static _ANIMATIONTYPE_QUATERNION;
  26469. /**
  26470. * Matrix animation type
  26471. */
  26472. private static _ANIMATIONTYPE_MATRIX;
  26473. /**
  26474. * Color3 animation type
  26475. */
  26476. private static _ANIMATIONTYPE_COLOR3;
  26477. /**
  26478. * Vector2 animation type
  26479. */
  26480. private static _ANIMATIONTYPE_VECTOR2;
  26481. /**
  26482. * Size animation type
  26483. */
  26484. private static _ANIMATIONTYPE_SIZE;
  26485. /**
  26486. * Relative Loop Mode
  26487. */
  26488. private static _ANIMATIONLOOPMODE_RELATIVE;
  26489. /**
  26490. * Cycle Loop Mode
  26491. */
  26492. private static _ANIMATIONLOOPMODE_CYCLE;
  26493. /**
  26494. * Constant Loop Mode
  26495. */
  26496. private static _ANIMATIONLOOPMODE_CONSTANT;
  26497. /**
  26498. * Get the float animation type
  26499. */
  26500. static readonly ANIMATIONTYPE_FLOAT: number;
  26501. /**
  26502. * Get the Vector3 animation type
  26503. */
  26504. static readonly ANIMATIONTYPE_VECTOR3: number;
  26505. /**
  26506. * Get the Vector2 animation type
  26507. */
  26508. static readonly ANIMATIONTYPE_VECTOR2: number;
  26509. /**
  26510. * Get the Size animation type
  26511. */
  26512. static readonly ANIMATIONTYPE_SIZE: number;
  26513. /**
  26514. * Get the Quaternion animation type
  26515. */
  26516. static readonly ANIMATIONTYPE_QUATERNION: number;
  26517. /**
  26518. * Get the Matrix animation type
  26519. */
  26520. static readonly ANIMATIONTYPE_MATRIX: number;
  26521. /**
  26522. * Get the Color3 animation type
  26523. */
  26524. static readonly ANIMATIONTYPE_COLOR3: number;
  26525. /**
  26526. * Get the Relative Loop Mode
  26527. */
  26528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26529. /**
  26530. * Get the Cycle Loop Mode
  26531. */
  26532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26533. /**
  26534. * Get the Constant Loop Mode
  26535. */
  26536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26537. /** @hidden */
  26538. static _UniversalLerp(left: any, right: any, amount: number): any;
  26539. /**
  26540. * Parses an animation object and creates an animation
  26541. * @param parsedAnimation Parsed animation object
  26542. * @returns Animation object
  26543. */
  26544. static Parse(parsedAnimation: any): Animation;
  26545. /**
  26546. * Appends the serialized animations from the source animations
  26547. * @param source Source containing the animations
  26548. * @param destination Target to store the animations
  26549. */
  26550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26551. }
  26552. }
  26553. declare module "babylonjs/Materials/Textures/baseTexture" {
  26554. import { Observable } from "babylonjs/Misc/observable";
  26555. import { IAnimatable } from "babylonjs/Misc/tools";
  26556. import { Nullable } from "babylonjs/types";
  26557. import { Scene } from "babylonjs/scene";
  26558. import { Matrix, ISize } from "babylonjs/Maths/math";
  26559. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26561. /**
  26562. * Base class of all the textures in babylon.
  26563. * It groups all the common properties the materials, post process, lights... might need
  26564. * in order to make a correct use of the texture.
  26565. */
  26566. export class BaseTexture implements IAnimatable {
  26567. /**
  26568. * Default anisotropic filtering level for the application.
  26569. * It is set to 4 as a good tradeoff between perf and quality.
  26570. */
  26571. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26572. /**
  26573. * Gets or sets the unique id of the texture
  26574. */
  26575. uniqueId: number;
  26576. /**
  26577. * Define the name of the texture.
  26578. */
  26579. name: string;
  26580. /**
  26581. * Gets or sets an object used to store user defined information.
  26582. */
  26583. metadata: any;
  26584. /**
  26585. * For internal use only. Please do not use.
  26586. */
  26587. reservedDataStore: any;
  26588. private _hasAlpha;
  26589. /**
  26590. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26591. */
  26592. hasAlpha: boolean;
  26593. /**
  26594. * Defines if the alpha value should be determined via the rgb values.
  26595. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26596. */
  26597. getAlphaFromRGB: boolean;
  26598. /**
  26599. * Intensity or strength of the texture.
  26600. * It is commonly used by materials to fine tune the intensity of the texture
  26601. */
  26602. level: number;
  26603. /**
  26604. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26605. * This is part of the texture as textures usually maps to one uv set.
  26606. */
  26607. coordinatesIndex: number;
  26608. private _coordinatesMode;
  26609. /**
  26610. * How a texture is mapped.
  26611. *
  26612. * | Value | Type | Description |
  26613. * | ----- | ----------------------------------- | ----------- |
  26614. * | 0 | EXPLICIT_MODE | |
  26615. * | 1 | SPHERICAL_MODE | |
  26616. * | 2 | PLANAR_MODE | |
  26617. * | 3 | CUBIC_MODE | |
  26618. * | 4 | PROJECTION_MODE | |
  26619. * | 5 | SKYBOX_MODE | |
  26620. * | 6 | INVCUBIC_MODE | |
  26621. * | 7 | EQUIRECTANGULAR_MODE | |
  26622. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26623. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26624. */
  26625. coordinatesMode: number;
  26626. /**
  26627. * | Value | Type | Description |
  26628. * | ----- | ------------------ | ----------- |
  26629. * | 0 | CLAMP_ADDRESSMODE | |
  26630. * | 1 | WRAP_ADDRESSMODE | |
  26631. * | 2 | MIRROR_ADDRESSMODE | |
  26632. */
  26633. wrapU: number;
  26634. /**
  26635. * | Value | Type | Description |
  26636. * | ----- | ------------------ | ----------- |
  26637. * | 0 | CLAMP_ADDRESSMODE | |
  26638. * | 1 | WRAP_ADDRESSMODE | |
  26639. * | 2 | MIRROR_ADDRESSMODE | |
  26640. */
  26641. wrapV: number;
  26642. /**
  26643. * | Value | Type | Description |
  26644. * | ----- | ------------------ | ----------- |
  26645. * | 0 | CLAMP_ADDRESSMODE | |
  26646. * | 1 | WRAP_ADDRESSMODE | |
  26647. * | 2 | MIRROR_ADDRESSMODE | |
  26648. */
  26649. wrapR: number;
  26650. /**
  26651. * With compliant hardware and browser (supporting anisotropic filtering)
  26652. * this defines the level of anisotropic filtering in the texture.
  26653. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26654. */
  26655. anisotropicFilteringLevel: number;
  26656. /**
  26657. * Define if the texture is a cube texture or if false a 2d texture.
  26658. */
  26659. isCube: boolean;
  26660. /**
  26661. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26662. */
  26663. is3D: boolean;
  26664. /**
  26665. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26666. * HDR texture are usually stored in linear space.
  26667. * This only impacts the PBR and Background materials
  26668. */
  26669. gammaSpace: boolean;
  26670. /**
  26671. * Gets whether or not the texture contains RGBD data.
  26672. */
  26673. readonly isRGBD: boolean;
  26674. /**
  26675. * Is Z inverted in the texture (useful in a cube texture).
  26676. */
  26677. invertZ: boolean;
  26678. /**
  26679. * Are mip maps generated for this texture or not.
  26680. */
  26681. readonly noMipmap: boolean;
  26682. /**
  26683. * @hidden
  26684. */
  26685. lodLevelInAlpha: boolean;
  26686. /**
  26687. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26688. */
  26689. lodGenerationOffset: number;
  26690. /**
  26691. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26692. */
  26693. lodGenerationScale: number;
  26694. /**
  26695. * Define if the texture is a render target.
  26696. */
  26697. isRenderTarget: boolean;
  26698. /**
  26699. * Define the unique id of the texture in the scene.
  26700. */
  26701. readonly uid: string;
  26702. /**
  26703. * Return a string representation of the texture.
  26704. * @returns the texture as a string
  26705. */
  26706. toString(): string;
  26707. /**
  26708. * Get the class name of the texture.
  26709. * @returns "BaseTexture"
  26710. */
  26711. getClassName(): string;
  26712. /**
  26713. * Define the list of animation attached to the texture.
  26714. */
  26715. animations: import("babylonjs/Animations/animation").Animation[];
  26716. /**
  26717. * An event triggered when the texture is disposed.
  26718. */
  26719. onDisposeObservable: Observable<BaseTexture>;
  26720. private _onDisposeObserver;
  26721. /**
  26722. * Callback triggered when the texture has been disposed.
  26723. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26724. */
  26725. onDispose: () => void;
  26726. /**
  26727. * Define the current state of the loading sequence when in delayed load mode.
  26728. */
  26729. delayLoadState: number;
  26730. private _scene;
  26731. /** @hidden */
  26732. _texture: Nullable<InternalTexture>;
  26733. private _uid;
  26734. /**
  26735. * Define if the texture is preventinga material to render or not.
  26736. * If not and the texture is not ready, the engine will use a default black texture instead.
  26737. */
  26738. readonly isBlocking: boolean;
  26739. /**
  26740. * Instantiates a new BaseTexture.
  26741. * Base class of all the textures in babylon.
  26742. * It groups all the common properties the materials, post process, lights... might need
  26743. * in order to make a correct use of the texture.
  26744. * @param scene Define the scene the texture blongs to
  26745. */
  26746. constructor(scene: Nullable<Scene>);
  26747. /**
  26748. * Get the scene the texture belongs to.
  26749. * @returns the scene or null if undefined
  26750. */
  26751. getScene(): Nullable<Scene>;
  26752. /**
  26753. * Get the texture transform matrix used to offset tile the texture for istance.
  26754. * @returns the transformation matrix
  26755. */
  26756. getTextureMatrix(): Matrix;
  26757. /**
  26758. * Get the texture reflection matrix used to rotate/transform the reflection.
  26759. * @returns the reflection matrix
  26760. */
  26761. getReflectionTextureMatrix(): Matrix;
  26762. /**
  26763. * Get the underlying lower level texture from Babylon.
  26764. * @returns the insternal texture
  26765. */
  26766. getInternalTexture(): Nullable<InternalTexture>;
  26767. /**
  26768. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26769. * @returns true if ready or not blocking
  26770. */
  26771. isReadyOrNotBlocking(): boolean;
  26772. /**
  26773. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26774. * @returns true if fully ready
  26775. */
  26776. isReady(): boolean;
  26777. private _cachedSize;
  26778. /**
  26779. * Get the size of the texture.
  26780. * @returns the texture size.
  26781. */
  26782. getSize(): ISize;
  26783. /**
  26784. * Get the base size of the texture.
  26785. * It can be different from the size if the texture has been resized for POT for instance
  26786. * @returns the base size
  26787. */
  26788. getBaseSize(): ISize;
  26789. /**
  26790. * Update the sampling mode of the texture.
  26791. * Default is Trilinear mode.
  26792. *
  26793. * | Value | Type | Description |
  26794. * | ----- | ------------------ | ----------- |
  26795. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26796. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26797. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26798. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26799. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26800. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26801. * | 7 | NEAREST_LINEAR | |
  26802. * | 8 | NEAREST_NEAREST | |
  26803. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26804. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26805. * | 11 | LINEAR_LINEAR | |
  26806. * | 12 | LINEAR_NEAREST | |
  26807. *
  26808. * > _mag_: magnification filter (close to the viewer)
  26809. * > _min_: minification filter (far from the viewer)
  26810. * > _mip_: filter used between mip map levels
  26811. *@param samplingMode Define the new sampling mode of the texture
  26812. */
  26813. updateSamplingMode(samplingMode: number): void;
  26814. /**
  26815. * Scales the texture if is `canRescale()`
  26816. * @param ratio the resize factor we want to use to rescale
  26817. */
  26818. scale(ratio: number): void;
  26819. /**
  26820. * Get if the texture can rescale.
  26821. */
  26822. readonly canRescale: boolean;
  26823. /** @hidden */
  26824. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26825. /** @hidden */
  26826. _rebuild(): void;
  26827. /**
  26828. * Triggers the load sequence in delayed load mode.
  26829. */
  26830. delayLoad(): void;
  26831. /**
  26832. * Clones the texture.
  26833. * @returns the cloned texture
  26834. */
  26835. clone(): Nullable<BaseTexture>;
  26836. /**
  26837. * Get the texture underlying type (INT, FLOAT...)
  26838. */
  26839. readonly textureType: number;
  26840. /**
  26841. * Get the texture underlying format (RGB, RGBA...)
  26842. */
  26843. readonly textureFormat: number;
  26844. /**
  26845. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26846. * This will returns an RGBA array buffer containing either in values (0-255) or
  26847. * float values (0-1) depending of the underlying buffer type.
  26848. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26849. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26850. * @param buffer defines a user defined buffer to fill with data (can be null)
  26851. * @returns The Array buffer containing the pixels data.
  26852. */
  26853. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26854. /**
  26855. * Release and destroy the underlying lower level texture aka internalTexture.
  26856. */
  26857. releaseInternalTexture(): void;
  26858. /**
  26859. * Get the polynomial representation of the texture data.
  26860. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26861. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26862. */
  26863. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26864. /** @hidden */
  26865. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26866. /** @hidden */
  26867. readonly _lodTextureMid: Nullable<BaseTexture>;
  26868. /** @hidden */
  26869. readonly _lodTextureLow: Nullable<BaseTexture>;
  26870. /**
  26871. * Dispose the texture and release its associated resources.
  26872. */
  26873. dispose(): void;
  26874. /**
  26875. * Serialize the texture into a JSON representation that can be parsed later on.
  26876. * @returns the JSON representation of the texture
  26877. */
  26878. serialize(): any;
  26879. /**
  26880. * Helper function to be called back once a list of texture contains only ready textures.
  26881. * @param textures Define the list of textures to wait for
  26882. * @param callback Define the callback triggered once the entire list will be ready
  26883. */
  26884. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26885. }
  26886. }
  26887. declare module "babylonjs/Materials/uniformBuffer" {
  26888. import { Nullable, FloatArray } from "babylonjs/types";
  26889. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26890. import { Engine } from "babylonjs/Engines/engine";
  26891. import { Effect } from "babylonjs/Materials/effect";
  26892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26893. /**
  26894. * Uniform buffer objects.
  26895. *
  26896. * Handles blocks of uniform on the GPU.
  26897. *
  26898. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26899. *
  26900. * For more information, please refer to :
  26901. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26902. */
  26903. export class UniformBuffer {
  26904. private _engine;
  26905. private _buffer;
  26906. private _data;
  26907. private _bufferData;
  26908. private _dynamic?;
  26909. private _uniformLocations;
  26910. private _uniformSizes;
  26911. private _uniformLocationPointer;
  26912. private _needSync;
  26913. private _noUBO;
  26914. private _currentEffect;
  26915. private static _MAX_UNIFORM_SIZE;
  26916. private static _tempBuffer;
  26917. /**
  26918. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26919. * This is dynamic to allow compat with webgl 1 and 2.
  26920. * You will need to pass the name of the uniform as well as the value.
  26921. */
  26922. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26923. /**
  26924. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26925. * This is dynamic to allow compat with webgl 1 and 2.
  26926. * You will need to pass the name of the uniform as well as the value.
  26927. */
  26928. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26929. /**
  26930. * Lambda to Update a single float in a uniform buffer.
  26931. * This is dynamic to allow compat with webgl 1 and 2.
  26932. * You will need to pass the name of the uniform as well as the value.
  26933. */
  26934. updateFloat: (name: string, x: number) => void;
  26935. /**
  26936. * Lambda to Update a vec2 of float in a uniform buffer.
  26937. * This is dynamic to allow compat with webgl 1 and 2.
  26938. * You will need to pass the name of the uniform as well as the value.
  26939. */
  26940. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26941. /**
  26942. * Lambda to Update a vec3 of float in a uniform buffer.
  26943. * This is dynamic to allow compat with webgl 1 and 2.
  26944. * You will need to pass the name of the uniform as well as the value.
  26945. */
  26946. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26947. /**
  26948. * Lambda to Update a vec4 of float in a uniform buffer.
  26949. * This is dynamic to allow compat with webgl 1 and 2.
  26950. * You will need to pass the name of the uniform as well as the value.
  26951. */
  26952. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26953. /**
  26954. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26955. * This is dynamic to allow compat with webgl 1 and 2.
  26956. * You will need to pass the name of the uniform as well as the value.
  26957. */
  26958. updateMatrix: (name: string, mat: Matrix) => void;
  26959. /**
  26960. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26961. * This is dynamic to allow compat with webgl 1 and 2.
  26962. * You will need to pass the name of the uniform as well as the value.
  26963. */
  26964. updateVector3: (name: string, vector: Vector3) => void;
  26965. /**
  26966. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26967. * This is dynamic to allow compat with webgl 1 and 2.
  26968. * You will need to pass the name of the uniform as well as the value.
  26969. */
  26970. updateVector4: (name: string, vector: Vector4) => void;
  26971. /**
  26972. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26973. * This is dynamic to allow compat with webgl 1 and 2.
  26974. * You will need to pass the name of the uniform as well as the value.
  26975. */
  26976. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26977. /**
  26978. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26979. * This is dynamic to allow compat with webgl 1 and 2.
  26980. * You will need to pass the name of the uniform as well as the value.
  26981. */
  26982. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26983. /**
  26984. * Instantiates a new Uniform buffer objects.
  26985. *
  26986. * Handles blocks of uniform on the GPU.
  26987. *
  26988. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26989. *
  26990. * For more information, please refer to :
  26991. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26992. * @param engine Define the engine the buffer is associated with
  26993. * @param data Define the data contained in the buffer
  26994. * @param dynamic Define if the buffer is updatable
  26995. */
  26996. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26997. /**
  26998. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26999. * or just falling back on setUniformXXX calls.
  27000. */
  27001. readonly useUbo: boolean;
  27002. /**
  27003. * Indicates if the WebGL underlying uniform buffer is in sync
  27004. * with the javascript cache data.
  27005. */
  27006. readonly isSync: boolean;
  27007. /**
  27008. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27009. * Also, a dynamic UniformBuffer will disable cache verification and always
  27010. * update the underlying WebGL uniform buffer to the GPU.
  27011. * @returns if Dynamic, otherwise false
  27012. */
  27013. isDynamic(): boolean;
  27014. /**
  27015. * The data cache on JS side.
  27016. * @returns the underlying data as a float array
  27017. */
  27018. getData(): Float32Array;
  27019. /**
  27020. * The underlying WebGL Uniform buffer.
  27021. * @returns the webgl buffer
  27022. */
  27023. getBuffer(): Nullable<WebGLBuffer>;
  27024. /**
  27025. * std140 layout specifies how to align data within an UBO structure.
  27026. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27027. * for specs.
  27028. */
  27029. private _fillAlignment;
  27030. /**
  27031. * Adds an uniform in the buffer.
  27032. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27033. * for the layout to be correct !
  27034. * @param name Name of the uniform, as used in the uniform block in the shader.
  27035. * @param size Data size, or data directly.
  27036. */
  27037. addUniform(name: string, size: number | number[]): void;
  27038. /**
  27039. * Adds a Matrix 4x4 to the uniform buffer.
  27040. * @param name Name of the uniform, as used in the uniform block in the shader.
  27041. * @param mat A 4x4 matrix.
  27042. */
  27043. addMatrix(name: string, mat: Matrix): void;
  27044. /**
  27045. * Adds a vec2 to the uniform buffer.
  27046. * @param name Name of the uniform, as used in the uniform block in the shader.
  27047. * @param x Define the x component value of the vec2
  27048. * @param y Define the y component value of the vec2
  27049. */
  27050. addFloat2(name: string, x: number, y: number): void;
  27051. /**
  27052. * Adds a vec3 to the uniform buffer.
  27053. * @param name Name of the uniform, as used in the uniform block in the shader.
  27054. * @param x Define the x component value of the vec3
  27055. * @param y Define the y component value of the vec3
  27056. * @param z Define the z component value of the vec3
  27057. */
  27058. addFloat3(name: string, x: number, y: number, z: number): void;
  27059. /**
  27060. * Adds a vec3 to the uniform buffer.
  27061. * @param name Name of the uniform, as used in the uniform block in the shader.
  27062. * @param color Define the vec3 from a Color
  27063. */
  27064. addColor3(name: string, color: Color3): void;
  27065. /**
  27066. * Adds a vec4 to the uniform buffer.
  27067. * @param name Name of the uniform, as used in the uniform block in the shader.
  27068. * @param color Define the rgb components from a Color
  27069. * @param alpha Define the a component of the vec4
  27070. */
  27071. addColor4(name: string, color: Color3, alpha: number): void;
  27072. /**
  27073. * Adds a vec3 to the uniform buffer.
  27074. * @param name Name of the uniform, as used in the uniform block in the shader.
  27075. * @param vector Define the vec3 components from a Vector
  27076. */
  27077. addVector3(name: string, vector: Vector3): void;
  27078. /**
  27079. * Adds a Matrix 3x3 to the uniform buffer.
  27080. * @param name Name of the uniform, as used in the uniform block in the shader.
  27081. */
  27082. addMatrix3x3(name: string): void;
  27083. /**
  27084. * Adds a Matrix 2x2 to the uniform buffer.
  27085. * @param name Name of the uniform, as used in the uniform block in the shader.
  27086. */
  27087. addMatrix2x2(name: string): void;
  27088. /**
  27089. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27090. */
  27091. create(): void;
  27092. /** @hidden */
  27093. _rebuild(): void;
  27094. /**
  27095. * Updates the WebGL Uniform Buffer on the GPU.
  27096. * If the `dynamic` flag is set to true, no cache comparison is done.
  27097. * Otherwise, the buffer will be updated only if the cache differs.
  27098. */
  27099. update(): void;
  27100. /**
  27101. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27102. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27103. * @param data Define the flattened data
  27104. * @param size Define the size of the data.
  27105. */
  27106. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27107. private _updateMatrix3x3ForUniform;
  27108. private _updateMatrix3x3ForEffect;
  27109. private _updateMatrix2x2ForEffect;
  27110. private _updateMatrix2x2ForUniform;
  27111. private _updateFloatForEffect;
  27112. private _updateFloatForUniform;
  27113. private _updateFloat2ForEffect;
  27114. private _updateFloat2ForUniform;
  27115. private _updateFloat3ForEffect;
  27116. private _updateFloat3ForUniform;
  27117. private _updateFloat4ForEffect;
  27118. private _updateFloat4ForUniform;
  27119. private _updateMatrixForEffect;
  27120. private _updateMatrixForUniform;
  27121. private _updateVector3ForEffect;
  27122. private _updateVector3ForUniform;
  27123. private _updateVector4ForEffect;
  27124. private _updateVector4ForUniform;
  27125. private _updateColor3ForEffect;
  27126. private _updateColor3ForUniform;
  27127. private _updateColor4ForEffect;
  27128. private _updateColor4ForUniform;
  27129. /**
  27130. * Sets a sampler uniform on the effect.
  27131. * @param name Define the name of the sampler.
  27132. * @param texture Define the texture to set in the sampler
  27133. */
  27134. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27135. /**
  27136. * Directly updates the value of the uniform in the cache AND on the GPU.
  27137. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27138. * @param data Define the flattened data
  27139. */
  27140. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27141. /**
  27142. * Binds this uniform buffer to an effect.
  27143. * @param effect Define the effect to bind the buffer to
  27144. * @param name Name of the uniform block in the shader.
  27145. */
  27146. bindToEffect(effect: Effect, name: string): void;
  27147. /**
  27148. * Disposes the uniform buffer.
  27149. */
  27150. dispose(): void;
  27151. }
  27152. }
  27153. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  27154. import { Nullable } from "babylonjs/types";
  27155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27156. /**
  27157. * This represents the required contract to create a new type of texture loader.
  27158. */
  27159. export interface IInternalTextureLoader {
  27160. /**
  27161. * Defines wether the loader supports cascade loading the different faces.
  27162. */
  27163. supportCascades: boolean;
  27164. /**
  27165. * This returns if the loader support the current file information.
  27166. * @param extension defines the file extension of the file being loaded
  27167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27168. * @param fallback defines the fallback internal texture if any
  27169. * @param isBase64 defines whether the texture is encoded as a base64
  27170. * @param isBuffer defines whether the texture data are stored as a buffer
  27171. * @returns true if the loader can load the specified file
  27172. */
  27173. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  27174. /**
  27175. * Transform the url before loading if required.
  27176. * @param rootUrl the url of the texture
  27177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27178. * @returns the transformed texture
  27179. */
  27180. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  27181. /**
  27182. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  27183. * @param rootUrl the url of the texture
  27184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  27185. * @returns the fallback texture
  27186. */
  27187. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  27188. /**
  27189. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  27190. * @param data contains the texture data
  27191. * @param texture defines the BabylonJS internal texture
  27192. * @param createPolynomials will be true if polynomials have been requested
  27193. * @param onLoad defines the callback to trigger once the texture is ready
  27194. * @param onError defines the callback to trigger in case of error
  27195. */
  27196. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  27197. /**
  27198. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  27199. * @param data contains the texture data
  27200. * @param texture defines the BabylonJS internal texture
  27201. * @param callback defines the method to call once ready to upload
  27202. */
  27203. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  27204. }
  27205. }
  27206. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  27207. import { Scene } from "babylonjs/scene";
  27208. import { Engine } from "babylonjs/Engines/engine";
  27209. import { Texture } from "babylonjs/Materials/Textures/texture";
  27210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27211. /**
  27212. * Creation options of the multi render target texture.
  27213. */
  27214. export interface IMultiRenderTargetOptions {
  27215. /**
  27216. * Define if the texture needs to create mip maps after render.
  27217. */
  27218. generateMipMaps?: boolean;
  27219. /**
  27220. * Define the types of all the draw buffers we want to create
  27221. */
  27222. types?: number[];
  27223. /**
  27224. * Define the sampling modes of all the draw buffers we want to create
  27225. */
  27226. samplingModes?: number[];
  27227. /**
  27228. * Define if a depth buffer is required
  27229. */
  27230. generateDepthBuffer?: boolean;
  27231. /**
  27232. * Define if a stencil buffer is required
  27233. */
  27234. generateStencilBuffer?: boolean;
  27235. /**
  27236. * Define if a depth texture is required instead of a depth buffer
  27237. */
  27238. generateDepthTexture?: boolean;
  27239. /**
  27240. * Define the number of desired draw buffers
  27241. */
  27242. textureCount?: number;
  27243. /**
  27244. * Define if aspect ratio should be adapted to the texture or stay the scene one
  27245. */
  27246. doNotChangeAspectRatio?: boolean;
  27247. /**
  27248. * Define the default type of the buffers we are creating
  27249. */
  27250. defaultType?: number;
  27251. }
  27252. /**
  27253. * A multi render target, like a render target provides the ability to render to a texture.
  27254. * Unlike the render target, it can render to several draw buffers in one draw.
  27255. * This is specially interesting in deferred rendering or for any effects requiring more than
  27256. * just one color from a single pass.
  27257. */
  27258. export class MultiRenderTarget extends RenderTargetTexture {
  27259. private _internalTextures;
  27260. private _textures;
  27261. private _multiRenderTargetOptions;
  27262. /**
  27263. * Get if draw buffers are currently supported by the used hardware and browser.
  27264. */
  27265. readonly isSupported: boolean;
  27266. /**
  27267. * Get the list of textures generated by the multi render target.
  27268. */
  27269. readonly textures: Texture[];
  27270. /**
  27271. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  27272. */
  27273. readonly depthTexture: Texture;
  27274. /**
  27275. * Set the wrapping mode on U of all the textures we are rendering to.
  27276. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27277. */
  27278. wrapU: number;
  27279. /**
  27280. * Set the wrapping mode on V of all the textures we are rendering to.
  27281. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27282. */
  27283. wrapV: number;
  27284. /**
  27285. * Instantiate a new multi render target texture.
  27286. * A multi render target, like a render target provides the ability to render to a texture.
  27287. * Unlike the render target, it can render to several draw buffers in one draw.
  27288. * This is specially interesting in deferred rendering or for any effects requiring more than
  27289. * just one color from a single pass.
  27290. * @param name Define the name of the texture
  27291. * @param size Define the size of the buffers to render to
  27292. * @param count Define the number of target we are rendering into
  27293. * @param scene Define the scene the texture belongs to
  27294. * @param options Define the options used to create the multi render target
  27295. */
  27296. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27297. /** @hidden */
  27298. _rebuild(): void;
  27299. private _createInternalTextures;
  27300. private _createTextures;
  27301. /**
  27302. * Define the number of samples used if MSAA is enabled.
  27303. */
  27304. samples: number;
  27305. /**
  27306. * Resize all the textures in the multi render target.
  27307. * Be carrefull as it will recreate all the data in the new texture.
  27308. * @param size Define the new size
  27309. */
  27310. resize(size: any): void;
  27311. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27312. /**
  27313. * Dispose the render targets and their associated resources
  27314. */
  27315. dispose(): void;
  27316. /**
  27317. * Release all the underlying texture used as draw buffers.
  27318. */
  27319. releaseInternalTextures(): void;
  27320. }
  27321. }
  27322. declare module "babylonjs/Audio/analyser" {
  27323. import { Scene } from "babylonjs/scene";
  27324. /**
  27325. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27327. */
  27328. export class Analyser {
  27329. /**
  27330. * Gets or sets the smoothing
  27331. * @ignorenaming
  27332. */
  27333. SMOOTHING: number;
  27334. /**
  27335. * Gets or sets the FFT table size
  27336. * @ignorenaming
  27337. */
  27338. FFT_SIZE: number;
  27339. /**
  27340. * Gets or sets the bar graph amplitude
  27341. * @ignorenaming
  27342. */
  27343. BARGRAPHAMPLITUDE: number;
  27344. /**
  27345. * Gets or sets the position of the debug canvas
  27346. * @ignorenaming
  27347. */
  27348. DEBUGCANVASPOS: {
  27349. x: number;
  27350. y: number;
  27351. };
  27352. /**
  27353. * Gets or sets the debug canvas size
  27354. * @ignorenaming
  27355. */
  27356. DEBUGCANVASSIZE: {
  27357. width: number;
  27358. height: number;
  27359. };
  27360. private _byteFreqs;
  27361. private _byteTime;
  27362. private _floatFreqs;
  27363. private _webAudioAnalyser;
  27364. private _debugCanvas;
  27365. private _debugCanvasContext;
  27366. private _scene;
  27367. private _registerFunc;
  27368. private _audioEngine;
  27369. /**
  27370. * Creates a new analyser
  27371. * @param scene defines hosting scene
  27372. */
  27373. constructor(scene: Scene);
  27374. /**
  27375. * Get the number of data values you will have to play with for the visualization
  27376. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27377. * @returns a number
  27378. */
  27379. getFrequencyBinCount(): number;
  27380. /**
  27381. * Gets the current frequency data as a byte array
  27382. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27383. * @returns a Uint8Array
  27384. */
  27385. getByteFrequencyData(): Uint8Array;
  27386. /**
  27387. * Gets the current waveform as a byte array
  27388. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27389. * @returns a Uint8Array
  27390. */
  27391. getByteTimeDomainData(): Uint8Array;
  27392. /**
  27393. * Gets the current frequency data as a float array
  27394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27395. * @returns a Float32Array
  27396. */
  27397. getFloatFrequencyData(): Float32Array;
  27398. /**
  27399. * Renders the debug canvas
  27400. */
  27401. drawDebugCanvas(): void;
  27402. /**
  27403. * Stops rendering the debug canvas and removes it
  27404. */
  27405. stopDebugCanvas(): void;
  27406. /**
  27407. * Connects two audio nodes
  27408. * @param inputAudioNode defines first node to connect
  27409. * @param outputAudioNode defines second node to connect
  27410. */
  27411. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27412. /**
  27413. * Releases all associated resources
  27414. */
  27415. dispose(): void;
  27416. }
  27417. }
  27418. declare module "babylonjs/Audio/audioEngine" {
  27419. import { IDisposable } from "babylonjs/scene";
  27420. import { Analyser } from "babylonjs/Audio/analyser";
  27421. import { Nullable } from "babylonjs/types";
  27422. import { Observable } from "babylonjs/Misc/observable";
  27423. /**
  27424. * This represents an audio engine and it is responsible
  27425. * to play, synchronize and analyse sounds throughout the application.
  27426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27427. */
  27428. export interface IAudioEngine extends IDisposable {
  27429. /**
  27430. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27431. */
  27432. readonly canUseWebAudio: boolean;
  27433. /**
  27434. * Gets the current AudioContext if available.
  27435. */
  27436. readonly audioContext: Nullable<AudioContext>;
  27437. /**
  27438. * The master gain node defines the global audio volume of your audio engine.
  27439. */
  27440. readonly masterGain: GainNode;
  27441. /**
  27442. * Gets whether or not mp3 are supported by your browser.
  27443. */
  27444. readonly isMP3supported: boolean;
  27445. /**
  27446. * Gets whether or not ogg are supported by your browser.
  27447. */
  27448. readonly isOGGsupported: boolean;
  27449. /**
  27450. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27451. * @ignoreNaming
  27452. */
  27453. WarnedWebAudioUnsupported: boolean;
  27454. /**
  27455. * Defines if the audio engine relies on a custom unlocked button.
  27456. * In this case, the embedded button will not be displayed.
  27457. */
  27458. useCustomUnlockedButton: boolean;
  27459. /**
  27460. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27461. */
  27462. readonly unlocked: boolean;
  27463. /**
  27464. * Event raised when audio has been unlocked on the browser.
  27465. */
  27466. onAudioUnlockedObservable: Observable<AudioEngine>;
  27467. /**
  27468. * Event raised when audio has been locked on the browser.
  27469. */
  27470. onAudioLockedObservable: Observable<AudioEngine>;
  27471. /**
  27472. * Flags the audio engine in Locked state.
  27473. * This happens due to new browser policies preventing audio to autoplay.
  27474. */
  27475. lock(): void;
  27476. /**
  27477. * Unlocks the audio engine once a user action has been done on the dom.
  27478. * This is helpful to resume play once browser policies have been satisfied.
  27479. */
  27480. unlock(): void;
  27481. }
  27482. /**
  27483. * This represents the default audio engine used in babylon.
  27484. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27486. */
  27487. export class AudioEngine implements IAudioEngine {
  27488. private _audioContext;
  27489. private _audioContextInitialized;
  27490. private _muteButton;
  27491. private _hostElement;
  27492. /**
  27493. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27494. */
  27495. canUseWebAudio: boolean;
  27496. /**
  27497. * The master gain node defines the global audio volume of your audio engine.
  27498. */
  27499. masterGain: GainNode;
  27500. /**
  27501. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27502. * @ignoreNaming
  27503. */
  27504. WarnedWebAudioUnsupported: boolean;
  27505. /**
  27506. * Gets whether or not mp3 are supported by your browser.
  27507. */
  27508. isMP3supported: boolean;
  27509. /**
  27510. * Gets whether or not ogg are supported by your browser.
  27511. */
  27512. isOGGsupported: boolean;
  27513. /**
  27514. * Gets whether audio has been unlocked on the device.
  27515. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27516. * a user interaction has happened.
  27517. */
  27518. unlocked: boolean;
  27519. /**
  27520. * Defines if the audio engine relies on a custom unlocked button.
  27521. * In this case, the embedded button will not be displayed.
  27522. */
  27523. useCustomUnlockedButton: boolean;
  27524. /**
  27525. * Event raised when audio has been unlocked on the browser.
  27526. */
  27527. onAudioUnlockedObservable: Observable<AudioEngine>;
  27528. /**
  27529. * Event raised when audio has been locked on the browser.
  27530. */
  27531. onAudioLockedObservable: Observable<AudioEngine>;
  27532. /**
  27533. * Gets the current AudioContext if available.
  27534. */
  27535. readonly audioContext: Nullable<AudioContext>;
  27536. private _connectedAnalyser;
  27537. /**
  27538. * Instantiates a new audio engine.
  27539. *
  27540. * There should be only one per page as some browsers restrict the number
  27541. * of audio contexts you can create.
  27542. * @param hostElement defines the host element where to display the mute icon if necessary
  27543. */
  27544. constructor(hostElement?: Nullable<HTMLElement>);
  27545. /**
  27546. * Flags the audio engine in Locked state.
  27547. * This happens due to new browser policies preventing audio to autoplay.
  27548. */
  27549. lock(): void;
  27550. /**
  27551. * Unlocks the audio engine once a user action has been done on the dom.
  27552. * This is helpful to resume play once browser policies have been satisfied.
  27553. */
  27554. unlock(): void;
  27555. private _resumeAudioContext;
  27556. private _initializeAudioContext;
  27557. private _tryToRun;
  27558. private _triggerRunningState;
  27559. private _triggerSuspendedState;
  27560. private _displayMuteButton;
  27561. private _moveButtonToTopLeft;
  27562. private _onResize;
  27563. private _hideMuteButton;
  27564. /**
  27565. * Destroy and release the resources associated with the audio ccontext.
  27566. */
  27567. dispose(): void;
  27568. /**
  27569. * Gets the global volume sets on the master gain.
  27570. * @returns the global volume if set or -1 otherwise
  27571. */
  27572. getGlobalVolume(): number;
  27573. /**
  27574. * Sets the global volume of your experience (sets on the master gain).
  27575. * @param newVolume Defines the new global volume of the application
  27576. */
  27577. setGlobalVolume(newVolume: number): void;
  27578. /**
  27579. * Connect the audio engine to an audio analyser allowing some amazing
  27580. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27582. * @param analyser The analyser to connect to the engine
  27583. */
  27584. connectToAnalyser(analyser: Analyser): void;
  27585. }
  27586. }
  27587. declare module "babylonjs/Loading/loadingScreen" {
  27588. /**
  27589. * Interface used to present a loading screen while loading a scene
  27590. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27591. */
  27592. export interface ILoadingScreen {
  27593. /**
  27594. * Function called to display the loading screen
  27595. */
  27596. displayLoadingUI: () => void;
  27597. /**
  27598. * Function called to hide the loading screen
  27599. */
  27600. hideLoadingUI: () => void;
  27601. /**
  27602. * Gets or sets the color to use for the background
  27603. */
  27604. loadingUIBackgroundColor: string;
  27605. /**
  27606. * Gets or sets the text to display while loading
  27607. */
  27608. loadingUIText: string;
  27609. }
  27610. /**
  27611. * Class used for the default loading screen
  27612. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27613. */
  27614. export class DefaultLoadingScreen implements ILoadingScreen {
  27615. private _renderingCanvas;
  27616. private _loadingText;
  27617. private _loadingDivBackgroundColor;
  27618. private _loadingDiv;
  27619. private _loadingTextDiv;
  27620. /**
  27621. * Creates a new default loading screen
  27622. * @param _renderingCanvas defines the canvas used to render the scene
  27623. * @param _loadingText defines the default text to display
  27624. * @param _loadingDivBackgroundColor defines the default background color
  27625. */
  27626. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27627. /**
  27628. * Function called to display the loading screen
  27629. */
  27630. displayLoadingUI(): void;
  27631. /**
  27632. * Function called to hide the loading screen
  27633. */
  27634. hideLoadingUI(): void;
  27635. /**
  27636. * Gets or sets the text to display while loading
  27637. */
  27638. loadingUIText: string;
  27639. /**
  27640. * Gets or sets the color to use for the background
  27641. */
  27642. loadingUIBackgroundColor: string;
  27643. private _resizeLoadingUI;
  27644. }
  27645. }
  27646. declare module "babylonjs/Materials/Textures/videoTexture" {
  27647. import { Observable } from "babylonjs/Misc/observable";
  27648. import { Nullable } from "babylonjs/types";
  27649. import { Scene } from "babylonjs/scene";
  27650. import { Texture } from "babylonjs/Materials/Textures/texture";
  27651. /**
  27652. * Settings for finer control over video usage
  27653. */
  27654. export interface VideoTextureSettings {
  27655. /**
  27656. * Applies `autoplay` to video, if specified
  27657. */
  27658. autoPlay?: boolean;
  27659. /**
  27660. * Applies `loop` to video, if specified
  27661. */
  27662. loop?: boolean;
  27663. /**
  27664. * Automatically updates internal texture from video at every frame in the render loop
  27665. */
  27666. autoUpdateTexture: boolean;
  27667. /**
  27668. * Image src displayed during the video loading or until the user interacts with the video.
  27669. */
  27670. poster?: string;
  27671. }
  27672. /**
  27673. * If you want to display a video in your scene, this is the special texture for that.
  27674. * This special texture works similar to other textures, with the exception of a few parameters.
  27675. * @see https://doc.babylonjs.com/how_to/video_texture
  27676. */
  27677. export class VideoTexture extends Texture {
  27678. /**
  27679. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27680. */
  27681. readonly autoUpdateTexture: boolean;
  27682. /**
  27683. * The video instance used by the texture internally
  27684. */
  27685. readonly video: HTMLVideoElement;
  27686. private _onUserActionRequestedObservable;
  27687. /**
  27688. * Event triggerd when a dom action is required by the user to play the video.
  27689. * This happens due to recent changes in browser policies preventing video to auto start.
  27690. */
  27691. readonly onUserActionRequestedObservable: Observable<Texture>;
  27692. private _generateMipMaps;
  27693. private _engine;
  27694. private _stillImageCaptured;
  27695. private _displayingPosterTexture;
  27696. private _settings;
  27697. private _createInternalTextureOnEvent;
  27698. /**
  27699. * Creates a video texture.
  27700. * If you want to display a video in your scene, this is the special texture for that.
  27701. * This special texture works similar to other textures, with the exception of a few parameters.
  27702. * @see https://doc.babylonjs.com/how_to/video_texture
  27703. * @param name optional name, will detect from video source, if not defined
  27704. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27705. * @param scene is obviously the current scene.
  27706. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27707. * @param invertY is false by default but can be used to invert video on Y axis
  27708. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27709. * @param settings allows finer control over video usage
  27710. */
  27711. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27712. private _getName;
  27713. private _getVideo;
  27714. private _createInternalTexture;
  27715. private reset;
  27716. /**
  27717. * @hidden Internal method to initiate `update`.
  27718. */
  27719. _rebuild(): void;
  27720. /**
  27721. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27722. */
  27723. update(): void;
  27724. /**
  27725. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27726. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27727. */
  27728. updateTexture(isVisible: boolean): void;
  27729. protected _updateInternalTexture: () => void;
  27730. /**
  27731. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27732. * @param url New url.
  27733. */
  27734. updateURL(url: string): void;
  27735. /**
  27736. * Dispose the texture and release its associated resources.
  27737. */
  27738. dispose(): void;
  27739. /**
  27740. * Creates a video texture straight from your WebCam video feed.
  27741. * @param scene Define the scene the texture should be created in
  27742. * @param onReady Define a callback to triggered once the texture will be ready
  27743. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27744. */
  27745. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27746. minWidth: number;
  27747. maxWidth: number;
  27748. minHeight: number;
  27749. maxHeight: number;
  27750. deviceId: string;
  27751. }): void;
  27752. }
  27753. }
  27754. declare module "babylonjs/Engines/engine" {
  27755. import { Observable } from "babylonjs/Misc/observable";
  27756. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27757. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27758. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27759. import { Camera } from "babylonjs/Cameras/camera";
  27760. import { Scene } from "babylonjs/scene";
  27761. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27762. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27763. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27764. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27765. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27766. import { Material } from "babylonjs/Materials/material";
  27767. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27770. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27771. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27772. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27773. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27774. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27775. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27778. /**
  27779. * Interface for attribute information associated with buffer instanciation
  27780. */
  27781. export class InstancingAttributeInfo {
  27782. /**
  27783. * Index/offset of the attribute in the vertex shader
  27784. */
  27785. index: number;
  27786. /**
  27787. * size of the attribute, 1, 2, 3 or 4
  27788. */
  27789. attributeSize: number;
  27790. /**
  27791. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27792. * default is FLOAT
  27793. */
  27794. attribyteType: number;
  27795. /**
  27796. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27797. */
  27798. normalized: boolean;
  27799. /**
  27800. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27801. */
  27802. offset: number;
  27803. /**
  27804. * Name of the GLSL attribute, for debugging purpose only
  27805. */
  27806. attributeName: string;
  27807. }
  27808. /**
  27809. * Define options used to create a depth texture
  27810. */
  27811. export class DepthTextureCreationOptions {
  27812. /** Specifies whether or not a stencil should be allocated in the texture */
  27813. generateStencil?: boolean;
  27814. /** Specifies whether or not bilinear filtering is enable on the texture */
  27815. bilinearFiltering?: boolean;
  27816. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27817. comparisonFunction?: number;
  27818. /** Specifies if the created texture is a cube texture */
  27819. isCube?: boolean;
  27820. }
  27821. /**
  27822. * Class used to describe the capabilities of the engine relatively to the current browser
  27823. */
  27824. export class EngineCapabilities {
  27825. /** Maximum textures units per fragment shader */
  27826. maxTexturesImageUnits: number;
  27827. /** Maximum texture units per vertex shader */
  27828. maxVertexTextureImageUnits: number;
  27829. /** Maximum textures units in the entire pipeline */
  27830. maxCombinedTexturesImageUnits: number;
  27831. /** Maximum texture size */
  27832. maxTextureSize: number;
  27833. /** Maximum cube texture size */
  27834. maxCubemapTextureSize: number;
  27835. /** Maximum render texture size */
  27836. maxRenderTextureSize: number;
  27837. /** Maximum number of vertex attributes */
  27838. maxVertexAttribs: number;
  27839. /** Maximum number of varyings */
  27840. maxVaryingVectors: number;
  27841. /** Maximum number of uniforms per vertex shader */
  27842. maxVertexUniformVectors: number;
  27843. /** Maximum number of uniforms per fragment shader */
  27844. maxFragmentUniformVectors: number;
  27845. /** Defines if standard derivates (dx/dy) are supported */
  27846. standardDerivatives: boolean;
  27847. /** Defines if s3tc texture compression is supported */
  27848. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27849. /** Defines if pvrtc texture compression is supported */
  27850. pvrtc: any;
  27851. /** Defines if etc1 texture compression is supported */
  27852. etc1: any;
  27853. /** Defines if etc2 texture compression is supported */
  27854. etc2: any;
  27855. /** Defines if astc texture compression is supported */
  27856. astc: any;
  27857. /** Defines if float textures are supported */
  27858. textureFloat: boolean;
  27859. /** Defines if vertex array objects are supported */
  27860. vertexArrayObject: boolean;
  27861. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27862. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27863. /** Gets the maximum level of anisotropy supported */
  27864. maxAnisotropy: number;
  27865. /** Defines if instancing is supported */
  27866. instancedArrays: boolean;
  27867. /** Defines if 32 bits indices are supported */
  27868. uintIndices: boolean;
  27869. /** Defines if high precision shaders are supported */
  27870. highPrecisionShaderSupported: boolean;
  27871. /** Defines if depth reading in the fragment shader is supported */
  27872. fragmentDepthSupported: boolean;
  27873. /** Defines if float texture linear filtering is supported*/
  27874. textureFloatLinearFiltering: boolean;
  27875. /** Defines if rendering to float textures is supported */
  27876. textureFloatRender: boolean;
  27877. /** Defines if half float textures are supported*/
  27878. textureHalfFloat: boolean;
  27879. /** Defines if half float texture linear filtering is supported*/
  27880. textureHalfFloatLinearFiltering: boolean;
  27881. /** Defines if rendering to half float textures is supported */
  27882. textureHalfFloatRender: boolean;
  27883. /** Defines if textureLOD shader command is supported */
  27884. textureLOD: boolean;
  27885. /** Defines if draw buffers extension is supported */
  27886. drawBuffersExtension: boolean;
  27887. /** Defines if depth textures are supported */
  27888. depthTextureExtension: boolean;
  27889. /** Defines if float color buffer are supported */
  27890. colorBufferFloat: boolean;
  27891. /** Gets disjoint timer query extension (null if not supported) */
  27892. timerQuery: EXT_disjoint_timer_query;
  27893. /** Defines if timestamp can be used with timer query */
  27894. canUseTimestampForTimerQuery: boolean;
  27895. /** Function used to let the system compiles shaders in background */
  27896. parallelShaderCompile: {
  27897. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27898. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27899. COMPLETION_STATUS_KHR: number;
  27900. };
  27901. }
  27902. /** Interface defining initialization parameters for Engine class */
  27903. export interface EngineOptions extends WebGLContextAttributes {
  27904. /**
  27905. * Defines if the engine should no exceed a specified device ratio
  27906. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27907. */
  27908. limitDeviceRatio?: number;
  27909. /**
  27910. * Defines if webvr should be enabled automatically
  27911. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27912. */
  27913. autoEnableWebVR?: boolean;
  27914. /**
  27915. * Defines if webgl2 should be turned off even if supported
  27916. * @see http://doc.babylonjs.com/features/webgl2
  27917. */
  27918. disableWebGL2Support?: boolean;
  27919. /**
  27920. * Defines if webaudio should be initialized as well
  27921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27922. */
  27923. audioEngine?: boolean;
  27924. /**
  27925. * Defines if animations should run using a deterministic lock step
  27926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27927. */
  27928. deterministicLockstep?: boolean;
  27929. /** Defines the maximum steps to use with deterministic lock step mode */
  27930. lockstepMaxSteps?: number;
  27931. /**
  27932. * Defines that engine should ignore context lost events
  27933. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27934. */
  27935. doNotHandleContextLost?: boolean;
  27936. /**
  27937. * Defines that engine should ignore modifying touch action attribute and style
  27938. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27939. */
  27940. doNotHandleTouchAction?: boolean;
  27941. }
  27942. /**
  27943. * Defines the interface used by display changed events
  27944. */
  27945. export interface IDisplayChangedEventArgs {
  27946. /** Gets the vrDisplay object (if any) */
  27947. vrDisplay: Nullable<any>;
  27948. /** Gets a boolean indicating if webVR is supported */
  27949. vrSupported: boolean;
  27950. }
  27951. /**
  27952. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27953. */
  27954. export class Engine {
  27955. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27956. static ExceptionList: ({
  27957. key: string;
  27958. capture: string;
  27959. captureConstraint: number;
  27960. targets: string[];
  27961. } | {
  27962. key: string;
  27963. capture: null;
  27964. captureConstraint: null;
  27965. targets: string[];
  27966. })[];
  27967. /** Gets the list of created engines */
  27968. static readonly Instances: Engine[];
  27969. /**
  27970. * Gets the latest created engine
  27971. */
  27972. static readonly LastCreatedEngine: Nullable<Engine>;
  27973. /**
  27974. * Gets the latest created scene
  27975. */
  27976. static readonly LastCreatedScene: Nullable<Scene>;
  27977. /**
  27978. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27979. * @param flag defines which part of the materials must be marked as dirty
  27980. * @param predicate defines a predicate used to filter which materials should be affected
  27981. */
  27982. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27983. /**
  27984. * Hidden
  27985. */
  27986. static _TextureLoaders: IInternalTextureLoader[];
  27987. /** Defines that alpha blending is disabled */
  27988. static readonly ALPHA_DISABLE: number;
  27989. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27990. static readonly ALPHA_ADD: number;
  27991. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27992. static readonly ALPHA_COMBINE: number;
  27993. /** Defines that alpha blending to DEST - SRC * DEST */
  27994. static readonly ALPHA_SUBTRACT: number;
  27995. /** Defines that alpha blending to SRC * DEST */
  27996. static readonly ALPHA_MULTIPLY: number;
  27997. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27998. static readonly ALPHA_MAXIMIZED: number;
  27999. /** Defines that alpha blending to SRC + DEST */
  28000. static readonly ALPHA_ONEONE: number;
  28001. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28002. static readonly ALPHA_PREMULTIPLIED: number;
  28003. /**
  28004. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28005. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28006. */
  28007. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28008. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28009. static readonly ALPHA_INTERPOLATE: number;
  28010. /**
  28011. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28012. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28013. */
  28014. static readonly ALPHA_SCREENMODE: number;
  28015. /** Defines that the ressource is not delayed*/
  28016. static readonly DELAYLOADSTATE_NONE: number;
  28017. /** Defines that the ressource was successfully delay loaded */
  28018. static readonly DELAYLOADSTATE_LOADED: number;
  28019. /** Defines that the ressource is currently delay loading */
  28020. static readonly DELAYLOADSTATE_LOADING: number;
  28021. /** Defines that the ressource is delayed and has not started loading */
  28022. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28024. static readonly NEVER: number;
  28025. /** 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 */
  28026. static readonly ALWAYS: number;
  28027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28028. static readonly LESS: number;
  28029. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28030. static readonly EQUAL: number;
  28031. /** 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 */
  28032. static readonly LEQUAL: number;
  28033. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28034. static readonly GREATER: number;
  28035. /** 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 */
  28036. static readonly GEQUAL: number;
  28037. /** 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 */
  28038. static readonly NOTEQUAL: number;
  28039. /** Passed to stencilOperation to specify that stencil value must be kept */
  28040. static readonly KEEP: number;
  28041. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28042. static readonly REPLACE: number;
  28043. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28044. static readonly INCR: number;
  28045. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28046. static readonly DECR: number;
  28047. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28048. static readonly INVERT: number;
  28049. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28050. static readonly INCR_WRAP: number;
  28051. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28052. static readonly DECR_WRAP: number;
  28053. /** Texture is not repeating outside of 0..1 UVs */
  28054. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28055. /** Texture is repeating outside of 0..1 UVs */
  28056. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28057. /** Texture is repeating and mirrored */
  28058. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28059. /** ALPHA */
  28060. static readonly TEXTUREFORMAT_ALPHA: number;
  28061. /** LUMINANCE */
  28062. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28063. /** LUMINANCE_ALPHA */
  28064. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28065. /** RGB */
  28066. static readonly TEXTUREFORMAT_RGB: number;
  28067. /** RGBA */
  28068. static readonly TEXTUREFORMAT_RGBA: number;
  28069. /** RED */
  28070. static readonly TEXTUREFORMAT_RED: number;
  28071. /** RED (2nd reference) */
  28072. static readonly TEXTUREFORMAT_R: number;
  28073. /** RG */
  28074. static readonly TEXTUREFORMAT_RG: number;
  28075. /** RED_INTEGER */
  28076. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28077. /** RED_INTEGER (2nd reference) */
  28078. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28079. /** RG_INTEGER */
  28080. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28081. /** RGB_INTEGER */
  28082. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28083. /** RGBA_INTEGER */
  28084. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28085. /** UNSIGNED_BYTE */
  28086. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28087. /** UNSIGNED_BYTE (2nd reference) */
  28088. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28089. /** FLOAT */
  28090. static readonly TEXTURETYPE_FLOAT: number;
  28091. /** HALF_FLOAT */
  28092. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28093. /** BYTE */
  28094. static readonly TEXTURETYPE_BYTE: number;
  28095. /** SHORT */
  28096. static readonly TEXTURETYPE_SHORT: number;
  28097. /** UNSIGNED_SHORT */
  28098. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28099. /** INT */
  28100. static readonly TEXTURETYPE_INT: number;
  28101. /** UNSIGNED_INT */
  28102. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28103. /** UNSIGNED_SHORT_4_4_4_4 */
  28104. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28105. /** UNSIGNED_SHORT_5_5_5_1 */
  28106. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28107. /** UNSIGNED_SHORT_5_6_5 */
  28108. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28109. /** UNSIGNED_INT_2_10_10_10_REV */
  28110. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28111. /** UNSIGNED_INT_24_8 */
  28112. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28113. /** UNSIGNED_INT_10F_11F_11F_REV */
  28114. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28115. /** UNSIGNED_INT_5_9_9_9_REV */
  28116. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28117. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28118. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28119. /** nearest is mag = nearest and min = nearest and mip = linear */
  28120. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28122. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28123. /** Trilinear is mag = linear and min = linear and mip = linear */
  28124. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28125. /** nearest is mag = nearest and min = nearest and mip = linear */
  28126. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28127. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28128. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28129. /** Trilinear is mag = linear and min = linear and mip = linear */
  28130. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28131. /** mag = nearest and min = nearest and mip = nearest */
  28132. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28133. /** mag = nearest and min = linear and mip = nearest */
  28134. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28135. /** mag = nearest and min = linear and mip = linear */
  28136. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28137. /** mag = nearest and min = linear and mip = none */
  28138. static readonly TEXTURE_NEAREST_LINEAR: number;
  28139. /** mag = nearest and min = nearest and mip = none */
  28140. static readonly TEXTURE_NEAREST_NEAREST: number;
  28141. /** mag = linear and min = nearest and mip = nearest */
  28142. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28143. /** mag = linear and min = nearest and mip = linear */
  28144. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28145. /** mag = linear and min = linear and mip = none */
  28146. static readonly TEXTURE_LINEAR_LINEAR: number;
  28147. /** mag = linear and min = nearest and mip = none */
  28148. static readonly TEXTURE_LINEAR_NEAREST: number;
  28149. /** Explicit coordinates mode */
  28150. static readonly TEXTURE_EXPLICIT_MODE: number;
  28151. /** Spherical coordinates mode */
  28152. static readonly TEXTURE_SPHERICAL_MODE: number;
  28153. /** Planar coordinates mode */
  28154. static readonly TEXTURE_PLANAR_MODE: number;
  28155. /** Cubic coordinates mode */
  28156. static readonly TEXTURE_CUBIC_MODE: number;
  28157. /** Projection coordinates mode */
  28158. static readonly TEXTURE_PROJECTION_MODE: number;
  28159. /** Skybox coordinates mode */
  28160. static readonly TEXTURE_SKYBOX_MODE: number;
  28161. /** Inverse Cubic coordinates mode */
  28162. static readonly TEXTURE_INVCUBIC_MODE: number;
  28163. /** Equirectangular coordinates mode */
  28164. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28165. /** Equirectangular Fixed coordinates mode */
  28166. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28167. /** Equirectangular Fixed Mirrored coordinates mode */
  28168. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28169. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28170. static readonly SCALEMODE_FLOOR: number;
  28171. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28172. static readonly SCALEMODE_NEAREST: number;
  28173. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28174. static readonly SCALEMODE_CEILING: number;
  28175. /**
  28176. * Returns the current version of the framework
  28177. */
  28178. static readonly Version: string;
  28179. /**
  28180. * Returns a string describing the current engine
  28181. */
  28182. readonly description: string;
  28183. /**
  28184. * Gets or sets the epsilon value used by collision engine
  28185. */
  28186. static CollisionsEpsilon: number;
  28187. /**
  28188. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28189. */
  28190. static ShadersRepository: string;
  28191. /**
  28192. * Method called to create the default loading screen.
  28193. * This can be overriden in your own app.
  28194. * @param canvas The rendering canvas element
  28195. * @returns The loading screen
  28196. */
  28197. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28198. /**
  28199. * Method called to create the default rescale post process on each engine.
  28200. */
  28201. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28202. /**
  28203. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28204. */
  28205. forcePOTTextures: boolean;
  28206. /**
  28207. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28208. */
  28209. isFullscreen: boolean;
  28210. /**
  28211. * Gets a boolean indicating if the pointer is currently locked
  28212. */
  28213. isPointerLock: boolean;
  28214. /**
  28215. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28216. */
  28217. cullBackFaces: boolean;
  28218. /**
  28219. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28220. */
  28221. renderEvenInBackground: boolean;
  28222. /**
  28223. * Gets or sets a boolean indicating that cache can be kept between frames
  28224. */
  28225. preventCacheWipeBetweenFrames: boolean;
  28226. /**
  28227. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28228. **/
  28229. enableOfflineSupport: boolean;
  28230. /**
  28231. * 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)
  28232. **/
  28233. disableManifestCheck: boolean;
  28234. /**
  28235. * Gets the list of created scenes
  28236. */
  28237. scenes: Scene[];
  28238. /**
  28239. * Event raised when a new scene is created
  28240. */
  28241. onNewSceneAddedObservable: Observable<Scene>;
  28242. /**
  28243. * Gets the list of created postprocesses
  28244. */
  28245. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28246. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28247. validateShaderPrograms: boolean;
  28248. /**
  28249. * Observable event triggered each time the rendering canvas is resized
  28250. */
  28251. onResizeObservable: Observable<Engine>;
  28252. /**
  28253. * Observable event triggered each time the canvas loses focus
  28254. */
  28255. onCanvasBlurObservable: Observable<Engine>;
  28256. /**
  28257. * Observable event triggered each time the canvas gains focus
  28258. */
  28259. onCanvasFocusObservable: Observable<Engine>;
  28260. /**
  28261. * Observable event triggered each time the canvas receives pointerout event
  28262. */
  28263. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28264. /**
  28265. * Observable event triggered before each texture is initialized
  28266. */
  28267. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28268. private _vrDisplay;
  28269. private _vrSupported;
  28270. private _oldSize;
  28271. private _oldHardwareScaleFactor;
  28272. private _vrExclusivePointerMode;
  28273. private _webVRInitPromise;
  28274. /**
  28275. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28276. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28277. */
  28278. readonly isInVRExclusivePointerMode: boolean;
  28279. /**
  28280. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28281. */
  28282. disableUniformBuffers: boolean;
  28283. /** @hidden */
  28284. _uniformBuffers: UniformBuffer[];
  28285. /**
  28286. * Gets a boolean indicating that the engine supports uniform buffers
  28287. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28288. */
  28289. readonly supportsUniformBuffers: boolean;
  28290. /**
  28291. * Observable raised when the engine begins a new frame
  28292. */
  28293. onBeginFrameObservable: Observable<Engine>;
  28294. /**
  28295. * If set, will be used to request the next animation frame for the render loop
  28296. */
  28297. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28298. /**
  28299. * Observable raised when the engine ends the current frame
  28300. */
  28301. onEndFrameObservable: Observable<Engine>;
  28302. /**
  28303. * Observable raised when the engine is about to compile a shader
  28304. */
  28305. onBeforeShaderCompilationObservable: Observable<Engine>;
  28306. /**
  28307. * Observable raised when the engine has jsut compiled a shader
  28308. */
  28309. onAfterShaderCompilationObservable: Observable<Engine>;
  28310. /** @hidden */
  28311. _gl: WebGLRenderingContext;
  28312. private _renderingCanvas;
  28313. private _windowIsBackground;
  28314. private _webGLVersion;
  28315. /**
  28316. * Gets a boolean indicating that only power of 2 textures are supported
  28317. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28318. */
  28319. readonly needPOTTextures: boolean;
  28320. /** @hidden */
  28321. _badOS: boolean;
  28322. /** @hidden */
  28323. _badDesktopOS: boolean;
  28324. /**
  28325. * Gets or sets a value indicating if we want to disable texture binding optimization.
  28326. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  28327. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  28328. */
  28329. disableTextureBindingOptimization: boolean;
  28330. /**
  28331. * Gets the audio engine
  28332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28333. * @ignorenaming
  28334. */
  28335. static audioEngine: IAudioEngine;
  28336. /**
  28337. * Default AudioEngine factory responsible of creating the Audio Engine.
  28338. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28339. */
  28340. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28341. /**
  28342. * Default offline support factory responsible of creating a tool used to store data locally.
  28343. * By default, this will create a Database object if the workload has been embedded.
  28344. */
  28345. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28346. private _onFocus;
  28347. private _onBlur;
  28348. private _onCanvasPointerOut;
  28349. private _onCanvasBlur;
  28350. private _onCanvasFocus;
  28351. private _onFullscreenChange;
  28352. private _onPointerLockChange;
  28353. private _onVRDisplayPointerRestricted;
  28354. private _onVRDisplayPointerUnrestricted;
  28355. private _onVrDisplayConnect;
  28356. private _onVrDisplayDisconnect;
  28357. private _onVrDisplayPresentChange;
  28358. /**
  28359. * Observable signaled when VR display mode changes
  28360. */
  28361. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28362. /**
  28363. * Observable signaled when VR request present is complete
  28364. */
  28365. onVRRequestPresentComplete: Observable<boolean>;
  28366. /**
  28367. * Observable signaled when VR request present starts
  28368. */
  28369. onVRRequestPresentStart: Observable<Engine>;
  28370. private _hardwareScalingLevel;
  28371. /** @hidden */
  28372. protected _caps: EngineCapabilities;
  28373. private _pointerLockRequested;
  28374. private _isStencilEnable;
  28375. private _colorWrite;
  28376. private _loadingScreen;
  28377. /** @hidden */
  28378. _drawCalls: PerfCounter;
  28379. /** @hidden */
  28380. _textureCollisions: PerfCounter;
  28381. private _glVersion;
  28382. private _glRenderer;
  28383. private _glVendor;
  28384. private _videoTextureSupported;
  28385. private _renderingQueueLaunched;
  28386. private _activeRenderLoops;
  28387. private _deterministicLockstep;
  28388. private _lockstepMaxSteps;
  28389. /**
  28390. * Observable signaled when a context lost event is raised
  28391. */
  28392. onContextLostObservable: Observable<Engine>;
  28393. /**
  28394. * Observable signaled when a context restored event is raised
  28395. */
  28396. onContextRestoredObservable: Observable<Engine>;
  28397. private _onContextLost;
  28398. private _onContextRestored;
  28399. private _contextWasLost;
  28400. private _doNotHandleContextLost;
  28401. /**
  28402. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28404. */
  28405. doNotHandleContextLost: boolean;
  28406. private _performanceMonitor;
  28407. private _fps;
  28408. private _deltaTime;
  28409. /**
  28410. * Turn this value on if you want to pause FPS computation when in background
  28411. */
  28412. disablePerformanceMonitorInBackground: boolean;
  28413. /**
  28414. * Gets the performance monitor attached to this engine
  28415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28416. */
  28417. readonly performanceMonitor: PerformanceMonitor;
  28418. /** @hidden */
  28419. protected _depthCullingState: _DepthCullingState;
  28420. /** @hidden */
  28421. protected _stencilState: _StencilState;
  28422. /** @hidden */
  28423. protected _alphaState: _AlphaState;
  28424. /** @hidden */
  28425. protected _alphaMode: number;
  28426. protected _internalTexturesCache: InternalTexture[];
  28427. /** @hidden */
  28428. protected _activeChannel: number;
  28429. private _currentTextureChannel;
  28430. /** @hidden */
  28431. protected _boundTexturesCache: {
  28432. [key: string]: Nullable<InternalTexture>;
  28433. };
  28434. /** @hidden */
  28435. protected _currentEffect: Nullable<Effect>;
  28436. /** @hidden */
  28437. protected _currentProgram: Nullable<WebGLProgram>;
  28438. private _compiledEffects;
  28439. private _vertexAttribArraysEnabled;
  28440. /** @hidden */
  28441. protected _cachedViewport: Nullable<Viewport>;
  28442. private _cachedVertexArrayObject;
  28443. /** @hidden */
  28444. protected _cachedVertexBuffers: any;
  28445. /** @hidden */
  28446. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28447. /** @hidden */
  28448. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28449. /** @hidden */
  28450. protected _currentRenderTarget: Nullable<InternalTexture>;
  28451. private _uintIndicesCurrentlySet;
  28452. private _currentBoundBuffer;
  28453. /** @hidden */
  28454. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28455. private _currentBufferPointers;
  28456. private _currentInstanceLocations;
  28457. private _currentInstanceBuffers;
  28458. private _textureUnits;
  28459. private _firstBoundInternalTextureTracker;
  28460. private _lastBoundInternalTextureTracker;
  28461. private _workingCanvas;
  28462. private _workingContext;
  28463. private _rescalePostProcess;
  28464. private _dummyFramebuffer;
  28465. private _externalData;
  28466. private _bindedRenderFunction;
  28467. private _vaoRecordInProgress;
  28468. private _mustWipeVertexAttributes;
  28469. private _emptyTexture;
  28470. private _emptyCubeTexture;
  28471. private _emptyTexture3D;
  28472. /** @hidden */
  28473. _frameHandler: number;
  28474. private _nextFreeTextureSlots;
  28475. private _maxSimultaneousTextures;
  28476. private _activeRequests;
  28477. private _texturesSupported;
  28478. private _textureFormatInUse;
  28479. /**
  28480. * Gets the list of texture formats supported
  28481. */
  28482. readonly texturesSupported: Array<string>;
  28483. /**
  28484. * Gets the list of texture formats in use
  28485. */
  28486. readonly textureFormatInUse: Nullable<string>;
  28487. /**
  28488. * Gets the current viewport
  28489. */
  28490. readonly currentViewport: Nullable<Viewport>;
  28491. /**
  28492. * Gets the default empty texture
  28493. */
  28494. readonly emptyTexture: InternalTexture;
  28495. /**
  28496. * Gets the default empty 3D texture
  28497. */
  28498. readonly emptyTexture3D: InternalTexture;
  28499. /**
  28500. * Gets the default empty cube texture
  28501. */
  28502. readonly emptyCubeTexture: InternalTexture;
  28503. /**
  28504. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28505. */
  28506. readonly premultipliedAlpha: boolean;
  28507. /**
  28508. * Creates a new engine
  28509. * @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
  28510. * @param antialias defines enable antialiasing (default: false)
  28511. * @param options defines further options to be sent to the getContext() function
  28512. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28513. */
  28514. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28515. private _disableTouchAction;
  28516. private _rebuildInternalTextures;
  28517. private _rebuildEffects;
  28518. /**
  28519. * Gets a boolean indicating if all created effects are ready
  28520. * @returns true if all effects are ready
  28521. */
  28522. areAllEffectsReady(): boolean;
  28523. private _rebuildBuffers;
  28524. private _initGLContext;
  28525. /**
  28526. * Gets version of the current webGL context
  28527. */
  28528. readonly webGLVersion: number;
  28529. /**
  28530. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28531. */
  28532. readonly isStencilEnable: boolean;
  28533. private _prepareWorkingCanvas;
  28534. /**
  28535. * Reset the texture cache to empty state
  28536. */
  28537. resetTextureCache(): void;
  28538. /**
  28539. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28540. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28541. * @returns true if engine is in deterministic lock step mode
  28542. */
  28543. isDeterministicLockStep(): boolean;
  28544. /**
  28545. * Gets the max steps when engine is running in deterministic lock step
  28546. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28547. * @returns the max steps
  28548. */
  28549. getLockstepMaxSteps(): number;
  28550. /**
  28551. * Gets an object containing information about the current webGL context
  28552. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28553. */
  28554. getGlInfo(): {
  28555. vendor: string;
  28556. renderer: string;
  28557. version: string;
  28558. };
  28559. /**
  28560. * Gets current aspect ratio
  28561. * @param camera defines the camera to use to get the aspect ratio
  28562. * @param useScreen defines if screen size must be used (or the current render target if any)
  28563. * @returns a number defining the aspect ratio
  28564. */
  28565. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28566. /**
  28567. * Gets current screen aspect ratio
  28568. * @returns a number defining the aspect ratio
  28569. */
  28570. getScreenAspectRatio(): number;
  28571. /**
  28572. * Gets the current render width
  28573. * @param useScreen defines if screen size must be used (or the current render target if any)
  28574. * @returns a number defining the current render width
  28575. */
  28576. getRenderWidth(useScreen?: boolean): number;
  28577. /**
  28578. * Gets the current render height
  28579. * @param useScreen defines if screen size must be used (or the current render target if any)
  28580. * @returns a number defining the current render height
  28581. */
  28582. getRenderHeight(useScreen?: boolean): number;
  28583. /**
  28584. * Gets the HTML canvas attached with the current webGL context
  28585. * @returns a HTML canvas
  28586. */
  28587. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28588. /**
  28589. * Gets the client rect of the HTML canvas attached with the current webGL context
  28590. * @returns a client rectanglee
  28591. */
  28592. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28593. /**
  28594. * Defines the hardware scaling level.
  28595. * By default the hardware scaling level is computed from the window device ratio.
  28596. * 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.
  28597. * @param level defines the level to use
  28598. */
  28599. setHardwareScalingLevel(level: number): void;
  28600. /**
  28601. * Gets the current hardware scaling level.
  28602. * By default the hardware scaling level is computed from the window device ratio.
  28603. * 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.
  28604. * @returns a number indicating the current hardware scaling level
  28605. */
  28606. getHardwareScalingLevel(): number;
  28607. /**
  28608. * Gets the list of loaded textures
  28609. * @returns an array containing all loaded textures
  28610. */
  28611. getLoadedTexturesCache(): InternalTexture[];
  28612. /**
  28613. * Gets the object containing all engine capabilities
  28614. * @returns the EngineCapabilities object
  28615. */
  28616. getCaps(): EngineCapabilities;
  28617. /**
  28618. * Gets the current depth function
  28619. * @returns a number defining the depth function
  28620. */
  28621. getDepthFunction(): Nullable<number>;
  28622. /**
  28623. * Sets the current depth function
  28624. * @param depthFunc defines the function to use
  28625. */
  28626. setDepthFunction(depthFunc: number): void;
  28627. /**
  28628. * Sets the current depth function to GREATER
  28629. */
  28630. setDepthFunctionToGreater(): void;
  28631. /**
  28632. * Sets the current depth function to GEQUAL
  28633. */
  28634. setDepthFunctionToGreaterOrEqual(): void;
  28635. /**
  28636. * Sets the current depth function to LESS
  28637. */
  28638. setDepthFunctionToLess(): void;
  28639. /**
  28640. * Sets the current depth function to LEQUAL
  28641. */
  28642. setDepthFunctionToLessOrEqual(): void;
  28643. /**
  28644. * Gets a boolean indicating if stencil buffer is enabled
  28645. * @returns the current stencil buffer state
  28646. */
  28647. getStencilBuffer(): boolean;
  28648. /**
  28649. * Enable or disable the stencil buffer
  28650. * @param enable defines if the stencil buffer must be enabled or disabled
  28651. */
  28652. setStencilBuffer(enable: boolean): void;
  28653. /**
  28654. * Gets the current stencil mask
  28655. * @returns a number defining the new stencil mask to use
  28656. */
  28657. getStencilMask(): number;
  28658. /**
  28659. * Sets the current stencil mask
  28660. * @param mask defines the new stencil mask to use
  28661. */
  28662. setStencilMask(mask: number): void;
  28663. /**
  28664. * Gets the current stencil function
  28665. * @returns a number defining the stencil function to use
  28666. */
  28667. getStencilFunction(): number;
  28668. /**
  28669. * Gets the current stencil reference value
  28670. * @returns a number defining the stencil reference value to use
  28671. */
  28672. getStencilFunctionReference(): number;
  28673. /**
  28674. * Gets the current stencil mask
  28675. * @returns a number defining the stencil mask to use
  28676. */
  28677. getStencilFunctionMask(): number;
  28678. /**
  28679. * Sets the current stencil function
  28680. * @param stencilFunc defines the new stencil function to use
  28681. */
  28682. setStencilFunction(stencilFunc: number): void;
  28683. /**
  28684. * Sets the current stencil reference
  28685. * @param reference defines the new stencil reference to use
  28686. */
  28687. setStencilFunctionReference(reference: number): void;
  28688. /**
  28689. * Sets the current stencil mask
  28690. * @param mask defines the new stencil mask to use
  28691. */
  28692. setStencilFunctionMask(mask: number): void;
  28693. /**
  28694. * Gets the current stencil operation when stencil fails
  28695. * @returns a number defining stencil operation to use when stencil fails
  28696. */
  28697. getStencilOperationFail(): number;
  28698. /**
  28699. * Gets the current stencil operation when depth fails
  28700. * @returns a number defining stencil operation to use when depth fails
  28701. */
  28702. getStencilOperationDepthFail(): number;
  28703. /**
  28704. * Gets the current stencil operation when stencil passes
  28705. * @returns a number defining stencil operation to use when stencil passes
  28706. */
  28707. getStencilOperationPass(): number;
  28708. /**
  28709. * Sets the stencil operation to use when stencil fails
  28710. * @param operation defines the stencil operation to use when stencil fails
  28711. */
  28712. setStencilOperationFail(operation: number): void;
  28713. /**
  28714. * Sets the stencil operation to use when depth fails
  28715. * @param operation defines the stencil operation to use when depth fails
  28716. */
  28717. setStencilOperationDepthFail(operation: number): void;
  28718. /**
  28719. * Sets the stencil operation to use when stencil passes
  28720. * @param operation defines the stencil operation to use when stencil passes
  28721. */
  28722. setStencilOperationPass(operation: number): void;
  28723. /**
  28724. * Sets a boolean indicating if the dithering state is enabled or disabled
  28725. * @param value defines the dithering state
  28726. */
  28727. setDitheringState(value: boolean): void;
  28728. /**
  28729. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28730. * @param value defines the rasterizer state
  28731. */
  28732. setRasterizerState(value: boolean): void;
  28733. /**
  28734. * stop executing a render loop function and remove it from the execution array
  28735. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28736. */
  28737. stopRenderLoop(renderFunction?: () => void): void;
  28738. /** @hidden */
  28739. _renderLoop(): void;
  28740. /**
  28741. * Register and execute a render loop. The engine can have more than one render function
  28742. * @param renderFunction defines the function to continuously execute
  28743. */
  28744. runRenderLoop(renderFunction: () => void): void;
  28745. /**
  28746. * Toggle full screen mode
  28747. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28748. */
  28749. switchFullscreen(requestPointerLock: boolean): void;
  28750. /**
  28751. * Clear the current render buffer or the current render target (if any is set up)
  28752. * @param color defines the color to use
  28753. * @param backBuffer defines if the back buffer must be cleared
  28754. * @param depth defines if the depth buffer must be cleared
  28755. * @param stencil defines if the stencil buffer must be cleared
  28756. */
  28757. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28758. /**
  28759. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28760. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28761. * @param y defines the y-coordinate of the corner of the clear rectangle
  28762. * @param width defines the width of the clear rectangle
  28763. * @param height defines the height of the clear rectangle
  28764. * @param clearColor defines the clear color
  28765. */
  28766. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28767. /**
  28768. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28769. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28770. * @param y defines the y-coordinate of the corner of the clear rectangle
  28771. * @param width defines the width of the clear rectangle
  28772. * @param height defines the height of the clear rectangle
  28773. */
  28774. enableScissor(x: number, y: number, width: number, height: number): void;
  28775. /**
  28776. * Disable previously set scissor test rectangle
  28777. */
  28778. disableScissor(): void;
  28779. private _viewportCached;
  28780. /** @hidden */
  28781. _viewport(x: number, y: number, width: number, height: number): void;
  28782. /**
  28783. * Set the WebGL's viewport
  28784. * @param viewport defines the viewport element to be used
  28785. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28786. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28787. */
  28788. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28789. /**
  28790. * Directly set the WebGL Viewport
  28791. * @param x defines the x coordinate of the viewport (in screen space)
  28792. * @param y defines the y coordinate of the viewport (in screen space)
  28793. * @param width defines the width of the viewport (in screen space)
  28794. * @param height defines the height of the viewport (in screen space)
  28795. * @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
  28796. */
  28797. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28798. /**
  28799. * Begin a new frame
  28800. */
  28801. beginFrame(): void;
  28802. /**
  28803. * Enf the current frame
  28804. */
  28805. endFrame(): void;
  28806. /**
  28807. * Resize the view according to the canvas' size
  28808. */
  28809. resize(): void;
  28810. /**
  28811. * Force a specific size of the canvas
  28812. * @param width defines the new canvas' width
  28813. * @param height defines the new canvas' height
  28814. */
  28815. setSize(width: number, height: number): void;
  28816. /**
  28817. * Gets a boolean indicating if a webVR device was detected
  28818. * @returns true if a webVR device was detected
  28819. */
  28820. isVRDevicePresent(): boolean;
  28821. /**
  28822. * Gets the current webVR device
  28823. * @returns the current webVR device (or null)
  28824. */
  28825. getVRDevice(): any;
  28826. /**
  28827. * Initializes a webVR display and starts listening to display change events
  28828. * The onVRDisplayChangedObservable will be notified upon these changes
  28829. * @returns The onVRDisplayChangedObservable
  28830. */
  28831. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28832. /**
  28833. * Initializes a webVR display and starts listening to display change events
  28834. * The onVRDisplayChangedObservable will be notified upon these changes
  28835. * @returns A promise containing a VRDisplay and if vr is supported
  28836. */
  28837. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28838. /**
  28839. * Call this function to switch to webVR mode
  28840. * Will do nothing if webVR is not supported or if there is no webVR device
  28841. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28842. */
  28843. enableVR(): void;
  28844. /**
  28845. * Call this function to leave webVR mode
  28846. * Will do nothing if webVR is not supported or if there is no webVR device
  28847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28848. */
  28849. disableVR(): void;
  28850. private _onVRFullScreenTriggered;
  28851. private _getVRDisplaysAsync;
  28852. /**
  28853. * Binds the frame buffer to the specified texture.
  28854. * @param texture The texture to render to or null for the default canvas
  28855. * @param faceIndex The face of the texture to render to in case of cube texture
  28856. * @param requiredWidth The width of the target to render to
  28857. * @param requiredHeight The height of the target to render to
  28858. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28859. * @param depthStencilTexture The depth stencil texture to use to render
  28860. * @param lodLevel defines le lod level to bind to the frame buffer
  28861. */
  28862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28863. private bindUnboundFramebuffer;
  28864. /**
  28865. * Unbind the current render target texture from the webGL context
  28866. * @param texture defines the render target texture to unbind
  28867. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28868. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28869. */
  28870. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28871. /**
  28872. * Unbind a list of render target textures from the webGL context
  28873. * This is used only when drawBuffer extension or webGL2 are active
  28874. * @param textures defines the render target textures to unbind
  28875. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28876. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28877. */
  28878. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28879. /**
  28880. * Force the mipmap generation for the given render target texture
  28881. * @param texture defines the render target texture to use
  28882. */
  28883. generateMipMapsForCubemap(texture: InternalTexture): void;
  28884. /**
  28885. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28886. */
  28887. flushFramebuffer(): void;
  28888. /**
  28889. * Unbind the current render target and bind the default framebuffer
  28890. */
  28891. restoreDefaultFramebuffer(): void;
  28892. /**
  28893. * Create an uniform buffer
  28894. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28895. * @param elements defines the content of the uniform buffer
  28896. * @returns the webGL uniform buffer
  28897. */
  28898. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28899. /**
  28900. * Create a dynamic uniform buffer
  28901. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28902. * @param elements defines the content of the uniform buffer
  28903. * @returns the webGL uniform buffer
  28904. */
  28905. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28906. /**
  28907. * Update an existing uniform buffer
  28908. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28909. * @param uniformBuffer defines the target uniform buffer
  28910. * @param elements defines the content to update
  28911. * @param offset defines the offset in the uniform buffer where update should start
  28912. * @param count defines the size of the data to update
  28913. */
  28914. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28915. private _resetVertexBufferBinding;
  28916. /**
  28917. * Creates a vertex buffer
  28918. * @param data the data for the vertex buffer
  28919. * @returns the new WebGL static buffer
  28920. */
  28921. createVertexBuffer(data: DataArray): WebGLBuffer;
  28922. /**
  28923. * Creates a dynamic vertex buffer
  28924. * @param data the data for the dynamic vertex buffer
  28925. * @returns the new WebGL dynamic buffer
  28926. */
  28927. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28928. /**
  28929. * Update a dynamic index buffer
  28930. * @param indexBuffer defines the target index buffer
  28931. * @param indices defines the data to update
  28932. * @param offset defines the offset in the target index buffer where update should start
  28933. */
  28934. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28935. /**
  28936. * Updates a dynamic vertex buffer.
  28937. * @param vertexBuffer the vertex buffer to update
  28938. * @param data the data used to update the vertex buffer
  28939. * @param byteOffset the byte offset of the data
  28940. * @param byteLength the byte length of the data
  28941. */
  28942. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28943. private _resetIndexBufferBinding;
  28944. /**
  28945. * Creates a new index buffer
  28946. * @param indices defines the content of the index buffer
  28947. * @param updatable defines if the index buffer must be updatable
  28948. * @returns a new webGL buffer
  28949. */
  28950. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28951. /**
  28952. * Bind a webGL buffer to the webGL context
  28953. * @param buffer defines the buffer to bind
  28954. */
  28955. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28956. /**
  28957. * Bind an uniform buffer to the current webGL context
  28958. * @param buffer defines the buffer to bind
  28959. */
  28960. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28961. /**
  28962. * Bind a buffer to the current webGL context at a given location
  28963. * @param buffer defines the buffer to bind
  28964. * @param location defines the index where to bind the buffer
  28965. */
  28966. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28967. /**
  28968. * Bind a specific block at a given index in a specific shader program
  28969. * @param shaderProgram defines the shader program
  28970. * @param blockName defines the block name
  28971. * @param index defines the index where to bind the block
  28972. */
  28973. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28974. private bindIndexBuffer;
  28975. private bindBuffer;
  28976. /**
  28977. * update the bound buffer with the given data
  28978. * @param data defines the data to update
  28979. */
  28980. updateArrayBuffer(data: Float32Array): void;
  28981. private _vertexAttribPointer;
  28982. private _bindIndexBufferWithCache;
  28983. private _bindVertexBuffersAttributes;
  28984. /**
  28985. * Records a vertex array object
  28986. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28987. * @param vertexBuffers defines the list of vertex buffers to store
  28988. * @param indexBuffer defines the index buffer to store
  28989. * @param effect defines the effect to store
  28990. * @returns the new vertex array object
  28991. */
  28992. recordVertexArrayObject(vertexBuffers: {
  28993. [key: string]: VertexBuffer;
  28994. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28995. /**
  28996. * Bind a specific vertex array object
  28997. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28998. * @param vertexArrayObject defines the vertex array object to bind
  28999. * @param indexBuffer defines the index buffer to bind
  29000. */
  29001. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  29002. /**
  29003. * Bind webGl buffers directly to the webGL context
  29004. * @param vertexBuffer defines the vertex buffer to bind
  29005. * @param indexBuffer defines the index buffer to bind
  29006. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29007. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29008. * @param effect defines the effect associated with the vertex buffer
  29009. */
  29010. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29011. private _unbindVertexArrayObject;
  29012. /**
  29013. * Bind a list of vertex buffers to the webGL context
  29014. * @param vertexBuffers defines the list of vertex buffers to bind
  29015. * @param indexBuffer defines the index buffer to bind
  29016. * @param effect defines the effect associated with the vertex buffers
  29017. */
  29018. bindBuffers(vertexBuffers: {
  29019. [key: string]: Nullable<VertexBuffer>;
  29020. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  29021. /**
  29022. * Unbind all instance attributes
  29023. */
  29024. unbindInstanceAttributes(): void;
  29025. /**
  29026. * Release and free the memory of a vertex array object
  29027. * @param vao defines the vertex array object to delete
  29028. */
  29029. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29030. /** @hidden */
  29031. _releaseBuffer(buffer: WebGLBuffer): boolean;
  29032. /**
  29033. * Creates a webGL buffer to use with instanciation
  29034. * @param capacity defines the size of the buffer
  29035. * @returns the webGL buffer
  29036. */
  29037. createInstancesBuffer(capacity: number): WebGLBuffer;
  29038. /**
  29039. * Delete a webGL buffer used with instanciation
  29040. * @param buffer defines the webGL buffer to delete
  29041. */
  29042. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29043. /**
  29044. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29045. * @param instancesBuffer defines the webGL buffer to update and bind
  29046. * @param data defines the data to store in the buffer
  29047. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29048. */
  29049. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29050. /**
  29051. * Apply all cached states (depth, culling, stencil and alpha)
  29052. */
  29053. applyStates(): void;
  29054. /**
  29055. * Send a draw order
  29056. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29057. * @param indexStart defines the starting index
  29058. * @param indexCount defines the number of index to draw
  29059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29060. */
  29061. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29062. /**
  29063. * Draw a list of points
  29064. * @param verticesStart defines the index of first vertex to draw
  29065. * @param verticesCount defines the count of vertices to draw
  29066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29067. */
  29068. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29069. /**
  29070. * Draw a list of unindexed primitives
  29071. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29072. * @param verticesStart defines the index of first vertex to draw
  29073. * @param verticesCount defines the count of vertices to draw
  29074. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29075. */
  29076. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29077. /**
  29078. * Draw a list of indexed primitives
  29079. * @param fillMode defines the primitive to use
  29080. * @param indexStart defines the starting index
  29081. * @param indexCount defines the number of index to draw
  29082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29083. */
  29084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29085. /**
  29086. * Draw a list of unindexed primitives
  29087. * @param fillMode defines the primitive to use
  29088. * @param verticesStart defines the index of first vertex to draw
  29089. * @param verticesCount defines the count of vertices to draw
  29090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29091. */
  29092. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29093. private _drawMode;
  29094. /** @hidden */
  29095. _releaseEffect(effect: Effect): void;
  29096. /** @hidden */
  29097. _deleteProgram(program: WebGLProgram): void;
  29098. /**
  29099. * Create a new effect (used to store vertex/fragment shaders)
  29100. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29101. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29102. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29103. * @param samplers defines an array of string used to represent textures
  29104. * @param defines defines the string containing the defines to use to compile the shaders
  29105. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29106. * @param onCompiled defines a function to call when the effect creation is successful
  29107. * @param onError defines a function to call when the effect creation has failed
  29108. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29109. * @returns the new Effect
  29110. */
  29111. 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;
  29112. private _compileShader;
  29113. private _compileRawShader;
  29114. /**
  29115. * Directly creates a webGL program
  29116. * @param vertexCode defines the vertex shader code to use
  29117. * @param fragmentCode defines the fragment shader code to use
  29118. * @param context defines the webGL context to use (if not set, the current one will be used)
  29119. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29120. * @returns the new webGL program
  29121. */
  29122. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29123. /**
  29124. * Creates a webGL program
  29125. * @param vertexCode defines the vertex shader code to use
  29126. * @param fragmentCode defines the fragment shader code to use
  29127. * @param defines defines the string containing the defines to use to compile the shaders
  29128. * @param context defines the webGL context to use (if not set, the current one will be used)
  29129. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29130. * @returns the new webGL program
  29131. */
  29132. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29133. private _createShaderProgram;
  29134. private _finalizeProgram;
  29135. /** @hidden */
  29136. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  29137. /** @hidden */
  29138. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  29139. /**
  29140. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29141. * @param shaderProgram defines the webGL program to use
  29142. * @param uniformsNames defines the list of uniform names
  29143. * @returns an array of webGL uniform locations
  29144. */
  29145. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29146. /**
  29147. * Gets the lsit of active attributes for a given webGL program
  29148. * @param shaderProgram defines the webGL program to use
  29149. * @param attributesNames defines the list of attribute names to get
  29150. * @returns an array of indices indicating the offset of each attribute
  29151. */
  29152. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  29153. /**
  29154. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29155. * @param effect defines the effect to activate
  29156. */
  29157. enableEffect(effect: Nullable<Effect>): void;
  29158. /**
  29159. * Set the value of an uniform to an array of int32
  29160. * @param uniform defines the webGL uniform location where to store the value
  29161. * @param array defines the array of int32 to store
  29162. */
  29163. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29164. /**
  29165. * Set the value of an uniform to an array of int32 (stored as vec2)
  29166. * @param uniform defines the webGL uniform location where to store the value
  29167. * @param array defines the array of int32 to store
  29168. */
  29169. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29170. /**
  29171. * Set the value of an uniform to an array of int32 (stored as vec3)
  29172. * @param uniform defines the webGL uniform location where to store the value
  29173. * @param array defines the array of int32 to store
  29174. */
  29175. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29176. /**
  29177. * Set the value of an uniform to an array of int32 (stored as vec4)
  29178. * @param uniform defines the webGL uniform location where to store the value
  29179. * @param array defines the array of int32 to store
  29180. */
  29181. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29182. /**
  29183. * Set the value of an uniform to an array of float32
  29184. * @param uniform defines the webGL uniform location where to store the value
  29185. * @param array defines the array of float32 to store
  29186. */
  29187. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29188. /**
  29189. * Set the value of an uniform to an array of float32 (stored as vec2)
  29190. * @param uniform defines the webGL uniform location where to store the value
  29191. * @param array defines the array of float32 to store
  29192. */
  29193. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29194. /**
  29195. * Set the value of an uniform to an array of float32 (stored as vec3)
  29196. * @param uniform defines the webGL uniform location where to store the value
  29197. * @param array defines the array of float32 to store
  29198. */
  29199. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29200. /**
  29201. * Set the value of an uniform to an array of float32 (stored as vec4)
  29202. * @param uniform defines the webGL uniform location where to store the value
  29203. * @param array defines the array of float32 to store
  29204. */
  29205. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29206. /**
  29207. * Set the value of an uniform to an array of number
  29208. * @param uniform defines the webGL uniform location where to store the value
  29209. * @param array defines the array of number to store
  29210. */
  29211. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29212. /**
  29213. * Set the value of an uniform to an array of number (stored as vec2)
  29214. * @param uniform defines the webGL uniform location where to store the value
  29215. * @param array defines the array of number to store
  29216. */
  29217. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29218. /**
  29219. * Set the value of an uniform to an array of number (stored as vec3)
  29220. * @param uniform defines the webGL uniform location where to store the value
  29221. * @param array defines the array of number to store
  29222. */
  29223. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29224. /**
  29225. * Set the value of an uniform to an array of number (stored as vec4)
  29226. * @param uniform defines the webGL uniform location where to store the value
  29227. * @param array defines the array of number to store
  29228. */
  29229. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29230. /**
  29231. * Set the value of an uniform to an array of float32 (stored as matrices)
  29232. * @param uniform defines the webGL uniform location where to store the value
  29233. * @param matrices defines the array of float32 to store
  29234. */
  29235. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29236. /**
  29237. * Set the value of an uniform to a matrix
  29238. * @param uniform defines the webGL uniform location where to store the value
  29239. * @param matrix defines the matrix to store
  29240. */
  29241. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29242. /**
  29243. * Set the value of an uniform to a matrix (3x3)
  29244. * @param uniform defines the webGL uniform location where to store the value
  29245. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29246. */
  29247. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29248. /**
  29249. * Set the value of an uniform to a matrix (2x2)
  29250. * @param uniform defines the webGL uniform location where to store the value
  29251. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29252. */
  29253. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29254. /**
  29255. * Set the value of an uniform to a number (int)
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param value defines the int number to store
  29258. */
  29259. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29260. /**
  29261. * Set the value of an uniform to a number (float)
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param value defines the float number to store
  29264. */
  29265. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29266. /**
  29267. * Set the value of an uniform to a vec2
  29268. * @param uniform defines the webGL uniform location where to store the value
  29269. * @param x defines the 1st component of the value
  29270. * @param y defines the 2nd component of the value
  29271. */
  29272. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29273. /**
  29274. * Set the value of an uniform to a vec3
  29275. * @param uniform defines the webGL uniform location where to store the value
  29276. * @param x defines the 1st component of the value
  29277. * @param y defines the 2nd component of the value
  29278. * @param z defines the 3rd component of the value
  29279. */
  29280. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29281. /**
  29282. * Set the value of an uniform to a boolean
  29283. * @param uniform defines the webGL uniform location where to store the value
  29284. * @param bool defines the boolean to store
  29285. */
  29286. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29287. /**
  29288. * Set the value of an uniform to a vec4
  29289. * @param uniform defines the webGL uniform location where to store the value
  29290. * @param x defines the 1st component of the value
  29291. * @param y defines the 2nd component of the value
  29292. * @param z defines the 3rd component of the value
  29293. * @param w defines the 4th component of the value
  29294. */
  29295. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29296. /**
  29297. * Set the value of an uniform to a Color3
  29298. * @param uniform defines the webGL uniform location where to store the value
  29299. * @param color3 defines the color to store
  29300. */
  29301. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29302. /**
  29303. * Set the value of an uniform to a Color3 and an alpha value
  29304. * @param uniform defines the webGL uniform location where to store the value
  29305. * @param color3 defines the color to store
  29306. * @param alpha defines the alpha component to store
  29307. */
  29308. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29309. /**
  29310. * Sets a Color4 on a uniform variable
  29311. * @param uniform defines the uniform location
  29312. * @param color4 defines the value to be set
  29313. */
  29314. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29315. /**
  29316. * Set various states to the webGL context
  29317. * @param culling defines backface culling state
  29318. * @param zOffset defines the value to apply to zOffset (0 by default)
  29319. * @param force defines if states must be applied even if cache is up to date
  29320. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29321. */
  29322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29323. /**
  29324. * Set the z offset to apply to current rendering
  29325. * @param value defines the offset to apply
  29326. */
  29327. setZOffset(value: number): void;
  29328. /**
  29329. * Gets the current value of the zOffset
  29330. * @returns the current zOffset state
  29331. */
  29332. getZOffset(): number;
  29333. /**
  29334. * Enable or disable depth buffering
  29335. * @param enable defines the state to set
  29336. */
  29337. setDepthBuffer(enable: boolean): void;
  29338. /**
  29339. * Gets a boolean indicating if depth writing is enabled
  29340. * @returns the current depth writing state
  29341. */
  29342. getDepthWrite(): boolean;
  29343. /**
  29344. * Enable or disable depth writing
  29345. * @param enable defines the state to set
  29346. */
  29347. setDepthWrite(enable: boolean): void;
  29348. /**
  29349. * Enable or disable color writing
  29350. * @param enable defines the state to set
  29351. */
  29352. setColorWrite(enable: boolean): void;
  29353. /**
  29354. * Gets a boolean indicating if color writing is enabled
  29355. * @returns the current color writing state
  29356. */
  29357. getColorWrite(): boolean;
  29358. /**
  29359. * Sets alpha constants used by some alpha blending modes
  29360. * @param r defines the red component
  29361. * @param g defines the green component
  29362. * @param b defines the blue component
  29363. * @param a defines the alpha component
  29364. */
  29365. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29366. /**
  29367. * Sets the current alpha mode
  29368. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29369. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29371. */
  29372. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29373. /**
  29374. * Gets the current alpha mode
  29375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29376. * @returns the current alpha mode
  29377. */
  29378. getAlphaMode(): number;
  29379. /**
  29380. * Clears the list of texture accessible through engine.
  29381. * This can help preventing texture load conflict due to name collision.
  29382. */
  29383. clearInternalTexturesCache(): void;
  29384. /**
  29385. * Force the entire cache to be cleared
  29386. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29387. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29388. */
  29389. wipeCaches(bruteForce?: boolean): void;
  29390. /**
  29391. * Set the compressed texture format to use, based on the formats you have, and the formats
  29392. * supported by the hardware / browser.
  29393. *
  29394. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29395. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29396. * to API arguments needed to compressed textures. This puts the burden on the container
  29397. * generator to house the arcane code for determining these for current & future formats.
  29398. *
  29399. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29400. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29401. *
  29402. * Note: The result of this call is not taken into account when a texture is base64.
  29403. *
  29404. * @param formatsAvailable defines the list of those format families you have created
  29405. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29406. *
  29407. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29408. * @returns The extension selected.
  29409. */
  29410. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29411. private _getSamplingParameters;
  29412. private _partialLoadImg;
  29413. private _cascadeLoadImgs;
  29414. /** @hidden */
  29415. _createTexture(): WebGLTexture;
  29416. /**
  29417. * Usually called from Texture.ts.
  29418. * Passed information to create a WebGLTexture
  29419. * @param urlArg defines a value which contains one of the following:
  29420. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29421. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29422. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29424. * @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)
  29425. * @param scene needed for loading to the correct scene
  29426. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29427. * @param onLoad optional callback to be called upon successful completion
  29428. * @param onError optional callback to be called upon failure
  29429. * @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
  29430. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29431. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29432. * @param forcedExtension defines the extension to use to pick the right loader
  29433. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29435. */
  29436. 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;
  29437. private _rescaleTexture;
  29438. /**
  29439. * Update a raw texture
  29440. * @param texture defines the texture to update
  29441. * @param data defines the data to store in the texture
  29442. * @param format defines the format of the data
  29443. * @param invertY defines if data must be stored with Y axis inverted
  29444. * @param compression defines the compression used (null by default)
  29445. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29446. */
  29447. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29448. /**
  29449. * Creates a raw texture
  29450. * @param data defines the data to store in the texture
  29451. * @param width defines the width of the texture
  29452. * @param height defines the height of the texture
  29453. * @param format defines the format of the data
  29454. * @param generateMipMaps defines if the engine should generate the mip levels
  29455. * @param invertY defines if data must be stored with Y axis inverted
  29456. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29457. * @param compression defines the compression used (null by default)
  29458. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29459. * @returns the raw texture inside an InternalTexture
  29460. */
  29461. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29462. private _unpackFlipYCached;
  29463. /**
  29464. * In case you are sharing the context with other applications, it might
  29465. * be interested to not cache the unpack flip y state to ensure a consistent
  29466. * value would be set.
  29467. */
  29468. enableUnpackFlipYCached: boolean;
  29469. /** @hidden */
  29470. _unpackFlipY(value: boolean): void;
  29471. /** @hidden */
  29472. _getUnpackAlignement(): number;
  29473. /**
  29474. * Creates a dynamic texture
  29475. * @param width defines the width of the texture
  29476. * @param height defines the height of the texture
  29477. * @param generateMipMaps defines if the engine should generate the mip levels
  29478. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29479. * @returns the dynamic texture inside an InternalTexture
  29480. */
  29481. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29482. /**
  29483. * Update the sampling mode of a given texture
  29484. * @param samplingMode defines the required sampling mode
  29485. * @param texture defines the texture to update
  29486. */
  29487. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29488. /**
  29489. * Update the content of a dynamic texture
  29490. * @param texture defines the texture to update
  29491. * @param canvas defines the canvas containing the source
  29492. * @param invertY defines if data must be stored with Y axis inverted
  29493. * @param premulAlpha defines if alpha is stored as premultiplied
  29494. * @param format defines the format of the data
  29495. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29496. */
  29497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29498. /**
  29499. * Update a video texture
  29500. * @param texture defines the texture to update
  29501. * @param video defines the video element to use
  29502. * @param invertY defines if data must be stored with Y axis inverted
  29503. */
  29504. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29505. /**
  29506. * Updates a depth texture Comparison Mode and Function.
  29507. * If the comparison Function is equal to 0, the mode will be set to none.
  29508. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29509. * @param texture The texture to set the comparison function for
  29510. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29511. */
  29512. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29513. private _setupDepthStencilTexture;
  29514. /**
  29515. * Creates a depth stencil texture.
  29516. * This is only available in WebGL 2 or with the depth texture extension available.
  29517. * @param size The size of face edge in the texture.
  29518. * @param options The options defining the texture.
  29519. * @returns The texture
  29520. */
  29521. createDepthStencilTexture(size: number | {
  29522. width: number;
  29523. height: number;
  29524. }, options: DepthTextureCreationOptions): InternalTexture;
  29525. /**
  29526. * Creates a depth stencil texture.
  29527. * This is only available in WebGL 2 or with the depth texture extension available.
  29528. * @param size The size of face edge in the texture.
  29529. * @param options The options defining the texture.
  29530. * @returns The texture
  29531. */
  29532. private _createDepthStencilTexture;
  29533. /**
  29534. * Creates a depth stencil cube texture.
  29535. * This is only available in WebGL 2.
  29536. * @param size The size of face edge in the cube texture.
  29537. * @param options The options defining the cube texture.
  29538. * @returns The cube texture
  29539. */
  29540. private _createDepthStencilCubeTexture;
  29541. /**
  29542. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29543. * @param renderTarget The render target to set the frame buffer for
  29544. */
  29545. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29546. /**
  29547. * Creates a new render target texture
  29548. * @param size defines the size of the texture
  29549. * @param options defines the options used to create the texture
  29550. * @returns a new render target texture stored in an InternalTexture
  29551. */
  29552. createRenderTargetTexture(size: number | {
  29553. width: number;
  29554. height: number;
  29555. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29556. /**
  29557. * Create a multi render target texture
  29558. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29559. * @param size defines the size of the texture
  29560. * @param options defines the creation options
  29561. * @returns the cube texture as an InternalTexture
  29562. */
  29563. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29564. private _setupFramebufferDepthAttachments;
  29565. /**
  29566. * Updates the sample count of a render target texture
  29567. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29568. * @param texture defines the texture to update
  29569. * @param samples defines the sample count to set
  29570. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29571. */
  29572. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29573. /**
  29574. * Update the sample count for a given multiple render target texture
  29575. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29576. * @param textures defines the textures to update
  29577. * @param samples defines the sample count to set
  29578. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29579. */
  29580. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29581. /** @hidden */
  29582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29583. /** @hidden */
  29584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29585. /** @hidden */
  29586. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29587. /** @hidden */
  29588. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29589. /**
  29590. * Creates a new render target cube texture
  29591. * @param size defines the size of the texture
  29592. * @param options defines the options used to create the texture
  29593. * @returns a new render target cube texture stored in an InternalTexture
  29594. */
  29595. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29596. /**
  29597. * Creates a cube texture
  29598. * @param rootUrl defines the url where the files to load is located
  29599. * @param scene defines the current scene
  29600. * @param files defines the list of files to load (1 per face)
  29601. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29602. * @param onLoad defines an optional callback raised when the texture is loaded
  29603. * @param onError defines an optional callback raised if there is an issue to load the texture
  29604. * @param format defines the format of the data
  29605. * @param forcedExtension defines the extension to use to pick the right loader
  29606. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29607. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29608. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29609. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29610. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29611. * @returns the cube texture as an InternalTexture
  29612. */
  29613. 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;
  29614. /**
  29615. * @hidden
  29616. */
  29617. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29618. /**
  29619. * Update a raw cube texture
  29620. * @param texture defines the texture to udpdate
  29621. * @param data defines the data to store
  29622. * @param format defines the data format
  29623. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29624. * @param invertY defines if data must be stored with Y axis inverted
  29625. * @param compression defines the compression used (null by default)
  29626. * @param level defines which level of the texture to update
  29627. */
  29628. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29629. /**
  29630. * Creates a new raw cube texture
  29631. * @param data defines the array of data to use to create each face
  29632. * @param size defines the size of the textures
  29633. * @param format defines the format of the data
  29634. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29635. * @param generateMipMaps defines if the engine should generate the mip levels
  29636. * @param invertY defines if data must be stored with Y axis inverted
  29637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29638. * @param compression defines the compression used (null by default)
  29639. * @returns the cube texture as an InternalTexture
  29640. */
  29641. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29642. /**
  29643. * Creates a new raw cube texture from a specified url
  29644. * @param url defines the url where the data is located
  29645. * @param scene defines the current scene
  29646. * @param size defines the size of the textures
  29647. * @param format defines the format of the data
  29648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29649. * @param noMipmap defines if the engine should avoid generating the mip levels
  29650. * @param callback defines a callback used to extract texture data from loaded data
  29651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29652. * @param onLoad defines a callback called when texture is loaded
  29653. * @param onError defines a callback called if there is an error
  29654. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29655. * @param invertY defines if data must be stored with Y axis inverted
  29656. * @returns the cube texture as an InternalTexture
  29657. */
  29658. 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;
  29659. /**
  29660. * Update a raw 3D texture
  29661. * @param texture defines the texture to update
  29662. * @param data defines the data to store
  29663. * @param format defines the data format
  29664. * @param invertY defines if data must be stored with Y axis inverted
  29665. * @param compression defines the used compression (can be null)
  29666. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29667. */
  29668. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29669. /**
  29670. * Creates a new raw 3D texture
  29671. * @param data defines the data used to create the texture
  29672. * @param width defines the width of the texture
  29673. * @param height defines the height of the texture
  29674. * @param depth defines the depth of the texture
  29675. * @param format defines the format of the texture
  29676. * @param generateMipMaps defines if the engine must generate mip levels
  29677. * @param invertY defines if data must be stored with Y axis inverted
  29678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29679. * @param compression defines the compressed used (can be null)
  29680. * @param textureType defines the compressed used (can be null)
  29681. * @returns a new raw 3D texture (stored in an InternalTexture)
  29682. */
  29683. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29684. private _prepareWebGLTextureContinuation;
  29685. private _prepareWebGLTexture;
  29686. private _convertRGBtoRGBATextureData;
  29687. /** @hidden */
  29688. _releaseFramebufferObjects(texture: InternalTexture): void;
  29689. /** @hidden */
  29690. _releaseTexture(texture: InternalTexture): void;
  29691. private setProgram;
  29692. private _boundUniforms;
  29693. /**
  29694. * Binds an effect to the webGL context
  29695. * @param effect defines the effect to bind
  29696. */
  29697. bindSamplers(effect: Effect): void;
  29698. private _moveBoundTextureOnTop;
  29699. private _getCorrectTextureChannel;
  29700. private _linkTrackers;
  29701. private _removeDesignatedSlot;
  29702. private _activateCurrentTexture;
  29703. /** @hidden */
  29704. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29705. /** @hidden */
  29706. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29707. /**
  29708. * Sets a texture to the webGL context from a postprocess
  29709. * @param channel defines the channel to use
  29710. * @param postProcess defines the source postprocess
  29711. */
  29712. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29713. /**
  29714. * Binds the output of the passed in post process to the texture channel specified
  29715. * @param channel The channel the texture should be bound to
  29716. * @param postProcess The post process which's output should be bound
  29717. */
  29718. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29719. /**
  29720. * Unbind all textures from the webGL context
  29721. */
  29722. unbindAllTextures(): void;
  29723. /**
  29724. * Sets a texture to the according uniform.
  29725. * @param channel The texture channel
  29726. * @param uniform The uniform to set
  29727. * @param texture The texture to apply
  29728. */
  29729. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29730. /**
  29731. * Sets a depth stencil texture from a render target to the according uniform.
  29732. * @param channel The texture channel
  29733. * @param uniform The uniform to set
  29734. * @param texture The render target texture containing the depth stencil texture to apply
  29735. */
  29736. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29737. private _bindSamplerUniformToChannel;
  29738. private _getTextureWrapMode;
  29739. private _setTexture;
  29740. /**
  29741. * Sets an array of texture to the webGL context
  29742. * @param channel defines the channel where the texture array must be set
  29743. * @param uniform defines the associated uniform location
  29744. * @param textures defines the array of textures to bind
  29745. */
  29746. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29747. /** @hidden */
  29748. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29749. private _setTextureParameterFloat;
  29750. private _setTextureParameterInteger;
  29751. /**
  29752. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29753. * @param x defines the x coordinate of the rectangle where pixels must be read
  29754. * @param y defines the y coordinate of the rectangle where pixels must be read
  29755. * @param width defines the width of the rectangle where pixels must be read
  29756. * @param height defines the height of the rectangle where pixels must be read
  29757. * @returns a Uint8Array containing RGBA colors
  29758. */
  29759. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29760. /**
  29761. * Add an externaly attached data from its key.
  29762. * This method call will fail and return false, if such key already exists.
  29763. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29764. * @param key the unique key that identifies the data
  29765. * @param data the data object to associate to the key for this Engine instance
  29766. * @return true if no such key were already present and the data was added successfully, false otherwise
  29767. */
  29768. addExternalData<T>(key: string, data: T): boolean;
  29769. /**
  29770. * Get an externaly attached data from its key
  29771. * @param key the unique key that identifies the data
  29772. * @return the associated data, if present (can be null), or undefined if not present
  29773. */
  29774. getExternalData<T>(key: string): T;
  29775. /**
  29776. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29777. * @param key the unique key that identifies the data
  29778. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29779. * @return the associated data, can be null if the factory returned null.
  29780. */
  29781. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29782. /**
  29783. * Remove an externaly attached data from the Engine instance
  29784. * @param key the unique key that identifies the data
  29785. * @return true if the data was successfully removed, false if it doesn't exist
  29786. */
  29787. removeExternalData(key: string): boolean;
  29788. /**
  29789. * Unbind all vertex attributes from the webGL context
  29790. */
  29791. unbindAllAttributes(): void;
  29792. /**
  29793. * 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
  29794. */
  29795. releaseEffects(): void;
  29796. /**
  29797. * Dispose and release all associated resources
  29798. */
  29799. dispose(): void;
  29800. /**
  29801. * Display the loading screen
  29802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29803. */
  29804. displayLoadingUI(): void;
  29805. /**
  29806. * Hide the loading screen
  29807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29808. */
  29809. hideLoadingUI(): void;
  29810. /**
  29811. * Gets the current loading screen object
  29812. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29813. */
  29814. /**
  29815. * Sets the current loading screen object
  29816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29817. */
  29818. loadingScreen: ILoadingScreen;
  29819. /**
  29820. * Sets the current loading screen text
  29821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29822. */
  29823. loadingUIText: string;
  29824. /**
  29825. * Sets the current loading screen background color
  29826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29827. */
  29828. loadingUIBackgroundColor: string;
  29829. /**
  29830. * Attach a new callback raised when context lost event is fired
  29831. * @param callback defines the callback to call
  29832. */
  29833. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29834. /**
  29835. * Attach a new callback raised when context restored event is fired
  29836. * @param callback defines the callback to call
  29837. */
  29838. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29839. /**
  29840. * Gets the source code of the vertex shader associated with a specific webGL program
  29841. * @param program defines the program to use
  29842. * @returns a string containing the source code of the vertex shader associated with the program
  29843. */
  29844. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29845. /**
  29846. * Gets the source code of the fragment shader associated with a specific webGL program
  29847. * @param program defines the program to use
  29848. * @returns a string containing the source code of the fragment shader associated with the program
  29849. */
  29850. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29851. /**
  29852. * Get the current error code of the webGL context
  29853. * @returns the error code
  29854. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29855. */
  29856. getError(): number;
  29857. /**
  29858. * Gets the current framerate
  29859. * @returns a number representing the framerate
  29860. */
  29861. getFps(): number;
  29862. /**
  29863. * Gets the time spent between current and previous frame
  29864. * @returns a number representing the delta time in ms
  29865. */
  29866. getDeltaTime(): number;
  29867. private _measureFps;
  29868. /** @hidden */
  29869. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29870. private _canRenderToFloatFramebuffer;
  29871. private _canRenderToHalfFloatFramebuffer;
  29872. private _canRenderToFramebuffer;
  29873. /** @hidden */
  29874. _getWebGLTextureType(type: number): number;
  29875. private _getInternalFormat;
  29876. /** @hidden */
  29877. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29878. /** @hidden */
  29879. _getRGBAMultiSampleBufferFormat(type: number): number;
  29880. /** @hidden */
  29881. _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;
  29882. /** @hidden */
  29883. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29884. private _partialLoadFile;
  29885. private _cascadeLoadFiles;
  29886. /**
  29887. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29888. * @returns true if the engine can be created
  29889. * @ignorenaming
  29890. */
  29891. static isSupported(): boolean;
  29892. }
  29893. }
  29894. declare module "babylonjs/Materials/effect" {
  29895. import { Observable } from "babylonjs/Misc/observable";
  29896. import { Nullable } from "babylonjs/types";
  29897. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29898. import { Engine } from "babylonjs/Engines/engine";
  29899. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29902. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29904. /**
  29905. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29906. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29907. */
  29908. export class EffectFallbacks {
  29909. private _defines;
  29910. private _currentRank;
  29911. private _maxRank;
  29912. private _mesh;
  29913. /**
  29914. * Removes the fallback from the bound mesh.
  29915. */
  29916. unBindMesh(): void;
  29917. /**
  29918. * Adds a fallback on the specified property.
  29919. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29920. * @param define The name of the define in the shader
  29921. */
  29922. addFallback(rank: number, define: string): void;
  29923. /**
  29924. * Sets the mesh to use CPU skinning when needing to fallback.
  29925. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29926. * @param mesh The mesh to use the fallbacks.
  29927. */
  29928. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29929. /**
  29930. * Checks to see if more fallbacks are still availible.
  29931. */
  29932. readonly isMoreFallbacks: boolean;
  29933. /**
  29934. * Removes the defines that shoould be removed when falling back.
  29935. * @param currentDefines defines the current define statements for the shader.
  29936. * @param effect defines the current effect we try to compile
  29937. * @returns The resulting defines with defines of the current rank removed.
  29938. */
  29939. reduce(currentDefines: string, effect: Effect): string;
  29940. }
  29941. /**
  29942. * Options to be used when creating an effect.
  29943. */
  29944. export class EffectCreationOptions {
  29945. /**
  29946. * Atrributes that will be used in the shader.
  29947. */
  29948. attributes: string[];
  29949. /**
  29950. * Uniform varible names that will be set in the shader.
  29951. */
  29952. uniformsNames: string[];
  29953. /**
  29954. * Uniform buffer varible names that will be set in the shader.
  29955. */
  29956. uniformBuffersNames: string[];
  29957. /**
  29958. * Sampler texture variable names that will be set in the shader.
  29959. */
  29960. samplers: string[];
  29961. /**
  29962. * Define statements that will be set in the shader.
  29963. */
  29964. defines: any;
  29965. /**
  29966. * Possible fallbacks for this effect to improve performance when needed.
  29967. */
  29968. fallbacks: Nullable<EffectFallbacks>;
  29969. /**
  29970. * Callback that will be called when the shader is compiled.
  29971. */
  29972. onCompiled: Nullable<(effect: Effect) => void>;
  29973. /**
  29974. * Callback that will be called if an error occurs during shader compilation.
  29975. */
  29976. onError: Nullable<(effect: Effect, errors: string) => void>;
  29977. /**
  29978. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29979. */
  29980. indexParameters: any;
  29981. /**
  29982. * Max number of lights that can be used in the shader.
  29983. */
  29984. maxSimultaneousLights: number;
  29985. /**
  29986. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29987. */
  29988. transformFeedbackVaryings: Nullable<string[]>;
  29989. }
  29990. /**
  29991. * Effect containing vertex and fragment shader that can be executed on an object.
  29992. */
  29993. export class Effect {
  29994. /**
  29995. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29996. */
  29997. static ShadersRepository: string;
  29998. /**
  29999. * Name of the effect.
  30000. */
  30001. name: any;
  30002. /**
  30003. * String container all the define statements that should be set on the shader.
  30004. */
  30005. defines: string;
  30006. /**
  30007. * Callback that will be called when the shader is compiled.
  30008. */
  30009. onCompiled: Nullable<(effect: Effect) => void>;
  30010. /**
  30011. * Callback that will be called if an error occurs during shader compilation.
  30012. */
  30013. onError: Nullable<(effect: Effect, errors: string) => void>;
  30014. /**
  30015. * Callback that will be called when effect is bound.
  30016. */
  30017. onBind: Nullable<(effect: Effect) => void>;
  30018. /**
  30019. * Unique ID of the effect.
  30020. */
  30021. uniqueId: number;
  30022. /**
  30023. * Observable that will be called when the shader is compiled.
  30024. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30025. */
  30026. onCompileObservable: Observable<Effect>;
  30027. /**
  30028. * Observable that will be called if an error occurs during shader compilation.
  30029. */
  30030. onErrorObservable: Observable<Effect>;
  30031. /** @hidden */
  30032. _onBindObservable: Nullable<Observable<Effect>>;
  30033. /**
  30034. * Observable that will be called when effect is bound.
  30035. */
  30036. readonly onBindObservable: Observable<Effect>;
  30037. /** @hidden */
  30038. _bonesComputationForcedToCPU: boolean;
  30039. private static _uniqueIdSeed;
  30040. private _engine;
  30041. private _uniformBuffersNames;
  30042. private _uniformsNames;
  30043. private _samplers;
  30044. private _isReady;
  30045. private _compilationError;
  30046. private _attributesNames;
  30047. private _attributes;
  30048. private _uniforms;
  30049. /**
  30050. * Key for the effect.
  30051. * @hidden
  30052. */
  30053. _key: string;
  30054. private _indexParameters;
  30055. private _fallbacks;
  30056. private _vertexSourceCode;
  30057. private _fragmentSourceCode;
  30058. private _vertexSourceCodeOverride;
  30059. private _fragmentSourceCodeOverride;
  30060. private _transformFeedbackVaryings;
  30061. /**
  30062. * Compiled shader to webGL program.
  30063. * @hidden
  30064. */
  30065. _program: WebGLProgram;
  30066. private _valueCache;
  30067. private static _baseCache;
  30068. /**
  30069. * Instantiates an effect.
  30070. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30071. * @param baseName Name of the effect.
  30072. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30073. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30074. * @param samplers List of sampler variables that will be passed to the shader.
  30075. * @param engine Engine to be used to render the effect
  30076. * @param defines Define statements to be added to the shader.
  30077. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30078. * @param onCompiled Callback that will be called when the shader is compiled.
  30079. * @param onError Callback that will be called if an error occurs during shader compilation.
  30080. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30081. */
  30082. 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);
  30083. /**
  30084. * Unique key for this effect
  30085. */
  30086. readonly key: string;
  30087. /**
  30088. * If the effect has been compiled and prepared.
  30089. * @returns if the effect is compiled and prepared.
  30090. */
  30091. isReady(): boolean;
  30092. /**
  30093. * The engine the effect was initialized with.
  30094. * @returns the engine.
  30095. */
  30096. getEngine(): Engine;
  30097. /**
  30098. * The compiled webGL program for the effect
  30099. * @returns the webGL program.
  30100. */
  30101. getProgram(): WebGLProgram;
  30102. /**
  30103. * The set of names of attribute variables for the shader.
  30104. * @returns An array of attribute names.
  30105. */
  30106. getAttributesNames(): string[];
  30107. /**
  30108. * Returns the attribute at the given index.
  30109. * @param index The index of the attribute.
  30110. * @returns The location of the attribute.
  30111. */
  30112. getAttributeLocation(index: number): number;
  30113. /**
  30114. * Returns the attribute based on the name of the variable.
  30115. * @param name of the attribute to look up.
  30116. * @returns the attribute location.
  30117. */
  30118. getAttributeLocationByName(name: string): number;
  30119. /**
  30120. * The number of attributes.
  30121. * @returns the numnber of attributes.
  30122. */
  30123. getAttributesCount(): number;
  30124. /**
  30125. * Gets the index of a uniform variable.
  30126. * @param uniformName of the uniform to look up.
  30127. * @returns the index.
  30128. */
  30129. getUniformIndex(uniformName: string): number;
  30130. /**
  30131. * Returns the attribute based on the name of the variable.
  30132. * @param uniformName of the uniform to look up.
  30133. * @returns the location of the uniform.
  30134. */
  30135. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30136. /**
  30137. * Returns an array of sampler variable names
  30138. * @returns The array of sampler variable neames.
  30139. */
  30140. getSamplers(): string[];
  30141. /**
  30142. * The error from the last compilation.
  30143. * @returns the error string.
  30144. */
  30145. getCompilationError(): string;
  30146. /**
  30147. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30148. * @param func The callback to be used.
  30149. */
  30150. executeWhenCompiled(func: (effect: Effect) => void): void;
  30151. private _checkIsReady;
  30152. /** @hidden */
  30153. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30154. /** @hidden */
  30155. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30156. /** @hidden */
  30157. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30158. private _processShaderConversion;
  30159. private _processIncludes;
  30160. private _processPrecision;
  30161. /**
  30162. * Recompiles the webGL program
  30163. * @param vertexSourceCode The source code for the vertex shader.
  30164. * @param fragmentSourceCode The source code for the fragment shader.
  30165. * @param onCompiled Callback called when completed.
  30166. * @param onError Callback called on error.
  30167. * @hidden
  30168. */
  30169. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  30170. /**
  30171. * Gets the uniform locations of the the specified variable names
  30172. * @param names THe names of the variables to lookup.
  30173. * @returns Array of locations in the same order as variable names.
  30174. */
  30175. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  30176. /**
  30177. * Prepares the effect
  30178. * @hidden
  30179. */
  30180. _prepareEffect(): void;
  30181. /**
  30182. * Checks if the effect is supported. (Must be called after compilation)
  30183. */
  30184. readonly isSupported: boolean;
  30185. /**
  30186. * Binds a texture to the engine to be used as output of the shader.
  30187. * @param channel Name of the output variable.
  30188. * @param texture Texture to bind.
  30189. * @hidden
  30190. */
  30191. _bindTexture(channel: string, texture: InternalTexture): void;
  30192. /**
  30193. * Sets a texture on the engine to be used in the shader.
  30194. * @param channel Name of the sampler variable.
  30195. * @param texture Texture to set.
  30196. */
  30197. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30198. /**
  30199. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30200. * @param channel Name of the sampler variable.
  30201. * @param texture Texture to set.
  30202. */
  30203. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30204. /**
  30205. * Sets an array of textures on the engine to be used in the shader.
  30206. * @param channel Name of the variable.
  30207. * @param textures Textures to set.
  30208. */
  30209. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30210. /**
  30211. * 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)
  30212. * @param channel Name of the sampler variable.
  30213. * @param postProcess Post process to get the input texture from.
  30214. */
  30215. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30216. /**
  30217. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30218. * 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)
  30219. * @param channel Name of the sampler variable.
  30220. * @param postProcess Post process to get the output texture from.
  30221. */
  30222. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30223. /** @hidden */
  30224. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30225. /** @hidden */
  30226. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30227. /** @hidden */
  30228. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30229. /** @hidden */
  30230. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30231. /**
  30232. * Binds a buffer to a uniform.
  30233. * @param buffer Buffer to bind.
  30234. * @param name Name of the uniform variable to bind to.
  30235. */
  30236. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  30237. /**
  30238. * Binds block to a uniform.
  30239. * @param blockName Name of the block to bind.
  30240. * @param index Index to bind.
  30241. */
  30242. bindUniformBlock(blockName: string, index: number): void;
  30243. /**
  30244. * Sets an interger value on a uniform variable.
  30245. * @param uniformName Name of the variable.
  30246. * @param value Value to be set.
  30247. * @returns this effect.
  30248. */
  30249. setInt(uniformName: string, value: number): Effect;
  30250. /**
  30251. * Sets an int array on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param array array to be set.
  30254. * @returns this effect.
  30255. */
  30256. setIntArray(uniformName: string, array: Int32Array): Effect;
  30257. /**
  30258. * 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)
  30259. * @param uniformName Name of the variable.
  30260. * @param array array to be set.
  30261. * @returns this effect.
  30262. */
  30263. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30264. /**
  30265. * 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)
  30266. * @param uniformName Name of the variable.
  30267. * @param array array to be set.
  30268. * @returns this effect.
  30269. */
  30270. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30271. /**
  30272. * 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)
  30273. * @param uniformName Name of the variable.
  30274. * @param array array to be set.
  30275. * @returns this effect.
  30276. */
  30277. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30278. /**
  30279. * Sets an float array on a uniform variable.
  30280. * @param uniformName Name of the variable.
  30281. * @param array array to be set.
  30282. * @returns this effect.
  30283. */
  30284. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30285. /**
  30286. * 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)
  30287. * @param uniformName Name of the variable.
  30288. * @param array array to be set.
  30289. * @returns this effect.
  30290. */
  30291. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30292. /**
  30293. * 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)
  30294. * @param uniformName Name of the variable.
  30295. * @param array array to be set.
  30296. * @returns this effect.
  30297. */
  30298. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30299. /**
  30300. * 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)
  30301. * @param uniformName Name of the variable.
  30302. * @param array array to be set.
  30303. * @returns this effect.
  30304. */
  30305. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30306. /**
  30307. * Sets an array on a uniform variable.
  30308. * @param uniformName Name of the variable.
  30309. * @param array array to be set.
  30310. * @returns this effect.
  30311. */
  30312. setArray(uniformName: string, array: number[]): Effect;
  30313. /**
  30314. * 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)
  30315. * @param uniformName Name of the variable.
  30316. * @param array array to be set.
  30317. * @returns this effect.
  30318. */
  30319. setArray2(uniformName: string, array: number[]): Effect;
  30320. /**
  30321. * 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)
  30322. * @param uniformName Name of the variable.
  30323. * @param array array to be set.
  30324. * @returns this effect.
  30325. */
  30326. setArray3(uniformName: string, array: number[]): Effect;
  30327. /**
  30328. * 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)
  30329. * @param uniformName Name of the variable.
  30330. * @param array array to be set.
  30331. * @returns this effect.
  30332. */
  30333. setArray4(uniformName: string, array: number[]): Effect;
  30334. /**
  30335. * Sets matrices on a uniform variable.
  30336. * @param uniformName Name of the variable.
  30337. * @param matrices matrices to be set.
  30338. * @returns this effect.
  30339. */
  30340. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30341. /**
  30342. * Sets matrix on a uniform variable.
  30343. * @param uniformName Name of the variable.
  30344. * @param matrix matrix to be set.
  30345. * @returns this effect.
  30346. */
  30347. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30348. /**
  30349. * 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)
  30350. * @param uniformName Name of the variable.
  30351. * @param matrix matrix to be set.
  30352. * @returns this effect.
  30353. */
  30354. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30355. /**
  30356. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30357. * @param uniformName Name of the variable.
  30358. * @param matrix matrix to be set.
  30359. * @returns this effect.
  30360. */
  30361. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30362. /**
  30363. * Sets a float on a uniform variable.
  30364. * @param uniformName Name of the variable.
  30365. * @param value value to be set.
  30366. * @returns this effect.
  30367. */
  30368. setFloat(uniformName: string, value: number): Effect;
  30369. /**
  30370. * Sets a boolean on a uniform variable.
  30371. * @param uniformName Name of the variable.
  30372. * @param bool value to be set.
  30373. * @returns this effect.
  30374. */
  30375. setBool(uniformName: string, bool: boolean): Effect;
  30376. /**
  30377. * Sets a Vector2 on a uniform variable.
  30378. * @param uniformName Name of the variable.
  30379. * @param vector2 vector2 to be set.
  30380. * @returns this effect.
  30381. */
  30382. setVector2(uniformName: string, vector2: Vector2): Effect;
  30383. /**
  30384. * Sets a float2 on a uniform variable.
  30385. * @param uniformName Name of the variable.
  30386. * @param x First float in float2.
  30387. * @param y Second float in float2.
  30388. * @returns this effect.
  30389. */
  30390. setFloat2(uniformName: string, x: number, y: number): Effect;
  30391. /**
  30392. * Sets a Vector3 on a uniform variable.
  30393. * @param uniformName Name of the variable.
  30394. * @param vector3 Value to be set.
  30395. * @returns this effect.
  30396. */
  30397. setVector3(uniformName: string, vector3: Vector3): Effect;
  30398. /**
  30399. * Sets a float3 on a uniform variable.
  30400. * @param uniformName Name of the variable.
  30401. * @param x First float in float3.
  30402. * @param y Second float in float3.
  30403. * @param z Third float in float3.
  30404. * @returns this effect.
  30405. */
  30406. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30407. /**
  30408. * Sets a Vector4 on a uniform variable.
  30409. * @param uniformName Name of the variable.
  30410. * @param vector4 Value to be set.
  30411. * @returns this effect.
  30412. */
  30413. setVector4(uniformName: string, vector4: Vector4): Effect;
  30414. /**
  30415. * Sets a float4 on a uniform variable.
  30416. * @param uniformName Name of the variable.
  30417. * @param x First float in float4.
  30418. * @param y Second float in float4.
  30419. * @param z Third float in float4.
  30420. * @param w Fourth float in float4.
  30421. * @returns this effect.
  30422. */
  30423. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30424. /**
  30425. * Sets a Color3 on a uniform variable.
  30426. * @param uniformName Name of the variable.
  30427. * @param color3 Value to be set.
  30428. * @returns this effect.
  30429. */
  30430. setColor3(uniformName: string, color3: Color3): Effect;
  30431. /**
  30432. * Sets a Color4 on a uniform variable.
  30433. * @param uniformName Name of the variable.
  30434. * @param color3 Value to be set.
  30435. * @param alpha Alpha value to be set.
  30436. * @returns this effect.
  30437. */
  30438. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30439. /**
  30440. * Sets a Color4 on a uniform variable
  30441. * @param uniformName defines the name of the variable
  30442. * @param color4 defines the value to be set
  30443. * @returns this effect.
  30444. */
  30445. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30446. /**
  30447. * This function will add a new shader to the shader store
  30448. * @param name the name of the shader
  30449. * @param pixelShader optional pixel shader content
  30450. * @param vertexShader optional vertex shader content
  30451. */
  30452. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30453. /**
  30454. * Store of each shader (The can be looked up using effect.key)
  30455. */
  30456. static ShadersStore: {
  30457. [key: string]: string;
  30458. };
  30459. /**
  30460. * Store of each included file for a shader (The can be looked up using effect.key)
  30461. */
  30462. static IncludesShadersStore: {
  30463. [key: string]: string;
  30464. };
  30465. /**
  30466. * Resets the cache of effects.
  30467. */
  30468. static ResetCache(): void;
  30469. }
  30470. }
  30471. declare module "babylonjs/Materials/colorCurves" {
  30472. import { Effect } from "babylonjs/Materials/effect";
  30473. /**
  30474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30476. * 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;
  30477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30478. */
  30479. export class ColorCurves {
  30480. private _dirty;
  30481. private _tempColor;
  30482. private _globalCurve;
  30483. private _highlightsCurve;
  30484. private _midtonesCurve;
  30485. private _shadowsCurve;
  30486. private _positiveCurve;
  30487. private _negativeCurve;
  30488. private _globalHue;
  30489. private _globalDensity;
  30490. private _globalSaturation;
  30491. private _globalExposure;
  30492. /**
  30493. * Gets the global Hue value.
  30494. * 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).
  30495. */
  30496. /**
  30497. * Sets the global Hue value.
  30498. * 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).
  30499. */
  30500. globalHue: number;
  30501. /**
  30502. * Gets the global Density value.
  30503. * 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.
  30504. * Values less than zero provide a filter of opposite hue.
  30505. */
  30506. /**
  30507. * Sets the global Density value.
  30508. * 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.
  30509. * Values less than zero provide a filter of opposite hue.
  30510. */
  30511. globalDensity: number;
  30512. /**
  30513. * Gets the global Saturation value.
  30514. * 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.
  30515. */
  30516. /**
  30517. * Sets the global Saturation value.
  30518. * 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.
  30519. */
  30520. globalSaturation: number;
  30521. /**
  30522. * Gets the global Exposure value.
  30523. * 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.
  30524. */
  30525. /**
  30526. * Sets the global Exposure value.
  30527. * 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.
  30528. */
  30529. globalExposure: number;
  30530. private _highlightsHue;
  30531. private _highlightsDensity;
  30532. private _highlightsSaturation;
  30533. private _highlightsExposure;
  30534. /**
  30535. * Gets the highlights Hue value.
  30536. * 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).
  30537. */
  30538. /**
  30539. * Sets the highlights Hue value.
  30540. * 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).
  30541. */
  30542. highlightsHue: number;
  30543. /**
  30544. * Gets the highlights Density value.
  30545. * 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.
  30546. * Values less than zero provide a filter of opposite hue.
  30547. */
  30548. /**
  30549. * Sets the highlights Density value.
  30550. * 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.
  30551. * Values less than zero provide a filter of opposite hue.
  30552. */
  30553. highlightsDensity: number;
  30554. /**
  30555. * Gets the highlights Saturation value.
  30556. * 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.
  30557. */
  30558. /**
  30559. * Sets the highlights Saturation value.
  30560. * 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.
  30561. */
  30562. highlightsSaturation: number;
  30563. /**
  30564. * Gets the highlights Exposure value.
  30565. * 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.
  30566. */
  30567. /**
  30568. * Sets the highlights Exposure value.
  30569. * 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.
  30570. */
  30571. highlightsExposure: number;
  30572. private _midtonesHue;
  30573. private _midtonesDensity;
  30574. private _midtonesSaturation;
  30575. private _midtonesExposure;
  30576. /**
  30577. * Gets the midtones Hue value.
  30578. * 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).
  30579. */
  30580. /**
  30581. * Sets the midtones Hue value.
  30582. * 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).
  30583. */
  30584. midtonesHue: number;
  30585. /**
  30586. * Gets the midtones Density value.
  30587. * 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.
  30588. * Values less than zero provide a filter of opposite hue.
  30589. */
  30590. /**
  30591. * Sets the midtones Density value.
  30592. * 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.
  30593. * Values less than zero provide a filter of opposite hue.
  30594. */
  30595. midtonesDensity: number;
  30596. /**
  30597. * Gets the midtones Saturation value.
  30598. * 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.
  30599. */
  30600. /**
  30601. * Sets the midtones Saturation value.
  30602. * 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.
  30603. */
  30604. midtonesSaturation: number;
  30605. /**
  30606. * Gets the midtones Exposure value.
  30607. * 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.
  30608. */
  30609. /**
  30610. * Sets the midtones Exposure value.
  30611. * 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.
  30612. */
  30613. midtonesExposure: number;
  30614. private _shadowsHue;
  30615. private _shadowsDensity;
  30616. private _shadowsSaturation;
  30617. private _shadowsExposure;
  30618. /**
  30619. * Gets the shadows Hue value.
  30620. * 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).
  30621. */
  30622. /**
  30623. * Sets the shadows Hue value.
  30624. * 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).
  30625. */
  30626. shadowsHue: number;
  30627. /**
  30628. * Gets the shadows Density value.
  30629. * 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.
  30630. * Values less than zero provide a filter of opposite hue.
  30631. */
  30632. /**
  30633. * Sets the shadows Density value.
  30634. * 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.
  30635. * Values less than zero provide a filter of opposite hue.
  30636. */
  30637. shadowsDensity: number;
  30638. /**
  30639. * Gets the shadows Saturation value.
  30640. * 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.
  30641. */
  30642. /**
  30643. * Sets the shadows Saturation value.
  30644. * 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.
  30645. */
  30646. shadowsSaturation: number;
  30647. /**
  30648. * Gets the shadows Exposure value.
  30649. * 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.
  30650. */
  30651. /**
  30652. * Sets the shadows Exposure value.
  30653. * 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.
  30654. */
  30655. shadowsExposure: number;
  30656. /**
  30657. * Returns the class name
  30658. * @returns The class name
  30659. */
  30660. getClassName(): string;
  30661. /**
  30662. * Binds the color curves to the shader.
  30663. * @param colorCurves The color curve to bind
  30664. * @param effect The effect to bind to
  30665. * @param positiveUniform The positive uniform shader parameter
  30666. * @param neutralUniform The neutral uniform shader parameter
  30667. * @param negativeUniform The negative uniform shader parameter
  30668. */
  30669. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30670. /**
  30671. * Prepare the list of uniforms associated with the ColorCurves effects.
  30672. * @param uniformsList The list of uniforms used in the effect
  30673. */
  30674. static PrepareUniforms(uniformsList: string[]): void;
  30675. /**
  30676. * Returns color grading data based on a hue, density, saturation and exposure value.
  30677. * @param filterHue The hue of the color filter.
  30678. * @param filterDensity The density of the color filter.
  30679. * @param saturation The saturation.
  30680. * @param exposure The exposure.
  30681. * @param result The result data container.
  30682. */
  30683. private getColorGradingDataToRef;
  30684. /**
  30685. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30686. * @param value The input slider value in range [-100,100].
  30687. * @returns Adjusted value.
  30688. */
  30689. private static applyColorGradingSliderNonlinear;
  30690. /**
  30691. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30692. * @param hue The hue (H) input.
  30693. * @param saturation The saturation (S) input.
  30694. * @param brightness The brightness (B) input.
  30695. * @result An RGBA color represented as Vector4.
  30696. */
  30697. private static fromHSBToRef;
  30698. /**
  30699. * Returns a value clamped between min and max
  30700. * @param value The value to clamp
  30701. * @param min The minimum of value
  30702. * @param max The maximum of value
  30703. * @returns The clamped value.
  30704. */
  30705. private static clamp;
  30706. /**
  30707. * Clones the current color curve instance.
  30708. * @return The cloned curves
  30709. */
  30710. clone(): ColorCurves;
  30711. /**
  30712. * Serializes the current color curve instance to a json representation.
  30713. * @return a JSON representation
  30714. */
  30715. serialize(): any;
  30716. /**
  30717. * Parses the color curve from a json representation.
  30718. * @param source the JSON source to parse
  30719. * @return The parsed curves
  30720. */
  30721. static Parse(source: any): ColorCurves;
  30722. }
  30723. }
  30724. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30725. import { Observable } from "babylonjs/Misc/observable";
  30726. import { Nullable } from "babylonjs/types";
  30727. import { Color4 } from "babylonjs/Maths/math";
  30728. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30729. import { Effect } from "babylonjs/Materials/effect";
  30730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30731. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30732. /**
  30733. * Interface to follow in your material defines to integrate easily the
  30734. * Image proccessing functions.
  30735. * @hidden
  30736. */
  30737. export interface IImageProcessingConfigurationDefines {
  30738. IMAGEPROCESSING: boolean;
  30739. VIGNETTE: boolean;
  30740. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30741. VIGNETTEBLENDMODEOPAQUE: boolean;
  30742. TONEMAPPING: boolean;
  30743. TONEMAPPING_ACES: boolean;
  30744. CONTRAST: boolean;
  30745. EXPOSURE: boolean;
  30746. COLORCURVES: boolean;
  30747. COLORGRADING: boolean;
  30748. COLORGRADING3D: boolean;
  30749. SAMPLER3DGREENDEPTH: boolean;
  30750. SAMPLER3DBGRMAP: boolean;
  30751. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30752. }
  30753. /**
  30754. * @hidden
  30755. */
  30756. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30757. IMAGEPROCESSING: boolean;
  30758. VIGNETTE: boolean;
  30759. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30760. VIGNETTEBLENDMODEOPAQUE: boolean;
  30761. TONEMAPPING: boolean;
  30762. TONEMAPPING_ACES: boolean;
  30763. CONTRAST: boolean;
  30764. COLORCURVES: boolean;
  30765. COLORGRADING: boolean;
  30766. COLORGRADING3D: boolean;
  30767. SAMPLER3DGREENDEPTH: boolean;
  30768. SAMPLER3DBGRMAP: boolean;
  30769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30770. EXPOSURE: boolean;
  30771. constructor();
  30772. }
  30773. /**
  30774. * This groups together the common properties used for image processing either in direct forward pass
  30775. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30776. * or not.
  30777. */
  30778. export class ImageProcessingConfiguration {
  30779. /**
  30780. * Default tone mapping applied in BabylonJS.
  30781. */
  30782. static readonly TONEMAPPING_STANDARD: number;
  30783. /**
  30784. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30785. * to other engines rendering to increase portability.
  30786. */
  30787. static readonly TONEMAPPING_ACES: number;
  30788. /**
  30789. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30790. */
  30791. colorCurves: Nullable<ColorCurves>;
  30792. private _colorCurvesEnabled;
  30793. /**
  30794. * Gets wether the color curves effect is enabled.
  30795. */
  30796. /**
  30797. * Sets wether the color curves effect is enabled.
  30798. */
  30799. colorCurvesEnabled: boolean;
  30800. private _colorGradingTexture;
  30801. /**
  30802. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30803. */
  30804. /**
  30805. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30806. */
  30807. colorGradingTexture: Nullable<BaseTexture>;
  30808. private _colorGradingEnabled;
  30809. /**
  30810. * Gets wether the color grading effect is enabled.
  30811. */
  30812. /**
  30813. * Sets wether the color grading effect is enabled.
  30814. */
  30815. colorGradingEnabled: boolean;
  30816. private _colorGradingWithGreenDepth;
  30817. /**
  30818. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30819. */
  30820. /**
  30821. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30822. */
  30823. colorGradingWithGreenDepth: boolean;
  30824. private _colorGradingBGR;
  30825. /**
  30826. * Gets wether the color grading texture contains BGR values.
  30827. */
  30828. /**
  30829. * Sets wether the color grading texture contains BGR values.
  30830. */
  30831. colorGradingBGR: boolean;
  30832. /** @hidden */
  30833. _exposure: number;
  30834. /**
  30835. * Gets the Exposure used in the effect.
  30836. */
  30837. /**
  30838. * Sets the Exposure used in the effect.
  30839. */
  30840. exposure: number;
  30841. private _toneMappingEnabled;
  30842. /**
  30843. * Gets wether the tone mapping effect is enabled.
  30844. */
  30845. /**
  30846. * Sets wether the tone mapping effect is enabled.
  30847. */
  30848. toneMappingEnabled: boolean;
  30849. private _toneMappingType;
  30850. /**
  30851. * Gets the type of tone mapping effect.
  30852. */
  30853. /**
  30854. * Sets the type of tone mapping effect used in BabylonJS.
  30855. */
  30856. toneMappingType: number;
  30857. protected _contrast: number;
  30858. /**
  30859. * Gets the contrast used in the effect.
  30860. */
  30861. /**
  30862. * Sets the contrast used in the effect.
  30863. */
  30864. contrast: number;
  30865. /**
  30866. * Vignette stretch size.
  30867. */
  30868. vignetteStretch: number;
  30869. /**
  30870. * Vignette centre X Offset.
  30871. */
  30872. vignetteCentreX: number;
  30873. /**
  30874. * Vignette centre Y Offset.
  30875. */
  30876. vignetteCentreY: number;
  30877. /**
  30878. * Vignette weight or intensity of the vignette effect.
  30879. */
  30880. vignetteWeight: number;
  30881. /**
  30882. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30883. * if vignetteEnabled is set to true.
  30884. */
  30885. vignetteColor: Color4;
  30886. /**
  30887. * Camera field of view used by the Vignette effect.
  30888. */
  30889. vignetteCameraFov: number;
  30890. private _vignetteBlendMode;
  30891. /**
  30892. * Gets the vignette blend mode allowing different kind of effect.
  30893. */
  30894. /**
  30895. * Sets the vignette blend mode allowing different kind of effect.
  30896. */
  30897. vignetteBlendMode: number;
  30898. private _vignetteEnabled;
  30899. /**
  30900. * Gets wether the vignette effect is enabled.
  30901. */
  30902. /**
  30903. * Sets wether the vignette effect is enabled.
  30904. */
  30905. vignetteEnabled: boolean;
  30906. private _applyByPostProcess;
  30907. /**
  30908. * Gets wether the image processing is applied through a post process or not.
  30909. */
  30910. /**
  30911. * Sets wether the image processing is applied through a post process or not.
  30912. */
  30913. applyByPostProcess: boolean;
  30914. private _isEnabled;
  30915. /**
  30916. * Gets wether the image processing is enabled or not.
  30917. */
  30918. /**
  30919. * Sets wether the image processing is enabled or not.
  30920. */
  30921. isEnabled: boolean;
  30922. /**
  30923. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30924. */
  30925. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30926. /**
  30927. * Method called each time the image processing information changes requires to recompile the effect.
  30928. */
  30929. protected _updateParameters(): void;
  30930. /**
  30931. * Gets the current class name.
  30932. * @return "ImageProcessingConfiguration"
  30933. */
  30934. getClassName(): string;
  30935. /**
  30936. * Prepare the list of uniforms associated with the Image Processing effects.
  30937. * @param uniforms The list of uniforms used in the effect
  30938. * @param defines the list of defines currently in use
  30939. */
  30940. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30941. /**
  30942. * Prepare the list of samplers associated with the Image Processing effects.
  30943. * @param samplersList The list of uniforms used in the effect
  30944. * @param defines the list of defines currently in use
  30945. */
  30946. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30947. /**
  30948. * Prepare the list of defines associated to the shader.
  30949. * @param defines the list of defines to complete
  30950. * @param forPostProcess Define if we are currently in post process mode or not
  30951. */
  30952. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30953. /**
  30954. * Returns true if all the image processing information are ready.
  30955. * @returns True if ready, otherwise, false
  30956. */
  30957. isReady(): boolean;
  30958. /**
  30959. * Binds the image processing to the shader.
  30960. * @param effect The effect to bind to
  30961. * @param aspectRatio Define the current aspect ratio of the effect
  30962. */
  30963. bind(effect: Effect, aspectRatio?: number): void;
  30964. /**
  30965. * Clones the current image processing instance.
  30966. * @return The cloned image processing
  30967. */
  30968. clone(): ImageProcessingConfiguration;
  30969. /**
  30970. * Serializes the current image processing instance to a json representation.
  30971. * @return a JSON representation
  30972. */
  30973. serialize(): any;
  30974. /**
  30975. * Parses the image processing from a json representation.
  30976. * @param source the JSON source to parse
  30977. * @return The parsed image processing
  30978. */
  30979. static Parse(source: any): ImageProcessingConfiguration;
  30980. private static _VIGNETTEMODE_MULTIPLY;
  30981. private static _VIGNETTEMODE_OPAQUE;
  30982. /**
  30983. * Used to apply the vignette as a mix with the pixel color.
  30984. */
  30985. static readonly VIGNETTEMODE_MULTIPLY: number;
  30986. /**
  30987. * Used to apply the vignette as a replacement of the pixel color.
  30988. */
  30989. static readonly VIGNETTEMODE_OPAQUE: number;
  30990. }
  30991. }
  30992. declare module "babylonjs/Materials/fresnelParameters" {
  30993. import { Color3 } from "babylonjs/Maths/math";
  30994. /**
  30995. * This represents all the required information to add a fresnel effect on a material:
  30996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30997. */
  30998. export class FresnelParameters {
  30999. private _isEnabled;
  31000. /**
  31001. * Define if the fresnel effect is enable or not.
  31002. */
  31003. isEnabled: boolean;
  31004. /**
  31005. * Define the color used on edges (grazing angle)
  31006. */
  31007. leftColor: Color3;
  31008. /**
  31009. * Define the color used on center
  31010. */
  31011. rightColor: Color3;
  31012. /**
  31013. * Define bias applied to computed fresnel term
  31014. */
  31015. bias: number;
  31016. /**
  31017. * Defined the power exponent applied to fresnel term
  31018. */
  31019. power: number;
  31020. /**
  31021. * Clones the current fresnel and its valuues
  31022. * @returns a clone fresnel configuration
  31023. */
  31024. clone(): FresnelParameters;
  31025. /**
  31026. * Serializes the current fresnel parameters to a JSON representation.
  31027. * @return the JSON serialization
  31028. */
  31029. serialize(): any;
  31030. /**
  31031. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31032. * @param parsedFresnelParameters Define the JSON representation
  31033. * @returns the parsed parameters
  31034. */
  31035. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31036. }
  31037. }
  31038. declare module "babylonjs/Misc/decorators" {
  31039. import { Nullable } from "babylonjs/types";
  31040. import { Scene } from "babylonjs/scene";
  31041. import { IAnimatable } from "babylonjs/Misc/tools";
  31042. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31043. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31044. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31045. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31046. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31047. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31048. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31049. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31050. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31051. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31052. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31053. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31054. /**
  31055. * Decorator used to define property that can be serialized as reference to a camera
  31056. * @param sourceName defines the name of the property to decorate
  31057. */
  31058. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31059. /**
  31060. * Class used to help serialization objects
  31061. */
  31062. export class SerializationHelper {
  31063. /** hidden */
  31064. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31065. /** hidden */
  31066. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31067. /** hidden */
  31068. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31069. /** hidden */
  31070. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31071. /**
  31072. * Appends the serialized animations from the source animations
  31073. * @param source Source containing the animations
  31074. * @param destination Target to store the animations
  31075. */
  31076. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31077. /**
  31078. * Static function used to serialized a specific entity
  31079. * @param entity defines the entity to serialize
  31080. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31081. * @returns a JSON compatible object representing the serialization of the entity
  31082. */
  31083. static Serialize<T>(entity: T, serializationObject?: any): any;
  31084. /**
  31085. * Creates a new entity from a serialization data object
  31086. * @param creationFunction defines a function used to instanciated the new entity
  31087. * @param source defines the source serialization data
  31088. * @param scene defines the hosting scene
  31089. * @param rootUrl defines the root url for resources
  31090. * @returns a new entity
  31091. */
  31092. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31093. /**
  31094. * Clones an object
  31095. * @param creationFunction defines the function used to instanciate the new object
  31096. * @param source defines the source object
  31097. * @returns the cloned object
  31098. */
  31099. static Clone<T>(creationFunction: () => T, source: T): T;
  31100. /**
  31101. * Instanciates a new object based on a source one (some data will be shared between both object)
  31102. * @param creationFunction defines the function used to instanciate the new object
  31103. * @param source defines the source object
  31104. * @returns the new object
  31105. */
  31106. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31107. }
  31108. }
  31109. declare module "babylonjs/Cameras/camera" {
  31110. import { SmartArray } from "babylonjs/Misc/smartArray";
  31111. import { Observable } from "babylonjs/Misc/observable";
  31112. import { Nullable } from "babylonjs/types";
  31113. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31114. import { Scene } from "babylonjs/scene";
  31115. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31116. import { Node } from "babylonjs/node";
  31117. import { Mesh } from "babylonjs/Meshes/mesh";
  31118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31119. import { Ray } from "babylonjs/Culling/ray";
  31120. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31121. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31124. /**
  31125. * This is the base class of all the camera used in the application.
  31126. * @see http://doc.babylonjs.com/features/cameras
  31127. */
  31128. export class Camera extends Node {
  31129. /** @hidden */
  31130. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31131. /**
  31132. * This is the default projection mode used by the cameras.
  31133. * It helps recreating a feeling of perspective and better appreciate depth.
  31134. * This is the best way to simulate real life cameras.
  31135. */
  31136. static readonly PERSPECTIVE_CAMERA: number;
  31137. /**
  31138. * This helps creating camera with an orthographic mode.
  31139. * 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.
  31140. */
  31141. static readonly ORTHOGRAPHIC_CAMERA: number;
  31142. /**
  31143. * This is the default FOV mode for perspective cameras.
  31144. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31145. */
  31146. static readonly FOVMODE_VERTICAL_FIXED: number;
  31147. /**
  31148. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31149. */
  31150. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31151. /**
  31152. * This specifies ther is no need for a camera rig.
  31153. * Basically only one eye is rendered corresponding to the camera.
  31154. */
  31155. static readonly RIG_MODE_NONE: number;
  31156. /**
  31157. * Simulates a camera Rig with one blue eye and one red eye.
  31158. * This can be use with 3d blue and red glasses.
  31159. */
  31160. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31161. /**
  31162. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31163. */
  31164. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31165. /**
  31166. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31167. */
  31168. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31169. /**
  31170. * Defines that both eyes of the camera will be rendered over under each other.
  31171. */
  31172. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31173. /**
  31174. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31175. */
  31176. static readonly RIG_MODE_VR: number;
  31177. /**
  31178. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31179. */
  31180. static readonly RIG_MODE_WEBVR: number;
  31181. /**
  31182. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31183. */
  31184. static readonly RIG_MODE_CUSTOM: number;
  31185. /**
  31186. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31187. */
  31188. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31189. /**
  31190. * @hidden
  31191. * Might be removed once multiview will be a thing
  31192. */
  31193. static UseAlternateWebVRRendering: boolean;
  31194. /**
  31195. * Define the input manager associated with the camera.
  31196. */
  31197. inputs: CameraInputsManager<Camera>;
  31198. /**
  31199. * Define the current local position of the camera in the scene
  31200. */
  31201. position: Vector3;
  31202. /**
  31203. * The vector the camera should consider as up.
  31204. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31205. */
  31206. upVector: Vector3;
  31207. /**
  31208. * Define the current limit on the left side for an orthographic camera
  31209. * In scene unit
  31210. */
  31211. orthoLeft: Nullable<number>;
  31212. /**
  31213. * Define the current limit on the right side for an orthographic camera
  31214. * In scene unit
  31215. */
  31216. orthoRight: Nullable<number>;
  31217. /**
  31218. * Define the current limit on the bottom side for an orthographic camera
  31219. * In scene unit
  31220. */
  31221. orthoBottom: Nullable<number>;
  31222. /**
  31223. * Define the current limit on the top side for an orthographic camera
  31224. * In scene unit
  31225. */
  31226. orthoTop: Nullable<number>;
  31227. /**
  31228. * Field Of View is set in Radians. (default is 0.8)
  31229. */
  31230. fov: number;
  31231. /**
  31232. * Define the minimum distance the camera can see from.
  31233. * This is important to note that the depth buffer are not infinite and the closer it starts
  31234. * the more your scene might encounter depth fighting issue.
  31235. */
  31236. minZ: number;
  31237. /**
  31238. * Define the maximum distance the camera can see to.
  31239. * This is important to note that the depth buffer are not infinite and the further it end
  31240. * the more your scene might encounter depth fighting issue.
  31241. */
  31242. maxZ: number;
  31243. /**
  31244. * Define the default inertia of the camera.
  31245. * This helps giving a smooth feeling to the camera movement.
  31246. */
  31247. inertia: number;
  31248. /**
  31249. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31250. */
  31251. mode: number;
  31252. /**
  31253. * Define wether the camera is intermediate.
  31254. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31255. */
  31256. isIntermediate: boolean;
  31257. /**
  31258. * Define the viewport of the camera.
  31259. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31260. */
  31261. viewport: Viewport;
  31262. /**
  31263. * Restricts the camera to viewing objects with the same layerMask.
  31264. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31265. */
  31266. layerMask: number;
  31267. /**
  31268. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31269. */
  31270. fovMode: number;
  31271. /**
  31272. * Rig mode of the camera.
  31273. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31274. * This is normally controlled byt the camera themselves as internal use.
  31275. */
  31276. cameraRigMode: number;
  31277. /**
  31278. * Defines the distance between both "eyes" in case of a RIG
  31279. */
  31280. interaxialDistance: number;
  31281. /**
  31282. * Defines if stereoscopic rendering is done side by side or over under.
  31283. */
  31284. isStereoscopicSideBySide: boolean;
  31285. /**
  31286. * 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
  31287. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31288. * else in the scene.
  31289. */
  31290. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31291. /**
  31292. * When set, the camera will render to this render target instead of the default canvas
  31293. */
  31294. outputRenderTarget: Nullable<RenderTargetTexture>;
  31295. /**
  31296. * Observable triggered when the camera view matrix has changed.
  31297. */
  31298. onViewMatrixChangedObservable: Observable<Camera>;
  31299. /**
  31300. * Observable triggered when the camera Projection matrix has changed.
  31301. */
  31302. onProjectionMatrixChangedObservable: Observable<Camera>;
  31303. /**
  31304. * Observable triggered when the inputs have been processed.
  31305. */
  31306. onAfterCheckInputsObservable: Observable<Camera>;
  31307. /**
  31308. * Observable triggered when reset has been called and applied to the camera.
  31309. */
  31310. onRestoreStateObservable: Observable<Camera>;
  31311. /** @hidden */
  31312. _cameraRigParams: any;
  31313. /** @hidden */
  31314. _rigCameras: Camera[];
  31315. /** @hidden */
  31316. _rigPostProcess: Nullable<PostProcess>;
  31317. protected _webvrViewMatrix: Matrix;
  31318. /** @hidden */
  31319. _skipRendering: boolean;
  31320. /** @hidden */
  31321. _alternateCamera: Camera;
  31322. /** @hidden */
  31323. _projectionMatrix: Matrix;
  31324. /** @hidden */
  31325. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31326. /** @hidden */
  31327. _activeMeshes: SmartArray<AbstractMesh>;
  31328. protected _globalPosition: Vector3;
  31329. /** hidden */
  31330. _computedViewMatrix: Matrix;
  31331. private _doNotComputeProjectionMatrix;
  31332. private _transformMatrix;
  31333. private _frustumPlanes;
  31334. private _refreshFrustumPlanes;
  31335. private _storedFov;
  31336. private _stateStored;
  31337. /**
  31338. * Instantiates a new camera object.
  31339. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31340. * @see http://doc.babylonjs.com/features/cameras
  31341. * @param name Defines the name of the camera in the scene
  31342. * @param position Defines the position of the camera
  31343. * @param scene Defines the scene the camera belongs too
  31344. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31345. */
  31346. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31347. /**
  31348. * Store current camera state (fov, position, etc..)
  31349. * @returns the camera
  31350. */
  31351. storeState(): Camera;
  31352. /**
  31353. * Restores the camera state values if it has been stored. You must call storeState() first
  31354. */
  31355. protected _restoreStateValues(): boolean;
  31356. /**
  31357. * Restored camera state. You must call storeState() first.
  31358. * @returns true if restored and false otherwise
  31359. */
  31360. restoreState(): boolean;
  31361. /**
  31362. * Gets the class name of the camera.
  31363. * @returns the class name
  31364. */
  31365. getClassName(): string;
  31366. /** @hidden */
  31367. readonly _isCamera: boolean;
  31368. /**
  31369. * Gets a string representation of the camera useful for debug purpose.
  31370. * @param fullDetails Defines that a more verboe level of logging is required
  31371. * @returns the string representation
  31372. */
  31373. toString(fullDetails?: boolean): string;
  31374. /**
  31375. * Gets the current world space position of the camera.
  31376. */
  31377. readonly globalPosition: Vector3;
  31378. /**
  31379. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31380. * @returns the active meshe list
  31381. */
  31382. getActiveMeshes(): SmartArray<AbstractMesh>;
  31383. /**
  31384. * Check wether a mesh is part of the current active mesh list of the camera
  31385. * @param mesh Defines the mesh to check
  31386. * @returns true if active, false otherwise
  31387. */
  31388. isActiveMesh(mesh: Mesh): boolean;
  31389. /**
  31390. * Is this camera ready to be used/rendered
  31391. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31392. * @return true if the camera is ready
  31393. */
  31394. isReady(completeCheck?: boolean): boolean;
  31395. /** @hidden */
  31396. _initCache(): void;
  31397. /** @hidden */
  31398. _updateCache(ignoreParentClass?: boolean): void;
  31399. /** @hidden */
  31400. _isSynchronized(): boolean;
  31401. /** @hidden */
  31402. _isSynchronizedViewMatrix(): boolean;
  31403. /** @hidden */
  31404. _isSynchronizedProjectionMatrix(): boolean;
  31405. /**
  31406. * Attach the input controls to a specific dom element to get the input from.
  31407. * @param element Defines the element the controls should be listened from
  31408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31409. */
  31410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31411. /**
  31412. * Detach the current controls from the specified dom element.
  31413. * @param element Defines the element to stop listening the inputs from
  31414. */
  31415. detachControl(element: HTMLElement): void;
  31416. /**
  31417. * Update the camera state according to the different inputs gathered during the frame.
  31418. */
  31419. update(): void;
  31420. /** @hidden */
  31421. _checkInputs(): void;
  31422. /** @hidden */
  31423. readonly rigCameras: Camera[];
  31424. /**
  31425. * Gets the post process used by the rig cameras
  31426. */
  31427. readonly rigPostProcess: Nullable<PostProcess>;
  31428. /**
  31429. * Internal, gets the first post proces.
  31430. * @returns the first post process to be run on this camera.
  31431. */
  31432. _getFirstPostProcess(): Nullable<PostProcess>;
  31433. private _cascadePostProcessesToRigCams;
  31434. /**
  31435. * Attach a post process to the camera.
  31436. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31437. * @param postProcess The post process to attach to the camera
  31438. * @param insertAt The position of the post process in case several of them are in use in the scene
  31439. * @returns the position the post process has been inserted at
  31440. */
  31441. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31442. /**
  31443. * Detach a post process to the camera.
  31444. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31445. * @param postProcess The post process to detach from the camera
  31446. */
  31447. detachPostProcess(postProcess: PostProcess): void;
  31448. /**
  31449. * Gets the current world matrix of the camera
  31450. */
  31451. getWorldMatrix(): Matrix;
  31452. /** @hidden */
  31453. _getViewMatrix(): Matrix;
  31454. /**
  31455. * Gets the current view matrix of the camera.
  31456. * @param force forces the camera to recompute the matrix without looking at the cached state
  31457. * @returns the view matrix
  31458. */
  31459. getViewMatrix(force?: boolean): Matrix;
  31460. /**
  31461. * Freeze the projection matrix.
  31462. * It will prevent the cache check of the camera projection compute and can speed up perf
  31463. * if no parameter of the camera are meant to change
  31464. * @param projection Defines manually a projection if necessary
  31465. */
  31466. freezeProjectionMatrix(projection?: Matrix): void;
  31467. /**
  31468. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31469. */
  31470. unfreezeProjectionMatrix(): void;
  31471. /**
  31472. * Gets the current projection matrix of the camera.
  31473. * @param force forces the camera to recompute the matrix without looking at the cached state
  31474. * @returns the projection matrix
  31475. */
  31476. getProjectionMatrix(force?: boolean): Matrix;
  31477. /**
  31478. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31479. * @returns a Matrix
  31480. */
  31481. getTransformationMatrix(): Matrix;
  31482. private _updateFrustumPlanes;
  31483. /**
  31484. * Checks if a cullable object (mesh...) is in the camera frustum
  31485. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31486. * @param target The object to check
  31487. * @returns true if the object is in frustum otherwise false
  31488. */
  31489. isInFrustum(target: ICullable): boolean;
  31490. /**
  31491. * Checks if a cullable object (mesh...) is in the camera frustum
  31492. * Unlike isInFrustum this cheks the full bounding box
  31493. * @param target The object to check
  31494. * @returns true if the object is in frustum otherwise false
  31495. */
  31496. isCompletelyInFrustum(target: ICullable): boolean;
  31497. /**
  31498. * Gets a ray in the forward direction from the camera.
  31499. * @param length Defines the length of the ray to create
  31500. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31501. * @param origin Defines the start point of the ray which defaults to the camera position
  31502. * @returns the forward ray
  31503. */
  31504. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31505. /**
  31506. * Releases resources associated with this node.
  31507. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31508. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31509. */
  31510. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31511. /**
  31512. * Gets the left camera of a rig setup in case of Rigged Camera
  31513. */
  31514. readonly leftCamera: Nullable<FreeCamera>;
  31515. /**
  31516. * Gets the right camera of a rig setup in case of Rigged Camera
  31517. */
  31518. readonly rightCamera: Nullable<FreeCamera>;
  31519. /**
  31520. * Gets the left camera target of a rig setup in case of Rigged Camera
  31521. * @returns the target position
  31522. */
  31523. getLeftTarget(): Nullable<Vector3>;
  31524. /**
  31525. * Gets the right camera target of a rig setup in case of Rigged Camera
  31526. * @returns the target position
  31527. */
  31528. getRightTarget(): Nullable<Vector3>;
  31529. /**
  31530. * @hidden
  31531. */
  31532. setCameraRigMode(mode: number, rigParams: any): void;
  31533. /** @hidden */
  31534. static _setStereoscopicRigMode(camera: Camera): void;
  31535. /** @hidden */
  31536. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31537. /** @hidden */
  31538. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31539. /** @hidden */
  31540. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31541. /** @hidden */
  31542. _getVRProjectionMatrix(): Matrix;
  31543. protected _updateCameraRotationMatrix(): void;
  31544. protected _updateWebVRCameraRotationMatrix(): void;
  31545. /**
  31546. * This function MUST be overwritten by the different WebVR cameras available.
  31547. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31548. * @hidden
  31549. */
  31550. _getWebVRProjectionMatrix(): Matrix;
  31551. /**
  31552. * This function MUST be overwritten by the different WebVR cameras available.
  31553. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31554. * @hidden
  31555. */
  31556. _getWebVRViewMatrix(): Matrix;
  31557. /** @hidden */
  31558. setCameraRigParameter(name: string, value: any): void;
  31559. /**
  31560. * needs to be overridden by children so sub has required properties to be copied
  31561. * @hidden
  31562. */
  31563. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31564. /**
  31565. * May need to be overridden by children
  31566. * @hidden
  31567. */
  31568. _updateRigCameras(): void;
  31569. /** @hidden */
  31570. _setupInputs(): void;
  31571. /**
  31572. * Serialiaze the camera setup to a json represention
  31573. * @returns the JSON representation
  31574. */
  31575. serialize(): any;
  31576. /**
  31577. * Clones the current camera.
  31578. * @param name The cloned camera name
  31579. * @returns the cloned camera
  31580. */
  31581. clone(name: string): Camera;
  31582. /**
  31583. * Gets the direction of the camera relative to a given local axis.
  31584. * @param localAxis Defines the reference axis to provide a relative direction.
  31585. * @return the direction
  31586. */
  31587. getDirection(localAxis: Vector3): Vector3;
  31588. /**
  31589. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31590. * @param localAxis Defines the reference axis to provide a relative direction.
  31591. * @param result Defines the vector to store the result in
  31592. */
  31593. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31594. /**
  31595. * Gets a camera constructor for a given camera type
  31596. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31597. * @param name The name of the camera the result will be able to instantiate
  31598. * @param scene The scene the result will construct the camera in
  31599. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31600. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31601. * @returns a factory method to construc the camera
  31602. */
  31603. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31604. /**
  31605. * Compute the world matrix of the camera.
  31606. * @returns the camera workd matrix
  31607. */
  31608. computeWorldMatrix(): Matrix;
  31609. /**
  31610. * Parse a JSON and creates the camera from the parsed information
  31611. * @param parsedCamera The JSON to parse
  31612. * @param scene The scene to instantiate the camera in
  31613. * @returns the newly constructed camera
  31614. */
  31615. static Parse(parsedCamera: any, scene: Scene): Camera;
  31616. }
  31617. }
  31618. declare module "babylonjs/Misc/tools" {
  31619. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31620. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31621. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31622. import { Observable } from "babylonjs/Misc/observable";
  31623. import { DomManagement } from "babylonjs/Misc/domManagement";
  31624. import { Camera } from "babylonjs/Cameras/camera";
  31625. import { Engine } from "babylonjs/Engines/engine";
  31626. import { Animation } from "babylonjs/Animations/animation";
  31627. /**
  31628. * Interface for any object that can request an animation frame
  31629. */
  31630. export interface ICustomAnimationFrameRequester {
  31631. /**
  31632. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31633. */
  31634. renderFunction?: Function;
  31635. /**
  31636. * Called to request the next frame to render to
  31637. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31638. */
  31639. requestAnimationFrame: Function;
  31640. /**
  31641. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31642. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31643. */
  31644. requestID?: number;
  31645. }
  31646. /**
  31647. * Interface containing an array of animations
  31648. */
  31649. export interface IAnimatable {
  31650. /**
  31651. * Array of animations
  31652. */
  31653. animations: Array<Animation>;
  31654. }
  31655. /** Interface used by value gradients (color, factor, ...) */
  31656. export interface IValueGradient {
  31657. /**
  31658. * Gets or sets the gradient value (between 0 and 1)
  31659. */
  31660. gradient: number;
  31661. }
  31662. /** Class used to store color4 gradient */
  31663. export class ColorGradient implements IValueGradient {
  31664. /**
  31665. * Gets or sets the gradient value (between 0 and 1)
  31666. */
  31667. gradient: number;
  31668. /**
  31669. * Gets or sets first associated color
  31670. */
  31671. color1: Color4;
  31672. /**
  31673. * Gets or sets second associated color
  31674. */
  31675. color2?: Color4;
  31676. /**
  31677. * Will get a color picked randomly between color1 and color2.
  31678. * If color2 is undefined then color1 will be used
  31679. * @param result defines the target Color4 to store the result in
  31680. */
  31681. getColorToRef(result: Color4): void;
  31682. }
  31683. /** Class used to store color 3 gradient */
  31684. export class Color3Gradient implements IValueGradient {
  31685. /**
  31686. * Gets or sets the gradient value (between 0 and 1)
  31687. */
  31688. gradient: number;
  31689. /**
  31690. * Gets or sets the associated color
  31691. */
  31692. color: Color3;
  31693. }
  31694. /** Class used to store factor gradient */
  31695. export class FactorGradient implements IValueGradient {
  31696. /**
  31697. * Gets or sets the gradient value (between 0 and 1)
  31698. */
  31699. gradient: number;
  31700. /**
  31701. * Gets or sets first associated factor
  31702. */
  31703. factor1: number;
  31704. /**
  31705. * Gets or sets second associated factor
  31706. */
  31707. factor2?: number;
  31708. /**
  31709. * Will get a number picked randomly between factor1 and factor2.
  31710. * If factor2 is undefined then factor1 will be used
  31711. * @returns the picked number
  31712. */
  31713. getFactor(): number;
  31714. }
  31715. /**
  31716. * @ignore
  31717. * Application error to support additional information when loading a file
  31718. */
  31719. export class LoadFileError extends Error {
  31720. /** defines the optional XHR request */
  31721. request?: XMLHttpRequest | undefined;
  31722. private static _setPrototypeOf;
  31723. /**
  31724. * Creates a new LoadFileError
  31725. * @param message defines the message of the error
  31726. * @param request defines the optional XHR request
  31727. */
  31728. constructor(message: string,
  31729. /** defines the optional XHR request */
  31730. request?: XMLHttpRequest | undefined);
  31731. }
  31732. /**
  31733. * Class used to define a retry strategy when error happens while loading assets
  31734. */
  31735. export class RetryStrategy {
  31736. /**
  31737. * Function used to defines an exponential back off strategy
  31738. * @param maxRetries defines the maximum number of retries (3 by default)
  31739. * @param baseInterval defines the interval between retries
  31740. * @returns the strategy function to use
  31741. */
  31742. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31743. }
  31744. /**
  31745. * File request interface
  31746. */
  31747. export interface IFileRequest {
  31748. /**
  31749. * Raised when the request is complete (success or error).
  31750. */
  31751. onCompleteObservable: Observable<IFileRequest>;
  31752. /**
  31753. * Aborts the request for a file.
  31754. */
  31755. abort: () => void;
  31756. }
  31757. /**
  31758. * Class containing a set of static utilities functions
  31759. */
  31760. export class Tools {
  31761. /**
  31762. * Gets or sets the base URL to use to load assets
  31763. */
  31764. static BaseUrl: string;
  31765. /**
  31766. * Enable/Disable Custom HTTP Request Headers globally.
  31767. * default = false
  31768. * @see CustomRequestHeaders
  31769. */
  31770. static UseCustomRequestHeaders: boolean;
  31771. /**
  31772. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31773. * i.e. when loading files, where the server/service expects an Authorization header.
  31774. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  31775. */
  31776. static CustomRequestHeaders: {
  31777. [key: string]: string;
  31778. };
  31779. /**
  31780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31781. */
  31782. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31783. /**
  31784. * Default behaviour for cors in the application.
  31785. * It can be a string if the expected behavior is identical in the entire app.
  31786. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31787. */
  31788. static CorsBehavior: string | ((url: string | string[]) => string);
  31789. /**
  31790. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31791. * @ignorenaming
  31792. */
  31793. static UseFallbackTexture: boolean;
  31794. /**
  31795. * Use this object to register external classes like custom textures or material
  31796. * to allow the laoders to instantiate them
  31797. */
  31798. static RegisteredExternalClasses: {
  31799. [key: string]: Object;
  31800. };
  31801. /**
  31802. * Texture content used if a texture cannot loaded
  31803. * @ignorenaming
  31804. */
  31805. static fallbackTexture: string;
  31806. /**
  31807. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31808. * @param u defines the coordinate on X axis
  31809. * @param v defines the coordinate on Y axis
  31810. * @param width defines the width of the source data
  31811. * @param height defines the height of the source data
  31812. * @param pixels defines the source byte array
  31813. * @param color defines the output color
  31814. */
  31815. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31816. /**
  31817. * Interpolates between a and b via alpha
  31818. * @param a The lower value (returned when alpha = 0)
  31819. * @param b The upper value (returned when alpha = 1)
  31820. * @param alpha The interpolation-factor
  31821. * @return The mixed value
  31822. */
  31823. static Mix(a: number, b: number, alpha: number): number;
  31824. /**
  31825. * Tries to instantiate a new object from a given class name
  31826. * @param className defines the class name to instantiate
  31827. * @returns the new object or null if the system was not able to do the instantiation
  31828. */
  31829. static Instantiate(className: string): any;
  31830. /**
  31831. * Provides a slice function that will work even on IE
  31832. * @param data defines the array to slice
  31833. * @param start defines the start of the data (optional)
  31834. * @param end defines the end of the data (optional)
  31835. * @returns the new sliced array
  31836. */
  31837. static Slice<T>(data: T, start?: number, end?: number): T;
  31838. /**
  31839. * Polyfill for setImmediate
  31840. * @param action defines the action to execute after the current execution block
  31841. */
  31842. static SetImmediate(action: () => void): void;
  31843. /**
  31844. * Function indicating if a number is an exponent of 2
  31845. * @param value defines the value to test
  31846. * @returns true if the value is an exponent of 2
  31847. */
  31848. static IsExponentOfTwo(value: number): boolean;
  31849. private static _tmpFloatArray;
  31850. /**
  31851. * Returns the nearest 32-bit single precision float representation of a Number
  31852. * @param value A Number. If the parameter is of a different type, it will get converted
  31853. * to a number or to NaN if it cannot be converted
  31854. * @returns number
  31855. */
  31856. static FloatRound(value: number): number;
  31857. /**
  31858. * Find the next highest power of two.
  31859. * @param x Number to start search from.
  31860. * @return Next highest power of two.
  31861. */
  31862. static CeilingPOT(x: number): number;
  31863. /**
  31864. * Find the next lowest power of two.
  31865. * @param x Number to start search from.
  31866. * @return Next lowest power of two.
  31867. */
  31868. static FloorPOT(x: number): number;
  31869. /**
  31870. * Find the nearest power of two.
  31871. * @param x Number to start search from.
  31872. * @return Next nearest power of two.
  31873. */
  31874. static NearestPOT(x: number): number;
  31875. /**
  31876. * Get the closest exponent of two
  31877. * @param value defines the value to approximate
  31878. * @param max defines the maximum value to return
  31879. * @param mode defines how to define the closest value
  31880. * @returns closest exponent of two of the given value
  31881. */
  31882. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31883. /**
  31884. * Extracts the filename from a path
  31885. * @param path defines the path to use
  31886. * @returns the filename
  31887. */
  31888. static GetFilename(path: string): string;
  31889. /**
  31890. * Extracts the "folder" part of a path (everything before the filename).
  31891. * @param uri The URI to extract the info from
  31892. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31893. * @returns The "folder" part of the path
  31894. */
  31895. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31896. /**
  31897. * Extracts text content from a DOM element hierarchy
  31898. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31899. */
  31900. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31901. /**
  31902. * Convert an angle in radians to degrees
  31903. * @param angle defines the angle to convert
  31904. * @returns the angle in degrees
  31905. */
  31906. static ToDegrees(angle: number): number;
  31907. /**
  31908. * Convert an angle in degrees to radians
  31909. * @param angle defines the angle to convert
  31910. * @returns the angle in radians
  31911. */
  31912. static ToRadians(angle: number): number;
  31913. /**
  31914. * Encode a buffer to a base64 string
  31915. * @param buffer defines the buffer to encode
  31916. * @returns the encoded string
  31917. */
  31918. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31919. /**
  31920. * Extracts minimum and maximum values from a list of indexed positions
  31921. * @param positions defines the positions to use
  31922. * @param indices defines the indices to the positions
  31923. * @param indexStart defines the start index
  31924. * @param indexCount defines the end index
  31925. * @param bias defines bias value to add to the result
  31926. * @return minimum and maximum values
  31927. */
  31928. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31929. minimum: Vector3;
  31930. maximum: Vector3;
  31931. };
  31932. /**
  31933. * Extracts minimum and maximum values from a list of positions
  31934. * @param positions defines the positions to use
  31935. * @param start defines the start index in the positions array
  31936. * @param count defines the number of positions to handle
  31937. * @param bias defines bias value to add to the result
  31938. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31939. * @return minimum and maximum values
  31940. */
  31941. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31942. minimum: Vector3;
  31943. maximum: Vector3;
  31944. };
  31945. /**
  31946. * Returns an array if obj is not an array
  31947. * @param obj defines the object to evaluate as an array
  31948. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31949. * @returns either obj directly if obj is an array or a new array containing obj
  31950. */
  31951. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31952. /**
  31953. * Gets the pointer prefix to use
  31954. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31955. */
  31956. static GetPointerPrefix(): string;
  31957. /**
  31958. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31959. * @param func - the function to be called
  31960. * @param requester - the object that will request the next frame. Falls back to window.
  31961. * @returns frame number
  31962. */
  31963. static QueueNewFrame(func: () => void, requester?: any): number;
  31964. /**
  31965. * Ask the browser to promote the current element to fullscreen rendering mode
  31966. * @param element defines the DOM element to promote
  31967. */
  31968. static RequestFullscreen(element: HTMLElement): void;
  31969. /**
  31970. * Asks the browser to exit fullscreen mode
  31971. */
  31972. static ExitFullscreen(): void;
  31973. /**
  31974. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31975. * @param url define the url we are trying
  31976. * @param element define the dom element where to configure the cors policy
  31977. */
  31978. static SetCorsBehavior(url: string | string[], element: {
  31979. crossOrigin: string | null;
  31980. }): void;
  31981. /**
  31982. * Removes unwanted characters from an url
  31983. * @param url defines the url to clean
  31984. * @returns the cleaned url
  31985. */
  31986. static CleanUrl(url: string): string;
  31987. /**
  31988. * Gets or sets a function used to pre-process url before using them to load assets
  31989. */
  31990. static PreprocessUrl: (url: string) => string;
  31991. /**
  31992. * Loads an image as an HTMLImageElement.
  31993. * @param input url string, ArrayBuffer, or Blob to load
  31994. * @param onLoad callback called when the image successfully loads
  31995. * @param onError callback called when the image fails to load
  31996. * @param offlineProvider offline provider for caching
  31997. * @returns the HTMLImageElement of the loaded image
  31998. */
  31999. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32000. /**
  32001. * Loads a file
  32002. * @param url url string, ArrayBuffer, or Blob to load
  32003. * @param onSuccess callback called when the file successfully loads
  32004. * @param onProgress callback called while file is loading (if the server supports this mode)
  32005. * @param offlineProvider defines the offline provider for caching
  32006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32007. * @param onError callback called when the file fails to load
  32008. * @returns a file request object
  32009. */
  32010. 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;
  32011. /**
  32012. * Load a script (identified by an url). When the url returns, the
  32013. * content of this file is added into a new script element, attached to the DOM (body element)
  32014. * @param scriptUrl defines the url of the script to laod
  32015. * @param onSuccess defines the callback called when the script is loaded
  32016. * @param onError defines the callback to call if an error occurs
  32017. */
  32018. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32019. /**
  32020. * Loads a file from a blob
  32021. * @param fileToLoad defines the blob to use
  32022. * @param callback defines the callback to call when data is loaded
  32023. * @param progressCallback defines the callback to call during loading process
  32024. * @returns a file request object
  32025. */
  32026. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32027. /**
  32028. * Loads a file
  32029. * @param fileToLoad defines the file to load
  32030. * @param callback defines the callback to call when data is loaded
  32031. * @param progressCallBack defines the callback to call during loading process
  32032. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32033. * @returns a file request object
  32034. */
  32035. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32036. /**
  32037. * Creates a data url from a given string content
  32038. * @param content defines the content to convert
  32039. * @returns the new data url link
  32040. */
  32041. static FileAsURL(content: string): string;
  32042. /**
  32043. * Format the given number to a specific decimal format
  32044. * @param value defines the number to format
  32045. * @param decimals defines the number of decimals to use
  32046. * @returns the formatted string
  32047. */
  32048. static Format(value: number, decimals?: number): string;
  32049. /**
  32050. * Checks if a given vector is inside a specific range
  32051. * @param v defines the vector to test
  32052. * @param min defines the minimum range
  32053. * @param max defines the maximum range
  32054. */
  32055. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32056. /**
  32057. * Tries to copy an object by duplicating every property
  32058. * @param source defines the source object
  32059. * @param destination defines the target object
  32060. * @param doNotCopyList defines a list of properties to avoid
  32061. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32062. */
  32063. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32064. /**
  32065. * Gets a boolean indicating if the given object has no own property
  32066. * @param obj defines the object to test
  32067. * @returns true if object has no own property
  32068. */
  32069. static IsEmpty(obj: any): boolean;
  32070. /**
  32071. * Function used to register events at window level
  32072. * @param events defines the events to register
  32073. */
  32074. static RegisterTopRootEvents(events: {
  32075. name: string;
  32076. handler: Nullable<(e: FocusEvent) => any>;
  32077. }[]): void;
  32078. /**
  32079. * Function used to unregister events from window level
  32080. * @param events defines the events to unregister
  32081. */
  32082. static UnregisterTopRootEvents(events: {
  32083. name: string;
  32084. handler: Nullable<(e: FocusEvent) => any>;
  32085. }[]): void;
  32086. /**
  32087. * Dumps the current bound framebuffer
  32088. * @param width defines the rendering width
  32089. * @param height defines the rendering height
  32090. * @param engine defines the hosting engine
  32091. * @param successCallback defines the callback triggered once the data are available
  32092. * @param mimeType defines the mime type of the result
  32093. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32094. */
  32095. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32096. /**
  32097. * Converts the canvas data to blob.
  32098. * This acts as a polyfill for browsers not supporting the to blob function.
  32099. * @param canvas Defines the canvas to extract the data from
  32100. * @param successCallback Defines the callback triggered once the data are available
  32101. * @param mimeType Defines the mime type of the result
  32102. */
  32103. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32104. /**
  32105. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32106. * @param successCallback defines the callback triggered once the data are available
  32107. * @param mimeType defines the mime type of the result
  32108. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32109. */
  32110. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32111. /**
  32112. * Downloads a blob in the browser
  32113. * @param blob defines the blob to download
  32114. * @param fileName defines the name of the downloaded file
  32115. */
  32116. static Download(blob: Blob, fileName: string): void;
  32117. /**
  32118. * Captures a screenshot of the current rendering
  32119. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32120. * @param engine defines the rendering engine
  32121. * @param camera defines the source camera
  32122. * @param size This parameter can be set to a single number or to an object with the
  32123. * following (optional) properties: precision, width, height. If a single number is passed,
  32124. * it will be used for both width and height. If an object is passed, the screenshot size
  32125. * will be derived from the parameters. The precision property is a multiplier allowing
  32126. * rendering at a higher or lower resolution
  32127. * @param successCallback defines the callback receives a single parameter which contains the
  32128. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32129. * src parameter of an <img> to display it
  32130. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32131. * Check your browser for supported MIME types
  32132. */
  32133. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32134. /**
  32135. * Generates an image screenshot from the specified camera.
  32136. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32137. * @param engine The engine to use for rendering
  32138. * @param camera The camera to use for rendering
  32139. * @param size This parameter can be set to a single number or to an object with the
  32140. * following (optional) properties: precision, width, height. If a single number is passed,
  32141. * it will be used for both width and height. If an object is passed, the screenshot size
  32142. * will be derived from the parameters. The precision property is a multiplier allowing
  32143. * rendering at a higher or lower resolution
  32144. * @param successCallback The callback receives a single parameter which contains the
  32145. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32146. * src parameter of an <img> to display it
  32147. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32148. * Check your browser for supported MIME types
  32149. * @param samples Texture samples (default: 1)
  32150. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32151. * @param fileName A name for for the downloaded file.
  32152. */
  32153. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32154. /**
  32155. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32156. * Be aware Math.random() could cause collisions, but:
  32157. * "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"
  32158. * @returns a pseudo random id
  32159. */
  32160. static RandomId(): string;
  32161. /**
  32162. * Test if the given uri is a base64 string
  32163. * @param uri The uri to test
  32164. * @return True if the uri is a base64 string or false otherwise
  32165. */
  32166. static IsBase64(uri: string): boolean;
  32167. /**
  32168. * Decode the given base64 uri.
  32169. * @param uri The uri to decode
  32170. * @return The decoded base64 data.
  32171. */
  32172. static DecodeBase64(uri: string): ArrayBuffer;
  32173. /**
  32174. * No log
  32175. */
  32176. static readonly NoneLogLevel: number;
  32177. /**
  32178. * Only message logs
  32179. */
  32180. static readonly MessageLogLevel: number;
  32181. /**
  32182. * Only warning logs
  32183. */
  32184. static readonly WarningLogLevel: number;
  32185. /**
  32186. * Only error logs
  32187. */
  32188. static readonly ErrorLogLevel: number;
  32189. /**
  32190. * All logs
  32191. */
  32192. static readonly AllLogLevel: number;
  32193. /**
  32194. * Gets a value indicating the number of loading errors
  32195. * @ignorenaming
  32196. */
  32197. static readonly errorsCount: number;
  32198. /**
  32199. * Callback called when a new log is added
  32200. */
  32201. static OnNewCacheEntry: (entry: string) => void;
  32202. /**
  32203. * Log a message to the console
  32204. * @param message defines the message to log
  32205. */
  32206. static Log(message: string): void;
  32207. /**
  32208. * Write a warning message to the console
  32209. * @param message defines the message to log
  32210. */
  32211. static Warn(message: string): void;
  32212. /**
  32213. * Write an error message to the console
  32214. * @param message defines the message to log
  32215. */
  32216. static Error(message: string): void;
  32217. /**
  32218. * Gets current log cache (list of logs)
  32219. */
  32220. static readonly LogCache: string;
  32221. /**
  32222. * Clears the log cache
  32223. */
  32224. static ClearLogCache(): void;
  32225. /**
  32226. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32227. */
  32228. static LogLevels: number;
  32229. /**
  32230. * Checks if the loaded document was accessed via `file:`-Protocol.
  32231. * @returns boolean
  32232. */
  32233. static IsFileURL(): boolean;
  32234. /**
  32235. * Checks if the window object exists
  32236. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32237. */
  32238. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32239. /**
  32240. * No performance log
  32241. */
  32242. static readonly PerformanceNoneLogLevel: number;
  32243. /**
  32244. * Use user marks to log performance
  32245. */
  32246. static readonly PerformanceUserMarkLogLevel: number;
  32247. /**
  32248. * Log performance to the console
  32249. */
  32250. static readonly PerformanceConsoleLogLevel: number;
  32251. private static _performance;
  32252. /**
  32253. * Sets the current performance log level
  32254. */
  32255. static PerformanceLogLevel: number;
  32256. private static _StartPerformanceCounterDisabled;
  32257. private static _EndPerformanceCounterDisabled;
  32258. private static _StartUserMark;
  32259. private static _EndUserMark;
  32260. private static _StartPerformanceConsole;
  32261. private static _EndPerformanceConsole;
  32262. /**
  32263. * Injects the @see CustomRequestHeaders into the given request
  32264. * @param request the request that should be used for injection
  32265. */
  32266. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  32267. /**
  32268. * Starts a performance counter
  32269. */
  32270. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32271. /**
  32272. * Ends a specific performance coutner
  32273. */
  32274. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32275. /**
  32276. * Gets either window.performance.now() if supported or Date.now() else
  32277. */
  32278. static readonly Now: number;
  32279. /**
  32280. * This method will return the name of the class used to create the instance of the given object.
  32281. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32282. * @param object the object to get the class name from
  32283. * @param isType defines if the object is actually a type
  32284. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32285. */
  32286. static GetClassName(object: any, isType?: boolean): string;
  32287. /**
  32288. * Gets the first element of an array satisfying a given predicate
  32289. * @param array defines the array to browse
  32290. * @param predicate defines the predicate to use
  32291. * @returns null if not found or the element
  32292. */
  32293. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32294. /**
  32295. * This method will return the name of the full name of the class, including its owning module (if any).
  32296. * 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).
  32297. * @param object the object to get the class name from
  32298. * @param isType defines if the object is actually a type
  32299. * @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.
  32300. * @ignorenaming
  32301. */
  32302. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32303. /**
  32304. * Returns a promise that resolves after the given amount of time.
  32305. * @param delay Number of milliseconds to delay
  32306. * @returns Promise that resolves after the given amount of time
  32307. */
  32308. static DelayAsync(delay: number): Promise<void>;
  32309. /**
  32310. * Gets the current gradient from an array of IValueGradient
  32311. * @param ratio defines the current ratio to get
  32312. * @param gradients defines the array of IValueGradient
  32313. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32314. */
  32315. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32316. }
  32317. /**
  32318. * This class is used to track a performance counter which is number based.
  32319. * The user has access to many properties which give statistics of different nature.
  32320. *
  32321. * The implementer can track two kinds of Performance Counter: time and count.
  32322. * 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.
  32323. * 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.
  32324. */
  32325. export class PerfCounter {
  32326. /**
  32327. * Gets or sets a global boolean to turn on and off all the counters
  32328. */
  32329. static Enabled: boolean;
  32330. /**
  32331. * Returns the smallest value ever
  32332. */
  32333. readonly min: number;
  32334. /**
  32335. * Returns the biggest value ever
  32336. */
  32337. readonly max: number;
  32338. /**
  32339. * Returns the average value since the performance counter is running
  32340. */
  32341. readonly average: number;
  32342. /**
  32343. * Returns the average value of the last second the counter was monitored
  32344. */
  32345. readonly lastSecAverage: number;
  32346. /**
  32347. * Returns the current value
  32348. */
  32349. readonly current: number;
  32350. /**
  32351. * Gets the accumulated total
  32352. */
  32353. readonly total: number;
  32354. /**
  32355. * Gets the total value count
  32356. */
  32357. readonly count: number;
  32358. /**
  32359. * Creates a new counter
  32360. */
  32361. constructor();
  32362. /**
  32363. * Call this method to start monitoring a new frame.
  32364. * 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.
  32365. */
  32366. fetchNewFrame(): void;
  32367. /**
  32368. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32369. * @param newCount the count value to add to the monitored count
  32370. * @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.
  32371. */
  32372. addCount(newCount: number, fetchResult: boolean): void;
  32373. /**
  32374. * Start monitoring this performance counter
  32375. */
  32376. beginMonitoring(): void;
  32377. /**
  32378. * Compute the time lapsed since the previous beginMonitoring() call.
  32379. * @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
  32380. */
  32381. endMonitoring(newFrame?: boolean): void;
  32382. private _fetchResult;
  32383. private _startMonitoringTime;
  32384. private _min;
  32385. private _max;
  32386. private _average;
  32387. private _current;
  32388. private _totalValueCount;
  32389. private _totalAccumulated;
  32390. private _lastSecAverage;
  32391. private _lastSecAccumulated;
  32392. private _lastSecTime;
  32393. private _lastSecValueCount;
  32394. }
  32395. /**
  32396. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32397. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32398. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32399. * @param name The name of the class, case should be preserved
  32400. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32401. */
  32402. export function className(name: string, module?: string): (target: Object) => void;
  32403. /**
  32404. * An implementation of a loop for asynchronous functions.
  32405. */
  32406. export class AsyncLoop {
  32407. /**
  32408. * Defines the number of iterations for the loop
  32409. */
  32410. iterations: number;
  32411. /**
  32412. * Defines the current index of the loop.
  32413. */
  32414. index: number;
  32415. private _done;
  32416. private _fn;
  32417. private _successCallback;
  32418. /**
  32419. * Constructor.
  32420. * @param iterations the number of iterations.
  32421. * @param func the function to run each iteration
  32422. * @param successCallback the callback that will be called upon succesful execution
  32423. * @param offset starting offset.
  32424. */
  32425. constructor(
  32426. /**
  32427. * Defines the number of iterations for the loop
  32428. */
  32429. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32430. /**
  32431. * Execute the next iteration. Must be called after the last iteration was finished.
  32432. */
  32433. executeNext(): void;
  32434. /**
  32435. * Break the loop and run the success callback.
  32436. */
  32437. breakLoop(): void;
  32438. /**
  32439. * Create and run an async loop.
  32440. * @param iterations the number of iterations.
  32441. * @param fn the function to run each iteration
  32442. * @param successCallback the callback that will be called upon succesful execution
  32443. * @param offset starting offset.
  32444. * @returns the created async loop object
  32445. */
  32446. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32447. /**
  32448. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32449. * @param iterations total number of iterations
  32450. * @param syncedIterations number of synchronous iterations in each async iteration.
  32451. * @param fn the function to call each iteration.
  32452. * @param callback a success call back that will be called when iterating stops.
  32453. * @param breakFunction a break condition (optional)
  32454. * @param timeout timeout settings for the setTimeout function. default - 0.
  32455. * @returns the created async loop object
  32456. */
  32457. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32458. }
  32459. }
  32460. declare module "babylonjs/Animations/animationGroup" {
  32461. import { Animatable } from "babylonjs/Animations/animatable";
  32462. import { Animation } from "babylonjs/Animations/animation";
  32463. import { Scene, IDisposable } from "babylonjs/scene";
  32464. import { Observable } from "babylonjs/Misc/observable";
  32465. import { Nullable } from "babylonjs/types";
  32466. /**
  32467. * This class defines the direct association between an animation and a target
  32468. */
  32469. export class TargetedAnimation {
  32470. /**
  32471. * Animation to perform
  32472. */
  32473. animation: Animation;
  32474. /**
  32475. * Target to animate
  32476. */
  32477. target: any;
  32478. }
  32479. /**
  32480. * Use this class to create coordinated animations on multiple targets
  32481. */
  32482. export class AnimationGroup implements IDisposable {
  32483. /** The name of the animation group */
  32484. name: string;
  32485. private _scene;
  32486. private _targetedAnimations;
  32487. private _animatables;
  32488. private _from;
  32489. private _to;
  32490. private _isStarted;
  32491. private _isPaused;
  32492. private _speedRatio;
  32493. /**
  32494. * Gets or sets the unique id of the node
  32495. */
  32496. uniqueId: number;
  32497. /**
  32498. * This observable will notify when one animation have ended
  32499. */
  32500. onAnimationEndObservable: Observable<TargetedAnimation>;
  32501. /**
  32502. * Observer raised when one animation loops
  32503. */
  32504. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32505. /**
  32506. * This observable will notify when all animations have ended.
  32507. */
  32508. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32509. /**
  32510. * This observable will notify when all animations have paused.
  32511. */
  32512. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32513. /**
  32514. * This observable will notify when all animations are playing.
  32515. */
  32516. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32517. /**
  32518. * Gets the first frame
  32519. */
  32520. readonly from: number;
  32521. /**
  32522. * Gets the last frame
  32523. */
  32524. readonly to: number;
  32525. /**
  32526. * Define if the animations are started
  32527. */
  32528. readonly isStarted: boolean;
  32529. /**
  32530. * Gets a value indicating that the current group is playing
  32531. */
  32532. readonly isPlaying: boolean;
  32533. /**
  32534. * Gets or sets the speed ratio to use for all animations
  32535. */
  32536. /**
  32537. * Gets or sets the speed ratio to use for all animations
  32538. */
  32539. speedRatio: number;
  32540. /**
  32541. * Gets the targeted animations for this animation group
  32542. */
  32543. readonly targetedAnimations: Array<TargetedAnimation>;
  32544. /**
  32545. * returning the list of animatables controlled by this animation group.
  32546. */
  32547. readonly animatables: Array<Animatable>;
  32548. /**
  32549. * Instantiates a new Animation Group.
  32550. * This helps managing several animations at once.
  32551. * @see http://doc.babylonjs.com/how_to/group
  32552. * @param name Defines the name of the group
  32553. * @param scene Defines the scene the group belongs to
  32554. */
  32555. constructor(
  32556. /** The name of the animation group */
  32557. name: string, scene?: Nullable<Scene>);
  32558. /**
  32559. * Add an animation (with its target) in the group
  32560. * @param animation defines the animation we want to add
  32561. * @param target defines the target of the animation
  32562. * @returns the TargetedAnimation object
  32563. */
  32564. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32565. /**
  32566. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32567. * It can add constant keys at begin or end
  32568. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32569. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32570. * @returns the animation group
  32571. */
  32572. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32573. /**
  32574. * Start all animations on given targets
  32575. * @param loop defines if animations must loop
  32576. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32577. * @param from defines the from key (optional)
  32578. * @param to defines the to key (optional)
  32579. * @returns the current animation group
  32580. */
  32581. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32582. /**
  32583. * Pause all animations
  32584. * @returns the animation group
  32585. */
  32586. pause(): AnimationGroup;
  32587. /**
  32588. * Play all animations to initial state
  32589. * This function will start() the animations if they were not started or will restart() them if they were paused
  32590. * @param loop defines if animations must loop
  32591. * @returns the animation group
  32592. */
  32593. play(loop?: boolean): AnimationGroup;
  32594. /**
  32595. * Reset all animations to initial state
  32596. * @returns the animation group
  32597. */
  32598. reset(): AnimationGroup;
  32599. /**
  32600. * Restart animations from key 0
  32601. * @returns the animation group
  32602. */
  32603. restart(): AnimationGroup;
  32604. /**
  32605. * Stop all animations
  32606. * @returns the animation group
  32607. */
  32608. stop(): AnimationGroup;
  32609. /**
  32610. * Set animation weight for all animatables
  32611. * @param weight defines the weight to use
  32612. * @return the animationGroup
  32613. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32614. */
  32615. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32616. /**
  32617. * Synchronize and normalize all animatables with a source animatable
  32618. * @param root defines the root animatable to synchronize with
  32619. * @return the animationGroup
  32620. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32621. */
  32622. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32623. /**
  32624. * Goes to a specific frame in this animation group
  32625. * @param frame the frame number to go to
  32626. * @return the animationGroup
  32627. */
  32628. goToFrame(frame: number): AnimationGroup;
  32629. /**
  32630. * Dispose all associated resources
  32631. */
  32632. dispose(): void;
  32633. private _checkAnimationGroupEnded;
  32634. /**
  32635. * Returns a new AnimationGroup object parsed from the source provided.
  32636. * @param parsedAnimationGroup defines the source
  32637. * @param scene defines the scene that will receive the animationGroup
  32638. * @returns a new AnimationGroup
  32639. */
  32640. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32641. /**
  32642. * Returns the string "AnimationGroup"
  32643. * @returns "AnimationGroup"
  32644. */
  32645. getClassName(): string;
  32646. /**
  32647. * Creates a detailled string about the object
  32648. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32649. * @returns a string representing the object
  32650. */
  32651. toString(fullDetails?: boolean): string;
  32652. }
  32653. }
  32654. declare module "babylonjs/Collisions/collisionCoordinator" {
  32655. import { Nullable } from "babylonjs/types";
  32656. import { Scene } from "babylonjs/scene";
  32657. import { Vector3 } from "babylonjs/Maths/math";
  32658. import { Collider } from "babylonjs/Collisions/collider";
  32659. import { Geometry } from "babylonjs/Meshes/geometry";
  32660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32661. /** @hidden */
  32662. export interface ICollisionCoordinator {
  32663. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32664. init(scene: Scene): void;
  32665. destroy(): void;
  32666. onMeshAdded(mesh: AbstractMesh): void;
  32667. onMeshUpdated(mesh: AbstractMesh): void;
  32668. onMeshRemoved(mesh: AbstractMesh): void;
  32669. onGeometryAdded(geometry: Geometry): void;
  32670. onGeometryUpdated(geometry: Geometry): void;
  32671. onGeometryDeleted(geometry: Geometry): void;
  32672. }
  32673. /** @hidden */
  32674. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  32675. private _scene;
  32676. private _scaledPosition;
  32677. private _scaledVelocity;
  32678. private _finalPosition;
  32679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32680. init(scene: Scene): void;
  32681. destroy(): void;
  32682. onMeshAdded(mesh: AbstractMesh): void;
  32683. onMeshUpdated(mesh: AbstractMesh): void;
  32684. onMeshRemoved(mesh: AbstractMesh): void;
  32685. onGeometryAdded(geometry: Geometry): void;
  32686. onGeometryUpdated(geometry: Geometry): void;
  32687. onGeometryDeleted(geometry: Geometry): void;
  32688. private _collideWithWorld;
  32689. }
  32690. }
  32691. declare module "babylonjs/scene" {
  32692. import { Nullable } from "babylonjs/types";
  32693. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32694. import { Observable } from "babylonjs/Misc/observable";
  32695. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32696. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32697. import { Geometry } from "babylonjs/Meshes/geometry";
  32698. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32701. import { Mesh } from "babylonjs/Meshes/mesh";
  32702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32703. import { Bone } from "babylonjs/Bones/bone";
  32704. import { Skeleton } from "babylonjs/Bones/skeleton";
  32705. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32706. import { Camera } from "babylonjs/Cameras/camera";
  32707. import { AbstractScene } from "babylonjs/abstractScene";
  32708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32710. import { Material } from "babylonjs/Materials/material";
  32711. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32712. import { Effect } from "babylonjs/Materials/effect";
  32713. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32714. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32715. import { Animation } from "babylonjs/Animations/animation";
  32716. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  32717. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32718. import { Animatable } from "babylonjs/Animations/animatable";
  32719. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32720. import { Light } from "babylonjs/Lights/light";
  32721. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32722. import { Collider } from "babylonjs/Collisions/collider";
  32723. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32724. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32725. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32726. import { ActionManager } from "babylonjs/Actions/actionManager";
  32727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32728. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32729. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32730. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32731. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32732. import { Engine } from "babylonjs/Engines/engine";
  32733. import { Ray } from "babylonjs/Culling/ray";
  32734. import { Node } from "babylonjs/node";
  32735. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32736. /**
  32737. * Define an interface for all classes that will hold resources
  32738. */
  32739. export interface IDisposable {
  32740. /**
  32741. * Releases all held resources
  32742. */
  32743. dispose(): void;
  32744. }
  32745. /** Interface defining initialization parameters for Scene class */
  32746. export interface SceneOptions {
  32747. /**
  32748. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32749. * It will improve performance when the number of geometries becomes important.
  32750. */
  32751. useGeometryUniqueIdsMap?: boolean;
  32752. /**
  32753. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32754. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32755. */
  32756. useMaterialMeshMap?: boolean;
  32757. /**
  32758. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32759. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32760. */
  32761. useClonedMeshhMap?: boolean;
  32762. }
  32763. /**
  32764. * Represents a scene to be rendered by the engine.
  32765. * @see http://doc.babylonjs.com/features/scene
  32766. */
  32767. export class Scene extends AbstractScene implements IAnimatable {
  32768. private static _uniqueIdCounter;
  32769. /** The fog is deactivated */
  32770. static readonly FOGMODE_NONE: number;
  32771. /** The fog density is following an exponential function */
  32772. static readonly FOGMODE_EXP: number;
  32773. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32774. static readonly FOGMODE_EXP2: number;
  32775. /** The fog density is following a linear function. */
  32776. static readonly FOGMODE_LINEAR: number;
  32777. /**
  32778. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32780. */
  32781. static MinDeltaTime: number;
  32782. /**
  32783. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32785. */
  32786. static MaxDeltaTime: number;
  32787. /**
  32788. * Factory used to create the default material.
  32789. * @param name The name of the material to create
  32790. * @param scene The scene to create the material for
  32791. * @returns The default material
  32792. */
  32793. static DefaultMaterialFactory(scene: Scene): Material;
  32794. /** @hidden */
  32795. readonly _isScene: boolean;
  32796. /**
  32797. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32798. */
  32799. autoClear: boolean;
  32800. /**
  32801. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32802. */
  32803. autoClearDepthAndStencil: boolean;
  32804. /**
  32805. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32806. */
  32807. clearColor: Color4;
  32808. /**
  32809. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32810. */
  32811. ambientColor: Color3;
  32812. /** @hidden */
  32813. _environmentBRDFTexture: BaseTexture;
  32814. /** @hidden */
  32815. protected _environmentTexture: Nullable<BaseTexture>;
  32816. /**
  32817. * Texture used in all pbr material as the reflection texture.
  32818. * As in the majority of the scene they are the same (exception for multi room and so on),
  32819. * this is easier to reference from here than from all the materials.
  32820. */
  32821. /**
  32822. * Texture used in all pbr material as the reflection texture.
  32823. * As in the majority of the scene they are the same (exception for multi room and so on),
  32824. * this is easier to set here than in all the materials.
  32825. */
  32826. environmentTexture: Nullable<BaseTexture>;
  32827. /** @hidden */
  32828. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32829. /**
  32830. * Default image processing configuration used either in the rendering
  32831. * Forward main pass or through the imageProcessingPostProcess if present.
  32832. * As in the majority of the scene they are the same (exception for multi camera),
  32833. * this is easier to reference from here than from all the materials and post process.
  32834. *
  32835. * No setter as we it is a shared configuration, you can set the values instead.
  32836. */
  32837. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32838. private _forceWireframe;
  32839. /**
  32840. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32841. */
  32842. forceWireframe: boolean;
  32843. private _forcePointsCloud;
  32844. /**
  32845. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32846. */
  32847. forcePointsCloud: boolean;
  32848. /**
  32849. * Gets or sets the active clipplane 1
  32850. */
  32851. clipPlane: Nullable<Plane>;
  32852. /**
  32853. * Gets or sets the active clipplane 2
  32854. */
  32855. clipPlane2: Nullable<Plane>;
  32856. /**
  32857. * Gets or sets the active clipplane 3
  32858. */
  32859. clipPlane3: Nullable<Plane>;
  32860. /**
  32861. * Gets or sets the active clipplane 4
  32862. */
  32863. clipPlane4: Nullable<Plane>;
  32864. /**
  32865. * Gets or sets a boolean indicating if animations are enabled
  32866. */
  32867. animationsEnabled: boolean;
  32868. private _animationPropertiesOverride;
  32869. /**
  32870. * Gets or sets the animation properties override
  32871. */
  32872. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32873. /**
  32874. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32875. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32876. */
  32877. useConstantAnimationDeltaTime: boolean;
  32878. /**
  32879. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32880. * Please note that it requires to run a ray cast through the scene on every frame
  32881. */
  32882. constantlyUpdateMeshUnderPointer: boolean;
  32883. /**
  32884. * Defines the HTML cursor to use when hovering over interactive elements
  32885. */
  32886. hoverCursor: string;
  32887. /**
  32888. * Defines the HTML default cursor to use (empty by default)
  32889. */
  32890. defaultCursor: string;
  32891. /**
  32892. * This is used to call preventDefault() on pointer down
  32893. * in order to block unwanted artifacts like system double clicks
  32894. */
  32895. preventDefaultOnPointerDown: boolean;
  32896. /**
  32897. * This is used to call preventDefault() on pointer up
  32898. * in order to block unwanted artifacts like system double clicks
  32899. */
  32900. preventDefaultOnPointerUp: boolean;
  32901. /**
  32902. * Gets or sets user defined metadata
  32903. */
  32904. metadata: any;
  32905. /**
  32906. * For internal use only. Please do not use.
  32907. */
  32908. reservedDataStore: any;
  32909. /**
  32910. * Gets the name of the plugin used to load this scene (null by default)
  32911. */
  32912. loadingPluginName: string;
  32913. /**
  32914. * Use this array to add regular expressions used to disable offline support for specific urls
  32915. */
  32916. disableOfflineSupportExceptionRules: RegExp[];
  32917. /**
  32918. * An event triggered when the scene is disposed.
  32919. */
  32920. onDisposeObservable: Observable<Scene>;
  32921. private _onDisposeObserver;
  32922. /** Sets a function to be executed when this scene is disposed. */
  32923. onDispose: () => void;
  32924. /**
  32925. * An event triggered before rendering the scene (right after animations and physics)
  32926. */
  32927. onBeforeRenderObservable: Observable<Scene>;
  32928. private _onBeforeRenderObserver;
  32929. /** Sets a function to be executed before rendering this scene */
  32930. beforeRender: Nullable<() => void>;
  32931. /**
  32932. * An event triggered after rendering the scene
  32933. */
  32934. onAfterRenderObservable: Observable<Scene>;
  32935. private _onAfterRenderObserver;
  32936. /** Sets a function to be executed after rendering this scene */
  32937. afterRender: Nullable<() => void>;
  32938. /**
  32939. * An event triggered before animating the scene
  32940. */
  32941. onBeforeAnimationsObservable: Observable<Scene>;
  32942. /**
  32943. * An event triggered after animations processing
  32944. */
  32945. onAfterAnimationsObservable: Observable<Scene>;
  32946. /**
  32947. * An event triggered before draw calls are ready to be sent
  32948. */
  32949. onBeforeDrawPhaseObservable: Observable<Scene>;
  32950. /**
  32951. * An event triggered after draw calls have been sent
  32952. */
  32953. onAfterDrawPhaseObservable: Observable<Scene>;
  32954. /**
  32955. * An event triggered when the scene is ready
  32956. */
  32957. onReadyObservable: Observable<Scene>;
  32958. /**
  32959. * An event triggered before rendering a camera
  32960. */
  32961. onBeforeCameraRenderObservable: Observable<Camera>;
  32962. private _onBeforeCameraRenderObserver;
  32963. /** Sets a function to be executed before rendering a camera*/
  32964. beforeCameraRender: () => void;
  32965. /**
  32966. * An event triggered after rendering a camera
  32967. */
  32968. onAfterCameraRenderObservable: Observable<Camera>;
  32969. private _onAfterCameraRenderObserver;
  32970. /** Sets a function to be executed after rendering a camera*/
  32971. afterCameraRender: () => void;
  32972. /**
  32973. * An event triggered when active meshes evaluation is about to start
  32974. */
  32975. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32976. /**
  32977. * An event triggered when active meshes evaluation is done
  32978. */
  32979. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32980. /**
  32981. * An event triggered when particles rendering is about to start
  32982. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32983. */
  32984. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32985. /**
  32986. * An event triggered when particles rendering is done
  32987. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32988. */
  32989. onAfterParticlesRenderingObservable: Observable<Scene>;
  32990. /**
  32991. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32992. */
  32993. onDataLoadedObservable: Observable<Scene>;
  32994. /**
  32995. * An event triggered when a camera is created
  32996. */
  32997. onNewCameraAddedObservable: Observable<Camera>;
  32998. /**
  32999. * An event triggered when a camera is removed
  33000. */
  33001. onCameraRemovedObservable: Observable<Camera>;
  33002. /**
  33003. * An event triggered when a light is created
  33004. */
  33005. onNewLightAddedObservable: Observable<Light>;
  33006. /**
  33007. * An event triggered when a light is removed
  33008. */
  33009. onLightRemovedObservable: Observable<Light>;
  33010. /**
  33011. * An event triggered when a geometry is created
  33012. */
  33013. onNewGeometryAddedObservable: Observable<Geometry>;
  33014. /**
  33015. * An event triggered when a geometry is removed
  33016. */
  33017. onGeometryRemovedObservable: Observable<Geometry>;
  33018. /**
  33019. * An event triggered when a transform node is created
  33020. */
  33021. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33022. /**
  33023. * An event triggered when a transform node is removed
  33024. */
  33025. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33026. /**
  33027. * An event triggered when a mesh is created
  33028. */
  33029. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33030. /**
  33031. * An event triggered when a mesh is removed
  33032. */
  33033. onMeshRemovedObservable: Observable<AbstractMesh>;
  33034. /**
  33035. * An event triggered when a material is created
  33036. */
  33037. onNewMaterialAddedObservable: Observable<Material>;
  33038. /**
  33039. * An event triggered when a material is removed
  33040. */
  33041. onMaterialRemovedObservable: Observable<Material>;
  33042. /**
  33043. * An event triggered when a texture is created
  33044. */
  33045. onNewTextureAddedObservable: Observable<BaseTexture>;
  33046. /**
  33047. * An event triggered when a texture is removed
  33048. */
  33049. onTextureRemovedObservable: Observable<BaseTexture>;
  33050. /**
  33051. * An event triggered when render targets are about to be rendered
  33052. * Can happen multiple times per frame.
  33053. */
  33054. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33055. /**
  33056. * An event triggered when render targets were rendered.
  33057. * Can happen multiple times per frame.
  33058. */
  33059. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered before calculating deterministic simulation step
  33062. */
  33063. onBeforeStepObservable: Observable<Scene>;
  33064. /**
  33065. * An event triggered after calculating deterministic simulation step
  33066. */
  33067. onAfterStepObservable: Observable<Scene>;
  33068. /**
  33069. * An event triggered when the activeCamera property is updated
  33070. */
  33071. onActiveCameraChanged: Observable<Scene>;
  33072. /**
  33073. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33074. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33075. * 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)
  33076. */
  33077. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33078. /**
  33079. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33080. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33081. * 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)
  33082. */
  33083. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33084. /**
  33085. * This Observable will when a mesh has been imported into the scene.
  33086. */
  33087. onMeshImportedObservable: Observable<AbstractMesh>;
  33088. private _registeredForLateAnimationBindings;
  33089. /**
  33090. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33091. */
  33092. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33093. /**
  33094. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33095. */
  33096. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33097. /**
  33098. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33099. */
  33100. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33101. private _onPointerMove;
  33102. private _onPointerDown;
  33103. private _onPointerUp;
  33104. /** Callback called when a pointer move is detected */
  33105. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33106. /** Callback called when a pointer down is detected */
  33107. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33108. /** Callback called when a pointer up is detected */
  33109. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33110. /** Callback called when a pointer pick is detected */
  33111. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33112. /**
  33113. * 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).
  33114. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33115. */
  33116. onPrePointerObservable: Observable<PointerInfoPre>;
  33117. /**
  33118. * Observable event triggered each time an input event is received from the rendering canvas
  33119. */
  33120. onPointerObservable: Observable<PointerInfo>;
  33121. /**
  33122. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33123. */
  33124. readonly unTranslatedPointer: Vector2;
  33125. /** The distance in pixel that you have to move to prevent some events */
  33126. static DragMovementThreshold: number;
  33127. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33128. static LongPressDelay: number;
  33129. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33130. static DoubleClickDelay: number;
  33131. /** If you need to check double click without raising a single click at first click, enable this flag */
  33132. static ExclusiveDoubleClickMode: boolean;
  33133. private _initClickEvent;
  33134. private _initActionManager;
  33135. private _delayedSimpleClick;
  33136. private _delayedSimpleClickTimeout;
  33137. private _previousDelayedSimpleClickTimeout;
  33138. private _meshPickProceed;
  33139. private _previousButtonPressed;
  33140. private _currentPickResult;
  33141. private _previousPickResult;
  33142. private _totalPointersPressed;
  33143. private _doubleClickOccured;
  33144. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33145. cameraToUseForPointers: Nullable<Camera>;
  33146. private _pointerX;
  33147. private _pointerY;
  33148. private _unTranslatedPointerX;
  33149. private _unTranslatedPointerY;
  33150. private _startingPointerPosition;
  33151. private _previousStartingPointerPosition;
  33152. private _startingPointerTime;
  33153. private _previousStartingPointerTime;
  33154. private _pointerCaptures;
  33155. private _timeAccumulator;
  33156. private _currentStepId;
  33157. private _currentInternalStep;
  33158. /** @hidden */
  33159. _mirroredCameraPosition: Nullable<Vector3>;
  33160. /**
  33161. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33162. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33163. */
  33164. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33165. /**
  33166. * Observable event triggered each time an keyboard event is received from the hosting window
  33167. */
  33168. onKeyboardObservable: Observable<KeyboardInfo>;
  33169. private _onKeyDown;
  33170. private _onKeyUp;
  33171. private _onCanvasFocusObserver;
  33172. private _onCanvasBlurObserver;
  33173. private _useRightHandedSystem;
  33174. /**
  33175. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33176. */
  33177. useRightHandedSystem: boolean;
  33178. /**
  33179. * Sets the step Id used by deterministic lock step
  33180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33181. * @param newStepId defines the step Id
  33182. */
  33183. setStepId(newStepId: number): void;
  33184. /**
  33185. * Gets the step Id used by deterministic lock step
  33186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33187. * @returns the step Id
  33188. */
  33189. getStepId(): number;
  33190. /**
  33191. * Gets the internal step used by deterministic lock step
  33192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33193. * @returns the internal step
  33194. */
  33195. getInternalStep(): number;
  33196. private _fogEnabled;
  33197. /**
  33198. * Gets or sets a boolean indicating if fog is enabled on this scene
  33199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33200. * (Default is true)
  33201. */
  33202. fogEnabled: boolean;
  33203. private _fogMode;
  33204. /**
  33205. * Gets or sets the fog mode to use
  33206. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33207. * | mode | value |
  33208. * | --- | --- |
  33209. * | FOGMODE_NONE | 0 |
  33210. * | FOGMODE_EXP | 1 |
  33211. * | FOGMODE_EXP2 | 2 |
  33212. * | FOGMODE_LINEAR | 3 |
  33213. */
  33214. fogMode: number;
  33215. /**
  33216. * Gets or sets the fog color to use
  33217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33218. * (Default is Color3(0.2, 0.2, 0.3))
  33219. */
  33220. fogColor: Color3;
  33221. /**
  33222. * Gets or sets the fog density to use
  33223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33224. * (Default is 0.1)
  33225. */
  33226. fogDensity: number;
  33227. /**
  33228. * Gets or sets the fog start distance to use
  33229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33230. * (Default is 0)
  33231. */
  33232. fogStart: number;
  33233. /**
  33234. * Gets or sets the fog end distance to use
  33235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33236. * (Default is 1000)
  33237. */
  33238. fogEnd: number;
  33239. private _shadowsEnabled;
  33240. /**
  33241. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33242. */
  33243. shadowsEnabled: boolean;
  33244. private _lightsEnabled;
  33245. /**
  33246. * Gets or sets a boolean indicating if lights are enabled on this scene
  33247. */
  33248. lightsEnabled: boolean;
  33249. /** All of the active cameras added to this scene. */
  33250. activeCameras: Camera[];
  33251. private _activeCamera;
  33252. /** Gets or sets the current active camera */
  33253. activeCamera: Nullable<Camera>;
  33254. private _defaultMaterial;
  33255. /** The default material used on meshes when no material is affected */
  33256. /** The default material used on meshes when no material is affected */
  33257. defaultMaterial: Material;
  33258. private _texturesEnabled;
  33259. /**
  33260. * Gets or sets a boolean indicating if textures are enabled on this scene
  33261. */
  33262. texturesEnabled: boolean;
  33263. /**
  33264. * Gets or sets a boolean indicating if particles are enabled on this scene
  33265. */
  33266. particlesEnabled: boolean;
  33267. /**
  33268. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33269. */
  33270. spritesEnabled: boolean;
  33271. private _skeletonsEnabled;
  33272. /**
  33273. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33274. */
  33275. skeletonsEnabled: boolean;
  33276. /**
  33277. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33278. */
  33279. lensFlaresEnabled: boolean;
  33280. /**
  33281. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33283. */
  33284. collisionsEnabled: boolean;
  33285. /** @hidden */
  33286. collisionCoordinator: ICollisionCoordinator;
  33287. /**
  33288. * Defines the gravity applied to this scene (used only for collisions)
  33289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33290. */
  33291. gravity: Vector3;
  33292. /**
  33293. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33294. */
  33295. postProcessesEnabled: boolean;
  33296. /**
  33297. * The list of postprocesses added to the scene
  33298. */
  33299. postProcesses: PostProcess[];
  33300. /**
  33301. * Gets the current postprocess manager
  33302. */
  33303. postProcessManager: PostProcessManager;
  33304. /**
  33305. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33306. */
  33307. renderTargetsEnabled: boolean;
  33308. /**
  33309. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33310. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33311. */
  33312. dumpNextRenderTargets: boolean;
  33313. /**
  33314. * The list of user defined render targets added to the scene
  33315. */
  33316. customRenderTargets: RenderTargetTexture[];
  33317. /**
  33318. * Defines if texture loading must be delayed
  33319. * If true, textures will only be loaded when they need to be rendered
  33320. */
  33321. useDelayedTextureLoading: boolean;
  33322. /**
  33323. * Gets the list of meshes imported to the scene through SceneLoader
  33324. */
  33325. importedMeshesFiles: String[];
  33326. /**
  33327. * Gets or sets a boolean indicating if probes are enabled on this scene
  33328. */
  33329. probesEnabled: boolean;
  33330. /**
  33331. * Gets or sets the current offline provider to use to store scene data
  33332. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33333. */
  33334. offlineProvider: IOfflineProvider;
  33335. /**
  33336. * Gets or sets the action manager associated with the scene
  33337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33338. */
  33339. actionManager: ActionManager;
  33340. private _meshesForIntersections;
  33341. /**
  33342. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33343. */
  33344. proceduralTexturesEnabled: boolean;
  33345. private _engine;
  33346. private _totalVertices;
  33347. /** @hidden */
  33348. _activeIndices: PerfCounter;
  33349. /** @hidden */
  33350. _activeParticles: PerfCounter;
  33351. /** @hidden */
  33352. _activeBones: PerfCounter;
  33353. private _animationRatio;
  33354. private _animationTimeLast;
  33355. private _animationTime;
  33356. /**
  33357. * Gets or sets a general scale for animation speed
  33358. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33359. */
  33360. animationTimeScale: number;
  33361. /** @hidden */
  33362. _cachedMaterial: Nullable<Material>;
  33363. /** @hidden */
  33364. _cachedEffect: Nullable<Effect>;
  33365. /** @hidden */
  33366. _cachedVisibility: Nullable<number>;
  33367. private _renderId;
  33368. private _frameId;
  33369. private _executeWhenReadyTimeoutId;
  33370. private _intermediateRendering;
  33371. private _viewUpdateFlag;
  33372. private _projectionUpdateFlag;
  33373. private _alternateViewUpdateFlag;
  33374. private _alternateProjectionUpdateFlag;
  33375. /** @hidden */
  33376. _toBeDisposed: Nullable<IDisposable>[];
  33377. private _activeRequests;
  33378. private _pendingData;
  33379. private _isDisposed;
  33380. /**
  33381. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33382. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33383. */
  33384. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33385. private _activeMeshes;
  33386. private _processedMaterials;
  33387. private _renderTargets;
  33388. /** @hidden */
  33389. _activeParticleSystems: SmartArray<IParticleSystem>;
  33390. private _activeSkeletons;
  33391. private _softwareSkinnedMeshes;
  33392. private _renderingManager;
  33393. /** @hidden */
  33394. _activeAnimatables: Animatable[];
  33395. private _transformMatrix;
  33396. private _sceneUbo;
  33397. private _alternateSceneUbo;
  33398. private _pickWithRayInverseMatrix;
  33399. private _viewMatrix;
  33400. private _projectionMatrix;
  33401. private _alternateViewMatrix;
  33402. private _alternateProjectionMatrix;
  33403. private _alternateTransformMatrix;
  33404. private _useAlternateCameraConfiguration;
  33405. private _alternateRendering;
  33406. private _wheelEventName;
  33407. /** @hidden */
  33408. _forcedViewPosition: Nullable<Vector3>;
  33409. /** @hidden */
  33410. readonly _isAlternateRenderingEnabled: boolean;
  33411. private _frustumPlanes;
  33412. /**
  33413. * Gets the list of frustum planes (built from the active camera)
  33414. */
  33415. readonly frustumPlanes: Plane[];
  33416. /**
  33417. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33418. * This is useful if there are more lights that the maximum simulteanous authorized
  33419. */
  33420. requireLightSorting: boolean;
  33421. /** @hidden */
  33422. readonly useMaterialMeshMap: boolean;
  33423. /** @hidden */
  33424. readonly useClonedMeshhMap: boolean;
  33425. private _pointerOverMesh;
  33426. private _pickedDownMesh;
  33427. private _pickedUpMesh;
  33428. private _externalData;
  33429. private _uid;
  33430. /**
  33431. * @hidden
  33432. * Backing store of defined scene components.
  33433. */
  33434. _components: ISceneComponent[];
  33435. /**
  33436. * @hidden
  33437. * Backing store of defined scene components.
  33438. */
  33439. _serializableComponents: ISceneSerializableComponent[];
  33440. /**
  33441. * List of components to register on the next registration step.
  33442. */
  33443. private _transientComponents;
  33444. /**
  33445. * Registers the transient components if needed.
  33446. */
  33447. private _registerTransientComponents;
  33448. /**
  33449. * @hidden
  33450. * Add a component to the scene.
  33451. * Note that the ccomponent could be registered on th next frame if this is called after
  33452. * the register component stage.
  33453. * @param component Defines the component to add to the scene
  33454. */
  33455. _addComponent(component: ISceneComponent): void;
  33456. /**
  33457. * @hidden
  33458. * Gets a component from the scene.
  33459. * @param name defines the name of the component to retrieve
  33460. * @returns the component or null if not present
  33461. */
  33462. _getComponent(name: string): Nullable<ISceneComponent>;
  33463. /**
  33464. * @hidden
  33465. * Defines the actions happening before camera updates.
  33466. */
  33467. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33468. /**
  33469. * @hidden
  33470. * Defines the actions happening before clear the canvas.
  33471. */
  33472. _beforeClearStage: Stage<SimpleStageAction>;
  33473. /**
  33474. * @hidden
  33475. * Defines the actions when collecting render targets for the frame.
  33476. */
  33477. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33478. /**
  33479. * @hidden
  33480. * Defines the actions happening for one camera in the frame.
  33481. */
  33482. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33483. /**
  33484. * @hidden
  33485. * Defines the actions happening during the per mesh ready checks.
  33486. */
  33487. _isReadyForMeshStage: Stage<MeshStageAction>;
  33488. /**
  33489. * @hidden
  33490. * Defines the actions happening before evaluate active mesh checks.
  33491. */
  33492. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33493. /**
  33494. * @hidden
  33495. * Defines the actions happening during the evaluate sub mesh checks.
  33496. */
  33497. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33498. /**
  33499. * @hidden
  33500. * Defines the actions happening during the active mesh stage.
  33501. */
  33502. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33503. /**
  33504. * @hidden
  33505. * Defines the actions happening during the per camera render target step.
  33506. */
  33507. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33508. /**
  33509. * @hidden
  33510. * Defines the actions happening just before the active camera is drawing.
  33511. */
  33512. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33513. /**
  33514. * @hidden
  33515. * Defines the actions happening just before a render target is drawing.
  33516. */
  33517. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33518. /**
  33519. * @hidden
  33520. * Defines the actions happening just before a rendering group is drawing.
  33521. */
  33522. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening just before a mesh is drawing.
  33526. */
  33527. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening just after a mesh has been drawn.
  33531. */
  33532. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions happening just after a rendering group has been drawn.
  33536. */
  33537. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening just after the active camera has been drawn.
  33541. */
  33542. _afterCameraDrawStage: Stage<CameraStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening just after a render target has been drawn.
  33546. */
  33547. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening just after rendering all cameras and computing intersections.
  33551. */
  33552. _afterRenderStage: Stage<SimpleStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening when a pointer move event happens.
  33556. */
  33557. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions happening when a pointer down event happens.
  33561. */
  33562. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33563. /**
  33564. * @hidden
  33565. * Defines the actions happening when a pointer up event happens.
  33566. */
  33567. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33568. /**
  33569. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33570. */
  33571. private geometriesByUniqueId;
  33572. /**
  33573. * Creates a new Scene
  33574. * @param engine defines the engine to use to render this scene
  33575. */
  33576. constructor(engine: Engine, options?: SceneOptions);
  33577. private _defaultMeshCandidates;
  33578. /**
  33579. * @hidden
  33580. */
  33581. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33582. private _defaultSubMeshCandidates;
  33583. /**
  33584. * @hidden
  33585. */
  33586. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33587. /**
  33588. * Sets the default candidate providers for the scene.
  33589. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33590. * and getCollidingSubMeshCandidates to their default function
  33591. */
  33592. setDefaultCandidateProviders(): void;
  33593. /**
  33594. * Gets a boolean indicating if collisions are processed on a web worker
  33595. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  33596. */
  33597. workerCollisions: boolean;
  33598. /**
  33599. * Gets the mesh that is currently under the pointer
  33600. */
  33601. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33602. /**
  33603. * Gets or sets the current on-screen X position of the pointer
  33604. */
  33605. pointerX: number;
  33606. /**
  33607. * Gets or sets the current on-screen Y position of the pointer
  33608. */
  33609. pointerY: number;
  33610. /**
  33611. * Gets the cached material (ie. the latest rendered one)
  33612. * @returns the cached material
  33613. */
  33614. getCachedMaterial(): Nullable<Material>;
  33615. /**
  33616. * Gets the cached effect (ie. the latest rendered one)
  33617. * @returns the cached effect
  33618. */
  33619. getCachedEffect(): Nullable<Effect>;
  33620. /**
  33621. * Gets the cached visibility state (ie. the latest rendered one)
  33622. * @returns the cached visibility state
  33623. */
  33624. getCachedVisibility(): Nullable<number>;
  33625. /**
  33626. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33627. * @param material defines the current material
  33628. * @param effect defines the current effect
  33629. * @param visibility defines the current visibility state
  33630. * @returns true if one parameter is not cached
  33631. */
  33632. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33633. /**
  33634. * Gets the engine associated with the scene
  33635. * @returns an Engine
  33636. */
  33637. getEngine(): Engine;
  33638. /**
  33639. * Gets the total number of vertices rendered per frame
  33640. * @returns the total number of vertices rendered per frame
  33641. */
  33642. getTotalVertices(): number;
  33643. /**
  33644. * Gets the performance counter for total vertices
  33645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33646. */
  33647. readonly totalVerticesPerfCounter: PerfCounter;
  33648. /**
  33649. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33650. * @returns the total number of active indices rendered per frame
  33651. */
  33652. getActiveIndices(): number;
  33653. /**
  33654. * Gets the performance counter for active indices
  33655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33656. */
  33657. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33658. /**
  33659. * Gets the total number of active particles rendered per frame
  33660. * @returns the total number of active particles rendered per frame
  33661. */
  33662. getActiveParticles(): number;
  33663. /**
  33664. * Gets the performance counter for active particles
  33665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33666. */
  33667. readonly activeParticlesPerfCounter: PerfCounter;
  33668. /**
  33669. * Gets the total number of active bones rendered per frame
  33670. * @returns the total number of active bones rendered per frame
  33671. */
  33672. getActiveBones(): number;
  33673. /**
  33674. * Gets the performance counter for active bones
  33675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33676. */
  33677. readonly activeBonesPerfCounter: PerfCounter;
  33678. /**
  33679. * Gets the array of active meshes
  33680. * @returns an array of AbstractMesh
  33681. */
  33682. getActiveMeshes(): SmartArray<AbstractMesh>;
  33683. /**
  33684. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33685. * @returns a number
  33686. */
  33687. getAnimationRatio(): number;
  33688. /**
  33689. * Gets an unique Id for the current render phase
  33690. * @returns a number
  33691. */
  33692. getRenderId(): number;
  33693. /**
  33694. * Gets an unique Id for the current frame
  33695. * @returns a number
  33696. */
  33697. getFrameId(): number;
  33698. /** Call this function if you want to manually increment the render Id*/
  33699. incrementRenderId(): void;
  33700. private _updatePointerPosition;
  33701. private _createUbo;
  33702. private _createAlternateUbo;
  33703. private _setRayOnPointerInfo;
  33704. /**
  33705. * Use this method to simulate a pointer move on a mesh
  33706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33709. * @returns the current scene
  33710. */
  33711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33712. private _processPointerMove;
  33713. private _checkPrePointerObservable;
  33714. /**
  33715. * Use this method to simulate a pointer down on a mesh
  33716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33719. * @returns the current scene
  33720. */
  33721. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33722. private _processPointerDown;
  33723. /**
  33724. * Use this method to simulate a pointer up on a mesh
  33725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33728. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33729. * @returns the current scene
  33730. */
  33731. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33732. private _processPointerUp;
  33733. /**
  33734. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33735. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33736. * @returns true if the pointer was captured
  33737. */
  33738. isPointerCaptured(pointerId?: number): boolean;
  33739. /** @hidden */
  33740. _isPointerSwiping(): boolean;
  33741. /**
  33742. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33743. * @param attachUp defines if you want to attach events to pointerup
  33744. * @param attachDown defines if you want to attach events to pointerdown
  33745. * @param attachMove defines if you want to attach events to pointermove
  33746. */
  33747. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33748. /** Detaches all event handlers*/
  33749. detachControl(): void;
  33750. /**
  33751. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33752. * Delay loaded resources are not taking in account
  33753. * @return true if all required resources are ready
  33754. */
  33755. isReady(): boolean;
  33756. /** Resets all cached information relative to material (including effect and visibility) */
  33757. resetCachedMaterial(): void;
  33758. /**
  33759. * Registers a function to be called before every frame render
  33760. * @param func defines the function to register
  33761. */
  33762. registerBeforeRender(func: () => void): void;
  33763. /**
  33764. * Unregisters a function called before every frame render
  33765. * @param func defines the function to unregister
  33766. */
  33767. unregisterBeforeRender(func: () => void): void;
  33768. /**
  33769. * Registers a function to be called after every frame render
  33770. * @param func defines the function to register
  33771. */
  33772. registerAfterRender(func: () => void): void;
  33773. /**
  33774. * Unregisters a function called after every frame render
  33775. * @param func defines the function to unregister
  33776. */
  33777. unregisterAfterRender(func: () => void): void;
  33778. private _executeOnceBeforeRender;
  33779. /**
  33780. * The provided function will run before render once and will be disposed afterwards.
  33781. * A timeout delay can be provided so that the function will be executed in N ms.
  33782. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33783. * @param func The function to be executed.
  33784. * @param timeout optional delay in ms
  33785. */
  33786. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33787. /** @hidden */
  33788. _addPendingData(data: any): void;
  33789. /** @hidden */
  33790. _removePendingData(data: any): void;
  33791. /**
  33792. * Returns the number of items waiting to be loaded
  33793. * @returns the number of items waiting to be loaded
  33794. */
  33795. getWaitingItemsCount(): number;
  33796. /**
  33797. * Returns a boolean indicating if the scene is still loading data
  33798. */
  33799. readonly isLoading: boolean;
  33800. /**
  33801. * Registers a function to be executed when the scene is ready
  33802. * @param {Function} func - the function to be executed
  33803. */
  33804. executeWhenReady(func: () => void): void;
  33805. /**
  33806. * Returns a promise that resolves when the scene is ready
  33807. * @returns A promise that resolves when the scene is ready
  33808. */
  33809. whenReadyAsync(): Promise<void>;
  33810. /** @hidden */
  33811. _checkIsReady(): void;
  33812. /**
  33813. * Will start the animation sequence of a given target
  33814. * @param target defines the target
  33815. * @param from defines from which frame should animation start
  33816. * @param to defines until which frame should animation run.
  33817. * @param weight defines the weight to apply to the animation (1.0 by default)
  33818. * @param loop defines if the animation loops
  33819. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33820. * @param onAnimationEnd defines the function to be executed when the animation ends
  33821. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33822. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33823. * @param onAnimationLoop defines the callback to call when an animation loops
  33824. * @returns the animatable object created for this animation
  33825. */
  33826. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33827. /**
  33828. * Will start the animation sequence of a given target
  33829. * @param target defines the target
  33830. * @param from defines from which frame should animation start
  33831. * @param to defines until which frame should animation run.
  33832. * @param loop defines if the animation loops
  33833. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33834. * @param onAnimationEnd defines the function to be executed when the animation ends
  33835. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33836. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33837. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  33838. * @param onAnimationLoop defines the callback to call when an animation loops
  33839. * @returns the animatable object created for this animation
  33840. */
  33841. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33842. /**
  33843. * Will start the animation sequence of a given target and its hierarchy
  33844. * @param target defines the target
  33845. * @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.
  33846. * @param from defines from which frame should animation start
  33847. * @param to defines until which frame should animation run.
  33848. * @param loop defines if the animation loops
  33849. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33850. * @param onAnimationEnd defines the function to be executed when the animation ends
  33851. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33852. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33853. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33854. * @param onAnimationLoop defines the callback to call when an animation loops
  33855. * @returns the list of created animatables
  33856. */
  33857. 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[];
  33858. /**
  33859. * Begin a new animation on a given node
  33860. * @param target defines the target where the animation will take place
  33861. * @param animations defines the list of animations to start
  33862. * @param from defines the initial value
  33863. * @param to defines the final value
  33864. * @param loop defines if you want animation to loop (off by default)
  33865. * @param speedRatio defines the speed ratio to apply to all animations
  33866. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33867. * @param onAnimationLoop defines the callback to call when an animation loops
  33868. * @returns the list of created animatables
  33869. */
  33870. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  33871. /**
  33872. * Begin a new animation on a given node and its hierarchy
  33873. * @param target defines the root node where the animation will take place
  33874. * @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.
  33875. * @param animations defines the list of animations to start
  33876. * @param from defines the initial value
  33877. * @param to defines the final value
  33878. * @param loop defines if you want animation to loop (off by default)
  33879. * @param speedRatio defines the speed ratio to apply to all animations
  33880. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33881. * @param onAnimationLoop defines the callback to call when an animation loops
  33882. * @returns the list of animatables created for all nodes
  33883. */
  33884. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  33885. /**
  33886. * Gets the animatable associated with a specific target
  33887. * @param target defines the target of the animatable
  33888. * @returns the required animatable if found
  33889. */
  33890. getAnimatableByTarget(target: any): Nullable<Animatable>;
  33891. /**
  33892. * Gets all animatables associated with a given target
  33893. * @param target defines the target to look animatables for
  33894. * @returns an array of Animatables
  33895. */
  33896. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  33897. /**
  33898. * Gets all animatable attached to the scene
  33899. */
  33900. readonly animatables: Animatable[];
  33901. /**
  33902. * Will stop the animation of the given target
  33903. * @param target - the target
  33904. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33905. * @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)
  33906. */
  33907. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33908. /**
  33909. * Stops and removes all animations that have been applied to the scene
  33910. */
  33911. stopAllAnimations(): void;
  33912. /**
  33913. * Resets the last animation time frame.
  33914. * Useful to override when animations start running when loading a scene for the first time.
  33915. */
  33916. resetLastAnimationTimeFrame(): void;
  33917. private _animate;
  33918. /** @hidden */
  33919. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  33920. private _processLateAnimationBindingsForMatrices;
  33921. private _processLateAnimationBindingsForQuaternions;
  33922. private _processLateAnimationBindings;
  33923. /** @hidden */
  33924. _switchToAlternateCameraConfiguration(active: boolean): void;
  33925. /**
  33926. * Gets the current view matrix
  33927. * @returns a Matrix
  33928. */
  33929. getViewMatrix(): Matrix;
  33930. /**
  33931. * Gets the current projection matrix
  33932. * @returns a Matrix
  33933. */
  33934. getProjectionMatrix(): Matrix;
  33935. /**
  33936. * Gets the current transform matrix
  33937. * @returns a Matrix made of View * Projection
  33938. */
  33939. getTransformMatrix(): Matrix;
  33940. /**
  33941. * Sets the current transform matrix
  33942. * @param view defines the View matrix to use
  33943. * @param projection defines the Projection matrix to use
  33944. */
  33945. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33946. /** @hidden */
  33947. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33948. /**
  33949. * Gets the uniform buffer used to store scene data
  33950. * @returns a UniformBuffer
  33951. */
  33952. getSceneUniformBuffer(): UniformBuffer;
  33953. /**
  33954. * Gets an unique (relatively to the current scene) Id
  33955. * @returns an unique number for the scene
  33956. */
  33957. getUniqueId(): number;
  33958. /**
  33959. * Add a mesh to the list of scene's meshes
  33960. * @param newMesh defines the mesh to add
  33961. * @param recursive if all child meshes should also be added to the scene
  33962. */
  33963. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33964. /**
  33965. * Remove a mesh for the list of scene's meshes
  33966. * @param toRemove defines the mesh to remove
  33967. * @param recursive if all child meshes should also be removed from the scene
  33968. * @returns the index where the mesh was in the mesh list
  33969. */
  33970. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33971. /**
  33972. * Add a transform node to the list of scene's transform nodes
  33973. * @param newTransformNode defines the transform node to add
  33974. */
  33975. addTransformNode(newTransformNode: TransformNode): void;
  33976. /**
  33977. * Remove a transform node for the list of scene's transform nodes
  33978. * @param toRemove defines the transform node to remove
  33979. * @returns the index where the transform node was in the transform node list
  33980. */
  33981. removeTransformNode(toRemove: TransformNode): number;
  33982. /**
  33983. * Remove a skeleton for the list of scene's skeletons
  33984. * @param toRemove defines the skeleton to remove
  33985. * @returns the index where the skeleton was in the skeleton list
  33986. */
  33987. removeSkeleton(toRemove: Skeleton): number;
  33988. /**
  33989. * Remove a morph target for the list of scene's morph targets
  33990. * @param toRemove defines the morph target to remove
  33991. * @returns the index where the morph target was in the morph target list
  33992. */
  33993. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33994. /**
  33995. * Remove a light for the list of scene's lights
  33996. * @param toRemove defines the light to remove
  33997. * @returns the index where the light was in the light list
  33998. */
  33999. removeLight(toRemove: Light): number;
  34000. /**
  34001. * Remove a camera for the list of scene's cameras
  34002. * @param toRemove defines the camera to remove
  34003. * @returns the index where the camera was in the camera list
  34004. */
  34005. removeCamera(toRemove: Camera): number;
  34006. /**
  34007. * Remove a particle system for the list of scene's particle systems
  34008. * @param toRemove defines the particle system to remove
  34009. * @returns the index where the particle system was in the particle system list
  34010. */
  34011. removeParticleSystem(toRemove: IParticleSystem): number;
  34012. /**
  34013. * Remove a animation for the list of scene's animations
  34014. * @param toRemove defines the animation to remove
  34015. * @returns the index where the animation was in the animation list
  34016. */
  34017. removeAnimation(toRemove: Animation): number;
  34018. /**
  34019. * Removes the given animation group from this scene.
  34020. * @param toRemove The animation group to remove
  34021. * @returns The index of the removed animation group
  34022. */
  34023. removeAnimationGroup(toRemove: AnimationGroup): number;
  34024. /**
  34025. * Removes the given multi-material from this scene.
  34026. * @param toRemove The multi-material to remove
  34027. * @returns The index of the removed multi-material
  34028. */
  34029. removeMultiMaterial(toRemove: MultiMaterial): number;
  34030. /**
  34031. * Removes the given material from this scene.
  34032. * @param toRemove The material to remove
  34033. * @returns The index of the removed material
  34034. */
  34035. removeMaterial(toRemove: Material): number;
  34036. /**
  34037. * Removes the given action manager from this scene.
  34038. * @param toRemove The action manager to remove
  34039. * @returns The index of the removed action manager
  34040. */
  34041. removeActionManager(toRemove: ActionManager): number;
  34042. /**
  34043. * Removes the given texture from this scene.
  34044. * @param toRemove The texture to remove
  34045. * @returns The index of the removed texture
  34046. */
  34047. removeTexture(toRemove: BaseTexture): number;
  34048. /**
  34049. * Adds the given light to this scene
  34050. * @param newLight The light to add
  34051. */
  34052. addLight(newLight: Light): void;
  34053. /**
  34054. * Sorts the list list based on light priorities
  34055. */
  34056. sortLightsByPriority(): void;
  34057. /**
  34058. * Adds the given camera to this scene
  34059. * @param newCamera The camera to add
  34060. */
  34061. addCamera(newCamera: Camera): void;
  34062. /**
  34063. * Adds the given skeleton to this scene
  34064. * @param newSkeleton The skeleton to add
  34065. */
  34066. addSkeleton(newSkeleton: Skeleton): void;
  34067. /**
  34068. * Adds the given particle system to this scene
  34069. * @param newParticleSystem The particle system to add
  34070. */
  34071. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34072. /**
  34073. * Adds the given animation to this scene
  34074. * @param newAnimation The animation to add
  34075. */
  34076. addAnimation(newAnimation: Animation): void;
  34077. /**
  34078. * Adds the given animation group to this scene.
  34079. * @param newAnimationGroup The animation group to add
  34080. */
  34081. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34082. /**
  34083. * Adds the given multi-material to this scene
  34084. * @param newMultiMaterial The multi-material to add
  34085. */
  34086. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34087. /**
  34088. * Adds the given material to this scene
  34089. * @param newMaterial The material to add
  34090. */
  34091. addMaterial(newMaterial: Material): void;
  34092. /**
  34093. * Adds the given morph target to this scene
  34094. * @param newMorphTargetManager The morph target to add
  34095. */
  34096. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34097. /**
  34098. * Adds the given geometry to this scene
  34099. * @param newGeometry The geometry to add
  34100. */
  34101. addGeometry(newGeometry: Geometry): void;
  34102. /**
  34103. * Adds the given action manager to this scene
  34104. * @param newActionManager The action manager to add
  34105. */
  34106. addActionManager(newActionManager: ActionManager): void;
  34107. /**
  34108. * Adds the given texture to this scene.
  34109. * @param newTexture The texture to add
  34110. */
  34111. addTexture(newTexture: BaseTexture): void;
  34112. /**
  34113. * Switch active camera
  34114. * @param newCamera defines the new active camera
  34115. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34116. */
  34117. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34118. /**
  34119. * sets the active camera of the scene using its ID
  34120. * @param id defines the camera's ID
  34121. * @return the new active camera or null if none found.
  34122. */
  34123. setActiveCameraByID(id: string): Nullable<Camera>;
  34124. /**
  34125. * sets the active camera of the scene using its name
  34126. * @param name defines the camera's name
  34127. * @returns the new active camera or null if none found.
  34128. */
  34129. setActiveCameraByName(name: string): Nullable<Camera>;
  34130. /**
  34131. * get an animation group using its name
  34132. * @param name defines the material's name
  34133. * @return the animation group or null if none found.
  34134. */
  34135. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34136. /**
  34137. * get a material using its id
  34138. * @param id defines the material's ID
  34139. * @return the material or null if none found.
  34140. */
  34141. getMaterialByID(id: string): Nullable<Material>;
  34142. /**
  34143. * Gets a material using its name
  34144. * @param name defines the material's name
  34145. * @return the material or null if none found.
  34146. */
  34147. getMaterialByName(name: string): Nullable<Material>;
  34148. /**
  34149. * Gets a camera using its id
  34150. * @param id defines the id to look for
  34151. * @returns the camera or null if not found
  34152. */
  34153. getCameraByID(id: string): Nullable<Camera>;
  34154. /**
  34155. * Gets a camera using its unique id
  34156. * @param uniqueId defines the unique id to look for
  34157. * @returns the camera or null if not found
  34158. */
  34159. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34160. /**
  34161. * Gets a camera using its name
  34162. * @param name defines the camera's name
  34163. * @return the camera or null if none found.
  34164. */
  34165. getCameraByName(name: string): Nullable<Camera>;
  34166. /**
  34167. * Gets a bone using its id
  34168. * @param id defines the bone's id
  34169. * @return the bone or null if not found
  34170. */
  34171. getBoneByID(id: string): Nullable<Bone>;
  34172. /**
  34173. * Gets a bone using its id
  34174. * @param name defines the bone's name
  34175. * @return the bone or null if not found
  34176. */
  34177. getBoneByName(name: string): Nullable<Bone>;
  34178. /**
  34179. * Gets a light node using its name
  34180. * @param name defines the the light's name
  34181. * @return the light or null if none found.
  34182. */
  34183. getLightByName(name: string): Nullable<Light>;
  34184. /**
  34185. * Gets a light node using its id
  34186. * @param id defines the light's id
  34187. * @return the light or null if none found.
  34188. */
  34189. getLightByID(id: string): Nullable<Light>;
  34190. /**
  34191. * Gets a light node using its scene-generated unique ID
  34192. * @param uniqueId defines the light's unique id
  34193. * @return the light or null if none found.
  34194. */
  34195. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34196. /**
  34197. * Gets a particle system by id
  34198. * @param id defines the particle system id
  34199. * @return the corresponding system or null if none found
  34200. */
  34201. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34202. /**
  34203. * Gets a geometry using its ID
  34204. * @param id defines the geometry's id
  34205. * @return the geometry or null if none found.
  34206. */
  34207. getGeometryByID(id: string): Nullable<Geometry>;
  34208. private _getGeometryByUniqueID;
  34209. /**
  34210. * Add a new geometry to this scene
  34211. * @param geometry defines the geometry to be added to the scene.
  34212. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34213. * @return a boolean defining if the geometry was added or not
  34214. */
  34215. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34216. /**
  34217. * Removes an existing geometry
  34218. * @param geometry defines the geometry to be removed from the scene
  34219. * @return a boolean defining if the geometry was removed or not
  34220. */
  34221. removeGeometry(geometry: Geometry): boolean;
  34222. /**
  34223. * Gets the list of geometries attached to the scene
  34224. * @returns an array of Geometry
  34225. */
  34226. getGeometries(): Geometry[];
  34227. /**
  34228. * Gets the first added mesh found of a given ID
  34229. * @param id defines the id to search for
  34230. * @return the mesh found or null if not found at all
  34231. */
  34232. getMeshByID(id: string): Nullable<AbstractMesh>;
  34233. /**
  34234. * Gets a list of meshes using their id
  34235. * @param id defines the id to search for
  34236. * @returns a list of meshes
  34237. */
  34238. getMeshesByID(id: string): Array<AbstractMesh>;
  34239. /**
  34240. * Gets the first added transform node found of a given ID
  34241. * @param id defines the id to search for
  34242. * @return the found transform node or null if not found at all.
  34243. */
  34244. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34245. /**
  34246. * Gets a list of transform nodes using their id
  34247. * @param id defines the id to search for
  34248. * @returns a list of transform nodes
  34249. */
  34250. getTransformNodesByID(id: string): Array<TransformNode>;
  34251. /**
  34252. * Gets a mesh with its auto-generated unique id
  34253. * @param uniqueId defines the unique id to search for
  34254. * @return the found mesh or null if not found at all.
  34255. */
  34256. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34257. /**
  34258. * Gets a the last added mesh using a given id
  34259. * @param id defines the id to search for
  34260. * @return the found mesh or null if not found at all.
  34261. */
  34262. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34263. /**
  34264. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34265. * @param id defines the id to search for
  34266. * @return the found node or null if not found at all
  34267. */
  34268. getLastEntryByID(id: string): Nullable<Node>;
  34269. /**
  34270. * Gets a node (Mesh, Camera, Light) using a given id
  34271. * @param id defines the id to search for
  34272. * @return the found node or null if not found at all
  34273. */
  34274. getNodeByID(id: string): Nullable<Node>;
  34275. /**
  34276. * Gets a node (Mesh, Camera, Light) using a given name
  34277. * @param name defines the name to search for
  34278. * @return the found node or null if not found at all.
  34279. */
  34280. getNodeByName(name: string): Nullable<Node>;
  34281. /**
  34282. * Gets a mesh using a given name
  34283. * @param name defines the name to search for
  34284. * @return the found mesh or null if not found at all.
  34285. */
  34286. getMeshByName(name: string): Nullable<AbstractMesh>;
  34287. /**
  34288. * Gets a transform node using a given name
  34289. * @param name defines the name to search for
  34290. * @return the found transform node or null if not found at all.
  34291. */
  34292. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34293. /**
  34294. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34295. * @param id defines the id to search for
  34296. * @return the found skeleton or null if not found at all.
  34297. */
  34298. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34299. /**
  34300. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34301. * @param id defines the id to search for
  34302. * @return the found skeleton or null if not found at all.
  34303. */
  34304. getSkeletonById(id: string): Nullable<Skeleton>;
  34305. /**
  34306. * Gets a skeleton using a given name
  34307. * @param name defines the name to search for
  34308. * @return the found skeleton or null if not found at all.
  34309. */
  34310. getSkeletonByName(name: string): Nullable<Skeleton>;
  34311. /**
  34312. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34313. * @param id defines the id to search for
  34314. * @return the found morph target manager or null if not found at all.
  34315. */
  34316. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34317. /**
  34318. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34319. * @param id defines the id to search for
  34320. * @return the found morph target or null if not found at all.
  34321. */
  34322. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34323. /**
  34324. * Gets a boolean indicating if the given mesh is active
  34325. * @param mesh defines the mesh to look for
  34326. * @returns true if the mesh is in the active list
  34327. */
  34328. isActiveMesh(mesh: AbstractMesh): boolean;
  34329. /**
  34330. * Return a unique id as a string which can serve as an identifier for the scene
  34331. */
  34332. readonly uid: string;
  34333. /**
  34334. * Add an externaly attached data from its key.
  34335. * This method call will fail and return false, if such key already exists.
  34336. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34337. * @param key the unique key that identifies the data
  34338. * @param data the data object to associate to the key for this Engine instance
  34339. * @return true if no such key were already present and the data was added successfully, false otherwise
  34340. */
  34341. addExternalData<T>(key: string, data: T): boolean;
  34342. /**
  34343. * Get an externaly attached data from its key
  34344. * @param key the unique key that identifies the data
  34345. * @return the associated data, if present (can be null), or undefined if not present
  34346. */
  34347. getExternalData<T>(key: string): Nullable<T>;
  34348. /**
  34349. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34350. * @param key the unique key that identifies the data
  34351. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34352. * @return the associated data, can be null if the factory returned null.
  34353. */
  34354. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34355. /**
  34356. * Remove an externaly attached data from the Engine instance
  34357. * @param key the unique key that identifies the data
  34358. * @return true if the data was successfully removed, false if it doesn't exist
  34359. */
  34360. removeExternalData(key: string): boolean;
  34361. private _evaluateSubMesh;
  34362. /**
  34363. * Clear the processed materials smart array preventing retention point in material dispose.
  34364. */
  34365. freeProcessedMaterials(): void;
  34366. private _preventFreeActiveMeshesAndRenderingGroups;
  34367. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34368. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34369. * when disposing several meshes in a row or a hierarchy of meshes.
  34370. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34371. */
  34372. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34373. /**
  34374. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34375. */
  34376. freeActiveMeshes(): void;
  34377. /**
  34378. * Clear the info related to rendering groups preventing retention points during dispose.
  34379. */
  34380. freeRenderingGroups(): void;
  34381. /** @hidden */
  34382. _isInIntermediateRendering(): boolean;
  34383. /**
  34384. * Lambda returning the list of potentially active meshes.
  34385. */
  34386. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34387. /**
  34388. * Lambda returning the list of potentially active sub meshes.
  34389. */
  34390. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34391. /**
  34392. * Lambda returning the list of potentially intersecting sub meshes.
  34393. */
  34394. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34395. /**
  34396. * Lambda returning the list of potentially colliding sub meshes.
  34397. */
  34398. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34399. private _activeMeshesFrozen;
  34400. /**
  34401. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34402. * @returns the current scene
  34403. */
  34404. freezeActiveMeshes(): Scene;
  34405. /**
  34406. * Use this function to restart evaluating active meshes on every frame
  34407. * @returns the current scene
  34408. */
  34409. unfreezeActiveMeshes(): Scene;
  34410. private _evaluateActiveMeshes;
  34411. private _activeMesh;
  34412. /**
  34413. * Update the transform matrix to update from the current active camera
  34414. * @param force defines a boolean used to force the update even if cache is up to date
  34415. */
  34416. updateTransformMatrix(force?: boolean): void;
  34417. /**
  34418. * 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)
  34419. * @param alternateCamera defines the camera to use
  34420. */
  34421. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  34422. /** @hidden */
  34423. _allowPostProcessClearColor: boolean;
  34424. private _renderForCamera;
  34425. private _processSubCameras;
  34426. private _checkIntersections;
  34427. /** @hidden */
  34428. _advancePhysicsEngineStep(step: number): void;
  34429. /**
  34430. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34431. */
  34432. getDeterministicFrameTime: () => number;
  34433. /**
  34434. * Render the scene
  34435. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34436. */
  34437. render(updateCameras?: boolean): void;
  34438. /**
  34439. * Freeze all materials
  34440. * A frozen material will not be updatable but should be faster to render
  34441. */
  34442. freezeMaterials(): void;
  34443. /**
  34444. * Unfreeze all materials
  34445. * A frozen material will not be updatable but should be faster to render
  34446. */
  34447. unfreezeMaterials(): void;
  34448. /**
  34449. * Releases all held ressources
  34450. */
  34451. dispose(): void;
  34452. /**
  34453. * Gets if the scene is already disposed
  34454. */
  34455. readonly isDisposed: boolean;
  34456. /**
  34457. * Call this function to reduce memory footprint of the scene.
  34458. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34459. */
  34460. clearCachedVertexData(): void;
  34461. /**
  34462. * This function will remove the local cached buffer data from texture.
  34463. * It will save memory but will prevent the texture from being rebuilt
  34464. */
  34465. cleanCachedTextureBuffer(): void;
  34466. /**
  34467. * Get the world extend vectors with an optional filter
  34468. *
  34469. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34470. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34471. */
  34472. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34473. min: Vector3;
  34474. max: Vector3;
  34475. };
  34476. /**
  34477. * Creates a ray that can be used to pick in the scene
  34478. * @param x defines the x coordinate of the origin (on-screen)
  34479. * @param y defines the y coordinate of the origin (on-screen)
  34480. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34481. * @param camera defines the camera to use for the picking
  34482. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34483. * @returns a Ray
  34484. */
  34485. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34486. /**
  34487. * Creates a ray that can be used to pick in the scene
  34488. * @param x defines the x coordinate of the origin (on-screen)
  34489. * @param y defines the y coordinate of the origin (on-screen)
  34490. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34491. * @param result defines the ray where to store the picking ray
  34492. * @param camera defines the camera to use for the picking
  34493. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34494. * @returns the current scene
  34495. */
  34496. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34497. /**
  34498. * Creates a ray that can be used to pick in the scene
  34499. * @param x defines the x coordinate of the origin (on-screen)
  34500. * @param y defines the y coordinate of the origin (on-screen)
  34501. * @param camera defines the camera to use for the picking
  34502. * @returns a Ray
  34503. */
  34504. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34505. /**
  34506. * Creates a ray that can be used to pick in the scene
  34507. * @param x defines the x coordinate of the origin (on-screen)
  34508. * @param y defines the y coordinate of the origin (on-screen)
  34509. * @param result defines the ray where to store the picking ray
  34510. * @param camera defines the camera to use for the picking
  34511. * @returns the current scene
  34512. */
  34513. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34514. private _internalPick;
  34515. private _internalMultiPick;
  34516. private _tempPickingRay;
  34517. /** Launch a ray to try to pick a mesh in the scene
  34518. * @param x position on screen
  34519. * @param y position on screen
  34520. * @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
  34521. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34522. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34523. * @returns a PickingInfo
  34524. */
  34525. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  34526. private _cachedRayForTransform;
  34527. /** Use the given ray to pick a mesh in the scene
  34528. * @param ray The ray to use to pick meshes
  34529. * @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
  34530. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34531. * @returns a PickingInfo
  34532. */
  34533. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34534. /**
  34535. * Launch a ray to try to pick a mesh in the scene
  34536. * @param x X position on screen
  34537. * @param y Y position on screen
  34538. * @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
  34539. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34540. * @returns an array of PickingInfo
  34541. */
  34542. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  34543. /**
  34544. * Launch a ray to try to pick a mesh in the scene
  34545. * @param ray Ray to use
  34546. * @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
  34547. * @returns an array of PickingInfo
  34548. */
  34549. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  34550. /**
  34551. * Force the value of meshUnderPointer
  34552. * @param mesh defines the mesh to use
  34553. */
  34554. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34555. /**
  34556. * Gets the mesh under the pointer
  34557. * @returns a Mesh or null if no mesh is under the pointer
  34558. */
  34559. getPointerOverMesh(): Nullable<AbstractMesh>;
  34560. /** @hidden */
  34561. _rebuildGeometries(): void;
  34562. /** @hidden */
  34563. _rebuildTextures(): void;
  34564. private _getByTags;
  34565. /**
  34566. * Get a list of meshes by tags
  34567. * @param tagsQuery defines the tags query to use
  34568. * @param forEach defines a predicate used to filter results
  34569. * @returns an array of Mesh
  34570. */
  34571. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34572. /**
  34573. * Get a list of cameras by tags
  34574. * @param tagsQuery defines the tags query to use
  34575. * @param forEach defines a predicate used to filter results
  34576. * @returns an array of Camera
  34577. */
  34578. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34579. /**
  34580. * Get a list of lights by tags
  34581. * @param tagsQuery defines the tags query to use
  34582. * @param forEach defines a predicate used to filter results
  34583. * @returns an array of Light
  34584. */
  34585. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34586. /**
  34587. * Get a list of materials by tags
  34588. * @param tagsQuery defines the tags query to use
  34589. * @param forEach defines a predicate used to filter results
  34590. * @returns an array of Material
  34591. */
  34592. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34593. /**
  34594. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34595. * This allowed control for front to back rendering or reversly depending of the special needs.
  34596. *
  34597. * @param renderingGroupId The rendering group id corresponding to its index
  34598. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34599. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34600. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34601. */
  34602. 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;
  34603. /**
  34604. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34605. *
  34606. * @param renderingGroupId The rendering group id corresponding to its index
  34607. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34608. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34609. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34610. */
  34611. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34612. /**
  34613. * Gets the current auto clear configuration for one rendering group of the rendering
  34614. * manager.
  34615. * @param index the rendering group index to get the information for
  34616. * @returns The auto clear setup for the requested rendering group
  34617. */
  34618. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34619. private _blockMaterialDirtyMechanism;
  34620. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34621. blockMaterialDirtyMechanism: boolean;
  34622. /**
  34623. * Will flag all materials as dirty to trigger new shader compilation
  34624. * @param flag defines the flag used to specify which material part must be marked as dirty
  34625. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34626. */
  34627. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34628. /** @hidden */
  34629. _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;
  34630. /** @hidden */
  34631. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34632. }
  34633. }
  34634. declare module "babylonjs/assetContainer" {
  34635. import { AbstractScene } from "babylonjs/abstractScene";
  34636. import { Scene } from "babylonjs/scene";
  34637. import { Mesh } from "babylonjs/Meshes/mesh";
  34638. /**
  34639. * Set of assets to keep when moving a scene into an asset container.
  34640. */
  34641. export class KeepAssets extends AbstractScene {
  34642. }
  34643. /**
  34644. * Container with a set of assets that can be added or removed from a scene.
  34645. */
  34646. export class AssetContainer extends AbstractScene {
  34647. /**
  34648. * The scene the AssetContainer belongs to.
  34649. */
  34650. scene: Scene;
  34651. /**
  34652. * Instantiates an AssetContainer.
  34653. * @param scene The scene the AssetContainer belongs to.
  34654. */
  34655. constructor(scene: Scene);
  34656. /**
  34657. * Adds all the assets from the container to the scene.
  34658. */
  34659. addAllToScene(): void;
  34660. /**
  34661. * Removes all the assets in the container from the scene
  34662. */
  34663. removeAllFromScene(): void;
  34664. /**
  34665. * Disposes all the assets in the container
  34666. */
  34667. dispose(): void;
  34668. private _moveAssets;
  34669. /**
  34670. * Removes all the assets contained in the scene and adds them to the container.
  34671. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34672. */
  34673. moveAllFromScene(keepAssets?: KeepAssets): void;
  34674. /**
  34675. * 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.
  34676. * @returns the root mesh
  34677. */
  34678. createRootMesh(): Mesh;
  34679. }
  34680. }
  34681. declare module "babylonjs/abstractScene" {
  34682. import { Scene } from "babylonjs/scene";
  34683. import { Nullable } from "babylonjs/types";
  34684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34686. import { Geometry } from "babylonjs/Meshes/geometry";
  34687. import { Skeleton } from "babylonjs/Bones/skeleton";
  34688. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34689. import { AssetContainer } from "babylonjs/assetContainer";
  34690. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34691. import { Animation } from "babylonjs/Animations/animation";
  34692. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34693. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34694. import { Material } from "babylonjs/Materials/material";
  34695. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34696. import { ActionManager } from "babylonjs/Actions/actionManager";
  34697. import { Camera } from "babylonjs/Cameras/camera";
  34698. import { Light } from "babylonjs/Lights/light";
  34699. import { Node } from "babylonjs/node";
  34700. /**
  34701. * Defines how the parser contract is defined.
  34702. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34703. */
  34704. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34705. /**
  34706. * Defines how the individual parser contract is defined.
  34707. * These parser can parse an individual asset
  34708. */
  34709. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34710. /**
  34711. * Base class of the scene acting as a container for the different elements composing a scene.
  34712. * This class is dynamically extended by the different components of the scene increasing
  34713. * flexibility and reducing coupling
  34714. */
  34715. export abstract class AbstractScene {
  34716. /**
  34717. * Stores the list of available parsers in the application.
  34718. */
  34719. private static _BabylonFileParsers;
  34720. /**
  34721. * Stores the list of available individual parsers in the application.
  34722. */
  34723. private static _IndividualBabylonFileParsers;
  34724. /**
  34725. * Adds a parser in the list of available ones
  34726. * @param name Defines the name of the parser
  34727. * @param parser Defines the parser to add
  34728. */
  34729. static AddParser(name: string, parser: BabylonFileParser): void;
  34730. /**
  34731. * Gets a general parser from the list of avaialble ones
  34732. * @param name Defines the name of the parser
  34733. * @returns the requested parser or null
  34734. */
  34735. static GetParser(name: string): Nullable<BabylonFileParser>;
  34736. /**
  34737. * Adds n individual parser in the list of available ones
  34738. * @param name Defines the name of the parser
  34739. * @param parser Defines the parser to add
  34740. */
  34741. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34742. /**
  34743. * Gets an individual parser from the list of avaialble ones
  34744. * @param name Defines the name of the parser
  34745. * @returns the requested parser or null
  34746. */
  34747. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34748. /**
  34749. * Parser json data and populate both a scene and its associated container object
  34750. * @param jsonData Defines the data to parse
  34751. * @param scene Defines the scene to parse the data for
  34752. * @param container Defines the container attached to the parsing sequence
  34753. * @param rootUrl Defines the root url of the data
  34754. */
  34755. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34756. /**
  34757. * Gets the list of root nodes (ie. nodes with no parent)
  34758. */
  34759. rootNodes: Node[];
  34760. /** All of the cameras added to this scene
  34761. * @see http://doc.babylonjs.com/babylon101/cameras
  34762. */
  34763. cameras: Camera[];
  34764. /**
  34765. * All of the lights added to this scene
  34766. * @see http://doc.babylonjs.com/babylon101/lights
  34767. */
  34768. lights: Light[];
  34769. /**
  34770. * All of the (abstract) meshes added to this scene
  34771. */
  34772. meshes: AbstractMesh[];
  34773. /**
  34774. * The list of skeletons added to the scene
  34775. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34776. */
  34777. skeletons: Skeleton[];
  34778. /**
  34779. * All of the particle systems added to this scene
  34780. * @see http://doc.babylonjs.com/babylon101/particles
  34781. */
  34782. particleSystems: IParticleSystem[];
  34783. /**
  34784. * Gets a list of Animations associated with the scene
  34785. */
  34786. animations: Animation[];
  34787. /**
  34788. * All of the animation groups added to this scene
  34789. * @see http://doc.babylonjs.com/how_to/group
  34790. */
  34791. animationGroups: AnimationGroup[];
  34792. /**
  34793. * All of the multi-materials added to this scene
  34794. * @see http://doc.babylonjs.com/how_to/multi_materials
  34795. */
  34796. multiMaterials: MultiMaterial[];
  34797. /**
  34798. * All of the materials added to this scene
  34799. * In the context of a Scene, it is not supposed to be modified manually.
  34800. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34801. * Note also that the order of the Material wihin the array is not significant and might change.
  34802. * @see http://doc.babylonjs.com/babylon101/materials
  34803. */
  34804. materials: Material[];
  34805. /**
  34806. * The list of morph target managers added to the scene
  34807. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34808. */
  34809. morphTargetManagers: MorphTargetManager[];
  34810. /**
  34811. * The list of geometries used in the scene.
  34812. */
  34813. geometries: Geometry[];
  34814. /**
  34815. * All of the tranform nodes added to this scene
  34816. * In the context of a Scene, it is not supposed to be modified manually.
  34817. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34818. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34819. * @see http://doc.babylonjs.com/how_to/transformnode
  34820. */
  34821. transformNodes: TransformNode[];
  34822. /**
  34823. * ActionManagers available on the scene.
  34824. */
  34825. actionManagers: ActionManager[];
  34826. /**
  34827. * Textures to keep.
  34828. */
  34829. textures: BaseTexture[];
  34830. }
  34831. }
  34832. declare module "babylonjs/Audio/sound" {
  34833. import { Observable } from "babylonjs/Misc/observable";
  34834. import { Vector3 } from "babylonjs/Maths/math";
  34835. import { Nullable } from "babylonjs/types";
  34836. import { Scene } from "babylonjs/scene";
  34837. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34838. /**
  34839. * Defines a sound that can be played in the application.
  34840. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34842. */
  34843. export class Sound {
  34844. /**
  34845. * The name of the sound in the scene.
  34846. */
  34847. name: string;
  34848. /**
  34849. * Does the sound autoplay once loaded.
  34850. */
  34851. autoplay: boolean;
  34852. /**
  34853. * Does the sound loop after it finishes playing once.
  34854. */
  34855. loop: boolean;
  34856. /**
  34857. * Does the sound use a custom attenuation curve to simulate the falloff
  34858. * happening when the source gets further away from the camera.
  34859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34860. */
  34861. useCustomAttenuation: boolean;
  34862. /**
  34863. * The sound track id this sound belongs to.
  34864. */
  34865. soundTrackId: number;
  34866. /**
  34867. * Is this sound currently played.
  34868. */
  34869. isPlaying: boolean;
  34870. /**
  34871. * Is this sound currently paused.
  34872. */
  34873. isPaused: boolean;
  34874. /**
  34875. * Does this sound enables spatial sound.
  34876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34877. */
  34878. spatialSound: boolean;
  34879. /**
  34880. * Define the reference distance the sound should be heard perfectly.
  34881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34882. */
  34883. refDistance: number;
  34884. /**
  34885. * Define the roll off factor of spatial sounds.
  34886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34887. */
  34888. rolloffFactor: number;
  34889. /**
  34890. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34892. */
  34893. maxDistance: number;
  34894. /**
  34895. * Define the distance attenuation model the sound will follow.
  34896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34897. */
  34898. distanceModel: string;
  34899. /**
  34900. * @hidden
  34901. * Back Compat
  34902. **/
  34903. onended: () => any;
  34904. /**
  34905. * Observable event when the current playing sound finishes.
  34906. */
  34907. onEndedObservable: Observable<Sound>;
  34908. private _panningModel;
  34909. private _playbackRate;
  34910. private _streaming;
  34911. private _startTime;
  34912. private _startOffset;
  34913. private _position;
  34914. /** @hidden */
  34915. _positionInEmitterSpace: boolean;
  34916. private _localDirection;
  34917. private _volume;
  34918. private _isReadyToPlay;
  34919. private _isDirectional;
  34920. private _readyToPlayCallback;
  34921. private _audioBuffer;
  34922. private _soundSource;
  34923. private _streamingSource;
  34924. private _soundPanner;
  34925. private _soundGain;
  34926. private _inputAudioNode;
  34927. private _outputAudioNode;
  34928. private _coneInnerAngle;
  34929. private _coneOuterAngle;
  34930. private _coneOuterGain;
  34931. private _scene;
  34932. private _connectedTransformNode;
  34933. private _customAttenuationFunction;
  34934. private _registerFunc;
  34935. private _isOutputConnected;
  34936. private _htmlAudioElement;
  34937. private _urlType;
  34938. /** @hidden */
  34939. static _SceneComponentInitialization: (scene: Scene) => void;
  34940. /**
  34941. * Create a sound and attach it to a scene
  34942. * @param name Name of your sound
  34943. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34946. */
  34947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34948. /**
  34949. * Release the sound and its associated resources
  34950. */
  34951. dispose(): void;
  34952. /**
  34953. * Gets if the sounds is ready to be played or not.
  34954. * @returns true if ready, otherwise false
  34955. */
  34956. isReady(): boolean;
  34957. private _soundLoaded;
  34958. /**
  34959. * Sets the data of the sound from an audiobuffer
  34960. * @param audioBuffer The audioBuffer containing the data
  34961. */
  34962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34963. /**
  34964. * Updates the current sounds options such as maxdistance, loop...
  34965. * @param options A JSON object containing values named as the object properties
  34966. */
  34967. updateOptions(options: any): void;
  34968. private _createSpatialParameters;
  34969. private _updateSpatialParameters;
  34970. /**
  34971. * Switch the panning model to HRTF:
  34972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34974. */
  34975. switchPanningModelToHRTF(): void;
  34976. /**
  34977. * Switch the panning model to Equal Power:
  34978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34980. */
  34981. switchPanningModelToEqualPower(): void;
  34982. private _switchPanningModel;
  34983. /**
  34984. * Connect this sound to a sound track audio node like gain...
  34985. * @param soundTrackAudioNode the sound track audio node to connect to
  34986. */
  34987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34988. /**
  34989. * Transform this sound into a directional source
  34990. * @param coneInnerAngle Size of the inner cone in degree
  34991. * @param coneOuterAngle Size of the outer cone in degree
  34992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34993. */
  34994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34995. /**
  34996. * Gets or sets the inner angle for the directional cone.
  34997. */
  34998. /**
  34999. * Gets or sets the inner angle for the directional cone.
  35000. */
  35001. directionalConeInnerAngle: number;
  35002. /**
  35003. * Gets or sets the outer angle for the directional cone.
  35004. */
  35005. /**
  35006. * Gets or sets the outer angle for the directional cone.
  35007. */
  35008. directionalConeOuterAngle: number;
  35009. /**
  35010. * Sets the position of the emitter if spatial sound is enabled
  35011. * @param newPosition Defines the new posisiton
  35012. */
  35013. setPosition(newPosition: Vector3): void;
  35014. /**
  35015. * Sets the local direction of the emitter if spatial sound is enabled
  35016. * @param newLocalDirection Defines the new local direction
  35017. */
  35018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35019. private _updateDirection;
  35020. /** @hidden */
  35021. updateDistanceFromListener(): void;
  35022. /**
  35023. * Sets a new custom attenuation function for the sound.
  35024. * @param callback Defines the function used for the attenuation
  35025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35026. */
  35027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35028. /**
  35029. * Play the sound
  35030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35031. * @param offset (optional) Start the sound setting it at a specific time
  35032. */
  35033. play(time?: number, offset?: number): void;
  35034. private _onended;
  35035. /**
  35036. * Stop the sound
  35037. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35038. */
  35039. stop(time?: number): void;
  35040. /**
  35041. * Put the sound in pause
  35042. */
  35043. pause(): void;
  35044. /**
  35045. * Sets a dedicated volume for this sounds
  35046. * @param newVolume Define the new volume of the sound
  35047. * @param time Define in how long the sound should be at this value
  35048. */
  35049. setVolume(newVolume: number, time?: number): void;
  35050. /**
  35051. * Set the sound play back rate
  35052. * @param newPlaybackRate Define the playback rate the sound should be played at
  35053. */
  35054. setPlaybackRate(newPlaybackRate: number): void;
  35055. /**
  35056. * Gets the volume of the sound.
  35057. * @returns the volume of the sound
  35058. */
  35059. getVolume(): number;
  35060. /**
  35061. * Attach the sound to a dedicated mesh
  35062. * @param transformNode The transform node to connect the sound with
  35063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35064. */
  35065. attachToMesh(transformNode: TransformNode): void;
  35066. /**
  35067. * Detach the sound from the previously attached mesh
  35068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35069. */
  35070. detachFromMesh(): void;
  35071. private _onRegisterAfterWorldMatrixUpdate;
  35072. /**
  35073. * Clone the current sound in the scene.
  35074. * @returns the new sound clone
  35075. */
  35076. clone(): Nullable<Sound>;
  35077. /**
  35078. * Gets the current underlying audio buffer containing the data
  35079. * @returns the audio buffer
  35080. */
  35081. getAudioBuffer(): Nullable<AudioBuffer>;
  35082. /**
  35083. * Serializes the Sound in a JSON representation
  35084. * @returns the JSON representation of the sound
  35085. */
  35086. serialize(): any;
  35087. /**
  35088. * Parse a JSON representation of a sound to innstantiate in a given scene
  35089. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35090. * @param scene Define the scene the new parsed sound should be created in
  35091. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35092. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35093. * @returns the newly parsed sound
  35094. */
  35095. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35096. }
  35097. }
  35098. declare module "babylonjs/Actions/directAudioActions" {
  35099. import { Action } from "babylonjs/Actions/action";
  35100. import { Condition } from "babylonjs/Actions/condition";
  35101. import { Sound } from "babylonjs/Audio/sound";
  35102. /**
  35103. * This defines an action helpful to play a defined sound on a triggered action.
  35104. */
  35105. export class PlaySoundAction extends Action {
  35106. private _sound;
  35107. /**
  35108. * Instantiate the action
  35109. * @param triggerOptions defines the trigger options
  35110. * @param sound defines the sound to play
  35111. * @param condition defines the trigger related conditions
  35112. */
  35113. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35114. /** @hidden */
  35115. _prepare(): void;
  35116. /**
  35117. * Execute the action and play the sound.
  35118. */
  35119. execute(): void;
  35120. /**
  35121. * Serializes the actions and its related information.
  35122. * @param parent defines the object to serialize in
  35123. * @returns the serialized object
  35124. */
  35125. serialize(parent: any): any;
  35126. }
  35127. /**
  35128. * This defines an action helpful to stop a defined sound on a triggered action.
  35129. */
  35130. export class StopSoundAction extends Action {
  35131. private _sound;
  35132. /**
  35133. * Instantiate the action
  35134. * @param triggerOptions defines the trigger options
  35135. * @param sound defines the sound to stop
  35136. * @param condition defines the trigger related conditions
  35137. */
  35138. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35139. /** @hidden */
  35140. _prepare(): void;
  35141. /**
  35142. * Execute the action and stop the sound.
  35143. */
  35144. execute(): void;
  35145. /**
  35146. * Serializes the actions and its related information.
  35147. * @param parent defines the object to serialize in
  35148. * @returns the serialized object
  35149. */
  35150. serialize(parent: any): any;
  35151. }
  35152. }
  35153. declare module "babylonjs/Actions/interpolateValueAction" {
  35154. import { Action } from "babylonjs/Actions/action";
  35155. import { Condition } from "babylonjs/Actions/condition";
  35156. import { Observable } from "babylonjs/Misc/observable";
  35157. /**
  35158. * This defines an action responsible to change the value of a property
  35159. * by interpolating between its current value and the newly set one once triggered.
  35160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35161. */
  35162. export class InterpolateValueAction extends Action {
  35163. /**
  35164. * Defines the path of the property where the value should be interpolated
  35165. */
  35166. propertyPath: string;
  35167. /**
  35168. * Defines the target value at the end of the interpolation.
  35169. */
  35170. value: any;
  35171. /**
  35172. * Defines the time it will take for the property to interpolate to the value.
  35173. */
  35174. duration: number;
  35175. /**
  35176. * Defines if the other scene animations should be stopped when the action has been triggered
  35177. */
  35178. stopOtherAnimations?: boolean;
  35179. /**
  35180. * Defines a callback raised once the interpolation animation has been done.
  35181. */
  35182. onInterpolationDone?: () => void;
  35183. /**
  35184. * Observable triggered once the interpolation animation has been done.
  35185. */
  35186. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35187. private _target;
  35188. private _effectiveTarget;
  35189. private _property;
  35190. /**
  35191. * Instantiate the action
  35192. * @param triggerOptions defines the trigger options
  35193. * @param target defines the object containing the value to interpolate
  35194. * @param propertyPath defines the path to the property in the target object
  35195. * @param value defines the target value at the end of the interpolation
  35196. * @param duration deines the time it will take for the property to interpolate to the value.
  35197. * @param condition defines the trigger related conditions
  35198. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35199. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35200. */
  35201. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35202. /** @hidden */
  35203. _prepare(): void;
  35204. /**
  35205. * Execute the action starts the value interpolation.
  35206. */
  35207. execute(): void;
  35208. /**
  35209. * Serializes the actions and its related information.
  35210. * @param parent defines the object to serialize in
  35211. * @returns the serialized object
  35212. */
  35213. serialize(parent: any): any;
  35214. }
  35215. }
  35216. declare module "babylonjs/Actions/index" {
  35217. export * from "babylonjs/Actions/action";
  35218. export * from "babylonjs/Actions/actionEvent";
  35219. export * from "babylonjs/Actions/actionManager";
  35220. export * from "babylonjs/Actions/condition";
  35221. export * from "babylonjs/Actions/directActions";
  35222. export * from "babylonjs/Actions/directAudioActions";
  35223. export * from "babylonjs/Actions/interpolateValueAction";
  35224. }
  35225. declare module "babylonjs/Animations/index" {
  35226. export * from "babylonjs/Animations/animatable";
  35227. export * from "babylonjs/Animations/animation";
  35228. export * from "babylonjs/Animations/animationGroup";
  35229. export * from "babylonjs/Animations/animationPropertiesOverride";
  35230. export * from "babylonjs/Animations/easing";
  35231. export * from "babylonjs/Animations/runtimeAnimation";
  35232. }
  35233. declare module "babylonjs/Audio/soundTrack" {
  35234. import { Sound } from "babylonjs/Audio/sound";
  35235. import { Analyser } from "babylonjs/Audio/analyser";
  35236. import { Scene } from "babylonjs/scene";
  35237. /**
  35238. * Options allowed during the creation of a sound track.
  35239. */
  35240. export interface ISoundTrackOptions {
  35241. /**
  35242. * The volume the sound track should take during creation
  35243. */
  35244. volume?: number;
  35245. /**
  35246. * Define if the sound track is the main sound track of the scene
  35247. */
  35248. mainTrack?: boolean;
  35249. }
  35250. /**
  35251. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35252. * It will be also used in a future release to apply effects on a specific track.
  35253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35254. */
  35255. export class SoundTrack {
  35256. /**
  35257. * The unique identifier of the sound track in the scene.
  35258. */
  35259. id: number;
  35260. /**
  35261. * The list of sounds included in the sound track.
  35262. */
  35263. soundCollection: Array<Sound>;
  35264. private _outputAudioNode;
  35265. private _scene;
  35266. private _isMainTrack;
  35267. private _connectedAnalyser;
  35268. private _options;
  35269. private _isInitialized;
  35270. /**
  35271. * Creates a new sound track.
  35272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35273. * @param scene Define the scene the sound track belongs to
  35274. * @param options
  35275. */
  35276. constructor(scene: Scene, options?: ISoundTrackOptions);
  35277. private _initializeSoundTrackAudioGraph;
  35278. /**
  35279. * Release the sound track and its associated resources
  35280. */
  35281. dispose(): void;
  35282. /**
  35283. * Adds a sound to this sound track
  35284. * @param sound define the cound to add
  35285. * @ignoreNaming
  35286. */
  35287. AddSound(sound: Sound): void;
  35288. /**
  35289. * Removes a sound to this sound track
  35290. * @param sound define the cound to remove
  35291. * @ignoreNaming
  35292. */
  35293. RemoveSound(sound: Sound): void;
  35294. /**
  35295. * Set a global volume for the full sound track.
  35296. * @param newVolume Define the new volume of the sound track
  35297. */
  35298. setVolume(newVolume: number): void;
  35299. /**
  35300. * Switch the panning model to HRTF:
  35301. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35303. */
  35304. switchPanningModelToHRTF(): void;
  35305. /**
  35306. * Switch the panning model to Equal Power:
  35307. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35309. */
  35310. switchPanningModelToEqualPower(): void;
  35311. /**
  35312. * Connect the sound track to an audio analyser allowing some amazing
  35313. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35315. * @param analyser The analyser to connect to the engine
  35316. */
  35317. connectToAnalyser(analyser: Analyser): void;
  35318. }
  35319. }
  35320. declare module "babylonjs/Audio/audioSceneComponent" {
  35321. import { Sound } from "babylonjs/Audio/sound";
  35322. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35323. import { Nullable } from "babylonjs/types";
  35324. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35325. import { Scene } from "babylonjs/scene";
  35326. import { AbstractScene } from "babylonjs/abstractScene";
  35327. module "babylonjs/abstractScene" {
  35328. interface AbstractScene {
  35329. /**
  35330. * The list of sounds used in the scene.
  35331. */
  35332. sounds: Nullable<Array<Sound>>;
  35333. }
  35334. }
  35335. module "babylonjs/scene" {
  35336. interface Scene {
  35337. /**
  35338. * @hidden
  35339. * Backing field
  35340. */
  35341. _mainSoundTrack: SoundTrack;
  35342. /**
  35343. * The main sound track played by the scene.
  35344. * It cotains your primary collection of sounds.
  35345. */
  35346. mainSoundTrack: SoundTrack;
  35347. /**
  35348. * The list of sound tracks added to the scene
  35349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35350. */
  35351. soundTracks: Nullable<Array<SoundTrack>>;
  35352. /**
  35353. * Gets a sound using a given name
  35354. * @param name defines the name to search for
  35355. * @return the found sound or null if not found at all.
  35356. */
  35357. getSoundByName(name: string): Nullable<Sound>;
  35358. /**
  35359. * Gets or sets if audio support is enabled
  35360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35361. */
  35362. audioEnabled: boolean;
  35363. /**
  35364. * Gets or sets if audio will be output to headphones
  35365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35366. */
  35367. headphone: boolean;
  35368. }
  35369. }
  35370. /**
  35371. * Defines the sound scene component responsible to manage any sounds
  35372. * in a given scene.
  35373. */
  35374. export class AudioSceneComponent implements ISceneSerializableComponent {
  35375. /**
  35376. * The component name helpfull to identify the component in the list of scene components.
  35377. */
  35378. readonly name: string;
  35379. /**
  35380. * The scene the component belongs to.
  35381. */
  35382. scene: Scene;
  35383. private _audioEnabled;
  35384. /**
  35385. * Gets whether audio is enabled or not.
  35386. * Please use related enable/disable method to switch state.
  35387. */
  35388. readonly audioEnabled: boolean;
  35389. private _headphone;
  35390. /**
  35391. * Gets whether audio is outputing to headphone or not.
  35392. * Please use the according Switch methods to change output.
  35393. */
  35394. readonly headphone: boolean;
  35395. /**
  35396. * Creates a new instance of the component for the given scene
  35397. * @param scene Defines the scene to register the component in
  35398. */
  35399. constructor(scene: Scene);
  35400. /**
  35401. * Registers the component in a given scene
  35402. */
  35403. register(): void;
  35404. /**
  35405. * Rebuilds the elements related to this component in case of
  35406. * context lost for instance.
  35407. */
  35408. rebuild(): void;
  35409. /**
  35410. * Serializes the component data to the specified json object
  35411. * @param serializationObject The object to serialize to
  35412. */
  35413. serialize(serializationObject: any): void;
  35414. /**
  35415. * Adds all the element from the container to the scene
  35416. * @param container the container holding the elements
  35417. */
  35418. addFromContainer(container: AbstractScene): void;
  35419. /**
  35420. * Removes all the elements in the container from the scene
  35421. * @param container contains the elements to remove
  35422. */
  35423. removeFromContainer(container: AbstractScene): void;
  35424. /**
  35425. * Disposes the component and the associated ressources.
  35426. */
  35427. dispose(): void;
  35428. /**
  35429. * Disables audio in the associated scene.
  35430. */
  35431. disableAudio(): void;
  35432. /**
  35433. * Enables audio in the associated scene.
  35434. */
  35435. enableAudio(): void;
  35436. /**
  35437. * Switch audio to headphone output.
  35438. */
  35439. switchAudioModeForHeadphones(): void;
  35440. /**
  35441. * Switch audio to normal speakers.
  35442. */
  35443. switchAudioModeForNormalSpeakers(): void;
  35444. private _afterRender;
  35445. }
  35446. }
  35447. declare module "babylonjs/Audio/weightedsound" {
  35448. import { Sound } from "babylonjs/Audio/sound";
  35449. /**
  35450. * Wraps one or more Sound objects and selects one with random weight for playback.
  35451. */
  35452. export class WeightedSound {
  35453. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35454. loop: boolean;
  35455. private _coneInnerAngle;
  35456. private _coneOuterAngle;
  35457. private _volume;
  35458. /** A Sound is currently playing. */
  35459. isPlaying: boolean;
  35460. /** A Sound is currently paused. */
  35461. isPaused: boolean;
  35462. private _sounds;
  35463. private _weights;
  35464. private _currentIndex?;
  35465. /**
  35466. * Creates a new WeightedSound from the list of sounds given.
  35467. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35468. * @param sounds Array of Sounds that will be selected from.
  35469. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35470. */
  35471. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35472. /**
  35473. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35474. */
  35475. /**
  35476. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35477. */
  35478. directionalConeInnerAngle: number;
  35479. /**
  35480. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35481. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35482. */
  35483. /**
  35484. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35485. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35486. */
  35487. directionalConeOuterAngle: number;
  35488. /**
  35489. * Playback volume.
  35490. */
  35491. /**
  35492. * Playback volume.
  35493. */
  35494. volume: number;
  35495. private _onended;
  35496. /**
  35497. * Suspend playback
  35498. */
  35499. pause(): void;
  35500. /**
  35501. * Stop playback
  35502. */
  35503. stop(): void;
  35504. /**
  35505. * Start playback.
  35506. * @param startOffset Position the clip head at a specific time in seconds.
  35507. */
  35508. play(startOffset?: number): void;
  35509. }
  35510. }
  35511. declare module "babylonjs/Audio/index" {
  35512. export * from "babylonjs/Audio/analyser";
  35513. export * from "babylonjs/Audio/audioEngine";
  35514. export * from "babylonjs/Audio/audioSceneComponent";
  35515. export * from "babylonjs/Audio/sound";
  35516. export * from "babylonjs/Audio/soundTrack";
  35517. export * from "babylonjs/Audio/weightedsound";
  35518. }
  35519. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35520. import { Behavior } from "babylonjs/Behaviors/behavior";
  35521. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35522. import { BackEase } from "babylonjs/Animations/easing";
  35523. /**
  35524. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35526. */
  35527. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35528. /**
  35529. * Gets the name of the behavior.
  35530. */
  35531. readonly name: string;
  35532. /**
  35533. * The easing function used by animations
  35534. */
  35535. static EasingFunction: BackEase;
  35536. /**
  35537. * The easing mode used by animations
  35538. */
  35539. static EasingMode: number;
  35540. /**
  35541. * The duration of the animation, in milliseconds
  35542. */
  35543. transitionDuration: number;
  35544. /**
  35545. * Length of the distance animated by the transition when lower radius is reached
  35546. */
  35547. lowerRadiusTransitionRange: number;
  35548. /**
  35549. * Length of the distance animated by the transition when upper radius is reached
  35550. */
  35551. upperRadiusTransitionRange: number;
  35552. private _autoTransitionRange;
  35553. /**
  35554. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35555. */
  35556. /**
  35557. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35558. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35559. */
  35560. autoTransitionRange: boolean;
  35561. private _attachedCamera;
  35562. private _onAfterCheckInputsObserver;
  35563. private _onMeshTargetChangedObserver;
  35564. /**
  35565. * Initializes the behavior.
  35566. */
  35567. init(): void;
  35568. /**
  35569. * Attaches the behavior to its arc rotate camera.
  35570. * @param camera Defines the camera to attach the behavior to
  35571. */
  35572. attach(camera: ArcRotateCamera): void;
  35573. /**
  35574. * Detaches the behavior from its current arc rotate camera.
  35575. */
  35576. detach(): void;
  35577. private _radiusIsAnimating;
  35578. private _radiusBounceTransition;
  35579. private _animatables;
  35580. private _cachedWheelPrecision;
  35581. /**
  35582. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35583. * @param radiusLimit The limit to check against.
  35584. * @return Bool to indicate if at limit.
  35585. */
  35586. private _isRadiusAtLimit;
  35587. /**
  35588. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35589. * @param radiusDelta The delta by which to animate to. Can be negative.
  35590. */
  35591. private _applyBoundRadiusAnimation;
  35592. /**
  35593. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35594. */
  35595. protected _clearAnimationLocks(): void;
  35596. /**
  35597. * Stops and removes all animations that have been applied to the camera
  35598. */
  35599. stopAllAnimations(): void;
  35600. }
  35601. }
  35602. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35603. import { Behavior } from "babylonjs/Behaviors/behavior";
  35604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35605. import { ExponentialEase } from "babylonjs/Animations/easing";
  35606. import { Nullable } from "babylonjs/types";
  35607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35608. import { Vector3 } from "babylonjs/Maths/math";
  35609. /**
  35610. * 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.
  35611. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35612. */
  35613. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35614. /**
  35615. * Gets the name of the behavior.
  35616. */
  35617. readonly name: string;
  35618. private _mode;
  35619. private _radiusScale;
  35620. private _positionScale;
  35621. private _defaultElevation;
  35622. private _elevationReturnTime;
  35623. private _elevationReturnWaitTime;
  35624. private _zoomStopsAnimation;
  35625. private _framingTime;
  35626. /**
  35627. * The easing function used by animations
  35628. */
  35629. static EasingFunction: ExponentialEase;
  35630. /**
  35631. * The easing mode used by animations
  35632. */
  35633. static EasingMode: number;
  35634. /**
  35635. * Sets the current mode used by the behavior
  35636. */
  35637. /**
  35638. * Gets current mode used by the behavior.
  35639. */
  35640. mode: number;
  35641. /**
  35642. * Sets the scale applied to the radius (1 by default)
  35643. */
  35644. /**
  35645. * Gets the scale applied to the radius
  35646. */
  35647. radiusScale: number;
  35648. /**
  35649. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35650. */
  35651. /**
  35652. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35653. */
  35654. positionScale: number;
  35655. /**
  35656. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35657. * behaviour is triggered, in radians.
  35658. */
  35659. /**
  35660. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35661. * behaviour is triggered, in radians.
  35662. */
  35663. defaultElevation: number;
  35664. /**
  35665. * Sets the time (in milliseconds) taken to return to the default beta position.
  35666. * Negative value indicates camera should not return to default.
  35667. */
  35668. /**
  35669. * Gets the time (in milliseconds) taken to return to the default beta position.
  35670. * Negative value indicates camera should not return to default.
  35671. */
  35672. elevationReturnTime: number;
  35673. /**
  35674. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35675. */
  35676. /**
  35677. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35678. */
  35679. elevationReturnWaitTime: number;
  35680. /**
  35681. * Sets the flag that indicates if user zooming should stop animation.
  35682. */
  35683. /**
  35684. * Gets the flag that indicates if user zooming should stop animation.
  35685. */
  35686. zoomStopsAnimation: boolean;
  35687. /**
  35688. * Sets the transition time when framing the mesh, in milliseconds
  35689. */
  35690. /**
  35691. * Gets the transition time when framing the mesh, in milliseconds
  35692. */
  35693. framingTime: number;
  35694. /**
  35695. * Define if the behavior should automatically change the configured
  35696. * camera limits and sensibilities.
  35697. */
  35698. autoCorrectCameraLimitsAndSensibility: boolean;
  35699. private _onPrePointerObservableObserver;
  35700. private _onAfterCheckInputsObserver;
  35701. private _onMeshTargetChangedObserver;
  35702. private _attachedCamera;
  35703. private _isPointerDown;
  35704. private _lastInteractionTime;
  35705. /**
  35706. * Initializes the behavior.
  35707. */
  35708. init(): void;
  35709. /**
  35710. * Attaches the behavior to its arc rotate camera.
  35711. * @param camera Defines the camera to attach the behavior to
  35712. */
  35713. attach(camera: ArcRotateCamera): void;
  35714. /**
  35715. * Detaches the behavior from its current arc rotate camera.
  35716. */
  35717. detach(): void;
  35718. private _animatables;
  35719. private _betaIsAnimating;
  35720. private _betaTransition;
  35721. private _radiusTransition;
  35722. private _vectorTransition;
  35723. /**
  35724. * Targets the given mesh and updates zoom level accordingly.
  35725. * @param mesh The mesh to target.
  35726. * @param radius Optional. If a cached radius position already exists, overrides default.
  35727. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35728. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35729. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35730. */
  35731. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35732. /**
  35733. * Targets the given mesh with its children and updates zoom level accordingly.
  35734. * @param mesh The mesh to target.
  35735. * @param radius Optional. If a cached radius position already exists, overrides default.
  35736. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35737. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35738. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35739. */
  35740. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35741. /**
  35742. * Targets the given meshes with their children and updates zoom level accordingly.
  35743. * @param meshes The mesh to target.
  35744. * @param radius Optional. If a cached radius position already exists, overrides default.
  35745. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35746. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35747. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35748. */
  35749. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35750. /**
  35751. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35752. * @param minimumWorld Determines the smaller position of the bounding box extend
  35753. * @param maximumWorld Determines the bigger position of the bounding box extend
  35754. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35755. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35756. */
  35757. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35758. /**
  35759. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35760. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35761. * frustum width.
  35762. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35763. * to fully enclose the mesh in the viewing frustum.
  35764. */
  35765. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35766. /**
  35767. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35768. * is automatically returned to its default position (expected to be above ground plane).
  35769. */
  35770. private _maintainCameraAboveGround;
  35771. /**
  35772. * Returns the frustum slope based on the canvas ratio and camera FOV
  35773. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35774. */
  35775. private _getFrustumSlope;
  35776. /**
  35777. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35778. */
  35779. private _clearAnimationLocks;
  35780. /**
  35781. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35782. */
  35783. private _applyUserInteraction;
  35784. /**
  35785. * Stops and removes all animations that have been applied to the camera
  35786. */
  35787. stopAllAnimations(): void;
  35788. /**
  35789. * Gets a value indicating if the user is moving the camera
  35790. */
  35791. readonly isUserIsMoving: boolean;
  35792. /**
  35793. * The camera can move all the way towards the mesh.
  35794. */
  35795. static IgnoreBoundsSizeMode: number;
  35796. /**
  35797. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35798. */
  35799. static FitFrustumSidesMode: number;
  35800. }
  35801. }
  35802. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35803. import { Nullable } from "babylonjs/types";
  35804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35805. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35806. /**
  35807. * Manage the pointers inputs to control an arc rotate camera.
  35808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35809. */
  35810. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  35811. /**
  35812. * Defines the camera the input is attached to.
  35813. */
  35814. camera: ArcRotateCamera;
  35815. /**
  35816. * Defines the buttons associated with the input to handle camera move.
  35817. */
  35818. buttons: number[];
  35819. /**
  35820. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35821. */
  35822. angularSensibilityX: number;
  35823. /**
  35824. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35825. */
  35826. angularSensibilityY: number;
  35827. /**
  35828. * Defines the pointer pinch precision or how fast is the camera zooming.
  35829. */
  35830. pinchPrecision: number;
  35831. /**
  35832. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  35833. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35834. */
  35835. pinchDeltaPercentage: number;
  35836. /**
  35837. * Defines the pointer panning sensibility or how fast is the camera moving.
  35838. */
  35839. panningSensibility: number;
  35840. /**
  35841. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35842. */
  35843. multiTouchPanning: boolean;
  35844. /**
  35845. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  35846. */
  35847. multiTouchPanAndZoom: boolean;
  35848. /**
  35849. * Revers pinch action direction.
  35850. */
  35851. pinchInwards: boolean;
  35852. private _isPanClick;
  35853. private _pointerInput;
  35854. private _observer;
  35855. private _onMouseMove;
  35856. private _onGestureStart;
  35857. private _onGesture;
  35858. private _MSGestureHandler;
  35859. private _onLostFocus;
  35860. private _onContextMenu;
  35861. /**
  35862. * Attach the input controls to a specific dom element to get the input from.
  35863. * @param element Defines the element the controls should be listened from
  35864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35865. */
  35866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35867. /**
  35868. * Detach the current controls from the specified dom element.
  35869. * @param element Defines the element to stop listening the inputs from
  35870. */
  35871. detachControl(element: Nullable<HTMLElement>): void;
  35872. /**
  35873. * Gets the class name of the current intput.
  35874. * @returns the class name
  35875. */
  35876. getClassName(): string;
  35877. /**
  35878. * Get the friendly name associated with the input class.
  35879. * @returns the input friendly name
  35880. */
  35881. getSimpleName(): string;
  35882. }
  35883. }
  35884. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35885. import { Nullable } from "babylonjs/types";
  35886. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35887. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35888. /**
  35889. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35891. */
  35892. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35893. /**
  35894. * Defines the camera the input is attached to.
  35895. */
  35896. camera: ArcRotateCamera;
  35897. /**
  35898. * Defines the list of key codes associated with the up action (increase alpha)
  35899. */
  35900. keysUp: number[];
  35901. /**
  35902. * Defines the list of key codes associated with the down action (decrease alpha)
  35903. */
  35904. keysDown: number[];
  35905. /**
  35906. * Defines the list of key codes associated with the left action (increase beta)
  35907. */
  35908. keysLeft: number[];
  35909. /**
  35910. * Defines the list of key codes associated with the right action (decrease beta)
  35911. */
  35912. keysRight: number[];
  35913. /**
  35914. * Defines the list of key codes associated with the reset action.
  35915. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35916. */
  35917. keysReset: number[];
  35918. /**
  35919. * Defines the panning sensibility of the inputs.
  35920. * (How fast is the camera paning)
  35921. */
  35922. panningSensibility: number;
  35923. /**
  35924. * Defines the zooming sensibility of the inputs.
  35925. * (How fast is the camera zooming)
  35926. */
  35927. zoomingSensibility: number;
  35928. /**
  35929. * Defines wether maintaining the alt key down switch the movement mode from
  35930. * orientation to zoom.
  35931. */
  35932. useAltToZoom: boolean;
  35933. /**
  35934. * Rotation speed of the camera
  35935. */
  35936. angularSpeed: number;
  35937. private _keys;
  35938. private _ctrlPressed;
  35939. private _altPressed;
  35940. private _onCanvasBlurObserver;
  35941. private _onKeyboardObserver;
  35942. private _engine;
  35943. private _scene;
  35944. /**
  35945. * Attach the input controls to a specific dom element to get the input from.
  35946. * @param element Defines the element the controls should be listened from
  35947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35948. */
  35949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35950. /**
  35951. * Detach the current controls from the specified dom element.
  35952. * @param element Defines the element to stop listening the inputs from
  35953. */
  35954. detachControl(element: Nullable<HTMLElement>): void;
  35955. /**
  35956. * Update the current camera state depending on the inputs that have been used this frame.
  35957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35958. */
  35959. checkInputs(): void;
  35960. /**
  35961. * Gets the class name of the current intput.
  35962. * @returns the class name
  35963. */
  35964. getClassName(): string;
  35965. /**
  35966. * Get the friendly name associated with the input class.
  35967. * @returns the input friendly name
  35968. */
  35969. getSimpleName(): string;
  35970. }
  35971. }
  35972. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35973. import { Nullable } from "babylonjs/types";
  35974. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35975. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35976. /**
  35977. * Manage the mouse wheel inputs to control an arc rotate camera.
  35978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35979. */
  35980. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35981. /**
  35982. * Defines the camera the input is attached to.
  35983. */
  35984. camera: ArcRotateCamera;
  35985. /**
  35986. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35987. */
  35988. wheelPrecision: number;
  35989. /**
  35990. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35991. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35992. */
  35993. wheelDeltaPercentage: number;
  35994. private _wheel;
  35995. private _observer;
  35996. /**
  35997. * Attach the input controls to a specific dom element to get the input from.
  35998. * @param element Defines the element the controls should be listened from
  35999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36000. */
  36001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36002. /**
  36003. * Detach the current controls from the specified dom element.
  36004. * @param element Defines the element to stop listening the inputs from
  36005. */
  36006. detachControl(element: Nullable<HTMLElement>): void;
  36007. /**
  36008. * Gets the class name of the current intput.
  36009. * @returns the class name
  36010. */
  36011. getClassName(): string;
  36012. /**
  36013. * Get the friendly name associated with the input class.
  36014. * @returns the input friendly name
  36015. */
  36016. getSimpleName(): string;
  36017. }
  36018. }
  36019. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36020. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36021. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36022. /**
  36023. * Default Inputs manager for the ArcRotateCamera.
  36024. * It groups all the default supported inputs for ease of use.
  36025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36026. */
  36027. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36028. /**
  36029. * Instantiates a new ArcRotateCameraInputsManager.
  36030. * @param camera Defines the camera the inputs belong to
  36031. */
  36032. constructor(camera: ArcRotateCamera);
  36033. /**
  36034. * Add mouse wheel input support to the input manager.
  36035. * @returns the current input manager
  36036. */
  36037. addMouseWheel(): ArcRotateCameraInputsManager;
  36038. /**
  36039. * Add pointers input support to the input manager.
  36040. * @returns the current input manager
  36041. */
  36042. addPointers(): ArcRotateCameraInputsManager;
  36043. /**
  36044. * Add keyboard input support to the input manager.
  36045. * @returns the current input manager
  36046. */
  36047. addKeyboard(): ArcRotateCameraInputsManager;
  36048. }
  36049. }
  36050. declare module "babylonjs/Cameras/arcRotateCamera" {
  36051. import { Observable } from "babylonjs/Misc/observable";
  36052. import { Nullable } from "babylonjs/types";
  36053. import { Scene } from "babylonjs/scene";
  36054. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36056. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36057. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36058. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36059. import { Collider } from "babylonjs/Collisions/collider";
  36060. import { Camera } from "babylonjs/Cameras/camera";
  36061. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36062. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36063. /**
  36064. * This represents an orbital type of camera.
  36065. *
  36066. * 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.
  36067. * 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.
  36068. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36069. */
  36070. export class ArcRotateCamera extends TargetCamera {
  36071. /**
  36072. * Defines the rotation angle of the camera along the longitudinal axis.
  36073. */
  36074. alpha: number;
  36075. /**
  36076. * Defines the rotation angle of the camera along the latitudinal axis.
  36077. */
  36078. beta: number;
  36079. /**
  36080. * Defines the radius of the camera from it s target point.
  36081. */
  36082. radius: number;
  36083. protected _target: Vector3;
  36084. protected _targetHost: Nullable<AbstractMesh>;
  36085. /**
  36086. * Defines the target point of the camera.
  36087. * The camera looks towards it form the radius distance.
  36088. */
  36089. target: Vector3;
  36090. /**
  36091. * Current inertia value on the longitudinal axis.
  36092. * The bigger this number the longer it will take for the camera to stop.
  36093. */
  36094. inertialAlphaOffset: number;
  36095. /**
  36096. * Current inertia value on the latitudinal axis.
  36097. * The bigger this number the longer it will take for the camera to stop.
  36098. */
  36099. inertialBetaOffset: number;
  36100. /**
  36101. * Current inertia value on the radius axis.
  36102. * The bigger this number the longer it will take for the camera to stop.
  36103. */
  36104. inertialRadiusOffset: number;
  36105. /**
  36106. * Minimum allowed angle on the longitudinal axis.
  36107. * This can help limiting how the Camera is able to move in the scene.
  36108. */
  36109. lowerAlphaLimit: Nullable<number>;
  36110. /**
  36111. * Maximum allowed angle on the longitudinal axis.
  36112. * This can help limiting how the Camera is able to move in the scene.
  36113. */
  36114. upperAlphaLimit: Nullable<number>;
  36115. /**
  36116. * Minimum allowed angle on the latitudinal axis.
  36117. * This can help limiting how the Camera is able to move in the scene.
  36118. */
  36119. lowerBetaLimit: number;
  36120. /**
  36121. * Maximum allowed angle on the latitudinal axis.
  36122. * This can help limiting how the Camera is able to move in the scene.
  36123. */
  36124. upperBetaLimit: number;
  36125. /**
  36126. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36127. * This can help limiting how the Camera is able to move in the scene.
  36128. */
  36129. lowerRadiusLimit: Nullable<number>;
  36130. /**
  36131. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36132. * This can help limiting how the Camera is able to move in the scene.
  36133. */
  36134. upperRadiusLimit: Nullable<number>;
  36135. /**
  36136. * Defines the current inertia value used during panning of the camera along the X axis.
  36137. */
  36138. inertialPanningX: number;
  36139. /**
  36140. * Defines the current inertia value used during panning of the camera along the Y axis.
  36141. */
  36142. inertialPanningY: number;
  36143. /**
  36144. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36145. * Basically if your fingers moves away from more than this distance you will be considered
  36146. * in pinch mode.
  36147. */
  36148. pinchToPanMaxDistance: number;
  36149. /**
  36150. * Defines the maximum distance the camera can pan.
  36151. * This could help keeping the cammera always in your scene.
  36152. */
  36153. panningDistanceLimit: Nullable<number>;
  36154. /**
  36155. * Defines the target of the camera before paning.
  36156. */
  36157. panningOriginTarget: Vector3;
  36158. /**
  36159. * Defines the value of the inertia used during panning.
  36160. * 0 would mean stop inertia and one would mean no decelleration at all.
  36161. */
  36162. panningInertia: number;
  36163. /**
  36164. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36165. */
  36166. angularSensibilityX: number;
  36167. /**
  36168. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36169. */
  36170. angularSensibilityY: number;
  36171. /**
  36172. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36173. */
  36174. pinchPrecision: number;
  36175. /**
  36176. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36177. * It will be used instead of pinchDeltaPrecision if different from 0.
  36178. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36179. */
  36180. pinchDeltaPercentage: number;
  36181. /**
  36182. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36183. */
  36184. panningSensibility: number;
  36185. /**
  36186. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36187. */
  36188. keysUp: number[];
  36189. /**
  36190. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36191. */
  36192. keysDown: number[];
  36193. /**
  36194. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36195. */
  36196. keysLeft: number[];
  36197. /**
  36198. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36199. */
  36200. keysRight: number[];
  36201. /**
  36202. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36203. */
  36204. wheelPrecision: number;
  36205. /**
  36206. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36207. * It will be used instead of pinchDeltaPrecision if different from 0.
  36208. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36209. */
  36210. wheelDeltaPercentage: number;
  36211. /**
  36212. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36213. */
  36214. zoomOnFactor: number;
  36215. /**
  36216. * Defines a screen offset for the camera position.
  36217. */
  36218. targetScreenOffset: Vector2;
  36219. /**
  36220. * Allows the camera to be completely reversed.
  36221. * If false the camera can not arrive upside down.
  36222. */
  36223. allowUpsideDown: boolean;
  36224. /**
  36225. * Define if double tap/click is used to restore the previously saved state of the camera.
  36226. */
  36227. useInputToRestoreState: boolean;
  36228. /** @hidden */
  36229. _viewMatrix: Matrix;
  36230. /** @hidden */
  36231. _useCtrlForPanning: boolean;
  36232. /** @hidden */
  36233. _panningMouseButton: number;
  36234. /**
  36235. * Defines the input associated to the camera.
  36236. */
  36237. inputs: ArcRotateCameraInputsManager;
  36238. /** @hidden */
  36239. _reset: () => void;
  36240. /**
  36241. * Defines the allowed panning axis.
  36242. */
  36243. panningAxis: Vector3;
  36244. protected _localDirection: Vector3;
  36245. protected _transformedDirection: Vector3;
  36246. private _bouncingBehavior;
  36247. /**
  36248. * Gets the bouncing behavior of the camera if it has been enabled.
  36249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36250. */
  36251. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36252. /**
  36253. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36254. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36255. */
  36256. useBouncingBehavior: boolean;
  36257. private _framingBehavior;
  36258. /**
  36259. * Gets the framing behavior of the camera if it has been enabled.
  36260. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36261. */
  36262. readonly framingBehavior: Nullable<FramingBehavior>;
  36263. /**
  36264. * Defines if the framing behavior of the camera is enabled on the camera.
  36265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36266. */
  36267. useFramingBehavior: boolean;
  36268. private _autoRotationBehavior;
  36269. /**
  36270. * Gets the auto rotation behavior of the camera if it has been enabled.
  36271. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36272. */
  36273. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36274. /**
  36275. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36277. */
  36278. useAutoRotationBehavior: boolean;
  36279. /**
  36280. * Observable triggered when the mesh target has been changed on the camera.
  36281. */
  36282. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36283. /**
  36284. * Event raised when the camera is colliding with a mesh.
  36285. */
  36286. onCollide: (collidedMesh: AbstractMesh) => void;
  36287. /**
  36288. * Defines whether the camera should check collision with the objects oh the scene.
  36289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36290. */
  36291. checkCollisions: boolean;
  36292. /**
  36293. * Defines the collision radius of the camera.
  36294. * This simulates a sphere around the camera.
  36295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36296. */
  36297. collisionRadius: Vector3;
  36298. protected _collider: Collider;
  36299. protected _previousPosition: Vector3;
  36300. protected _collisionVelocity: Vector3;
  36301. protected _newPosition: Vector3;
  36302. protected _previousAlpha: number;
  36303. protected _previousBeta: number;
  36304. protected _previousRadius: number;
  36305. protected _collisionTriggered: boolean;
  36306. protected _targetBoundingCenter: Nullable<Vector3>;
  36307. private _computationVector;
  36308. private _tempAxisVector;
  36309. private _tempAxisRotationMatrix;
  36310. /**
  36311. * Instantiates a new ArcRotateCamera in a given scene
  36312. * @param name Defines the name of the camera
  36313. * @param alpha Defines the camera rotation along the logitudinal axis
  36314. * @param beta Defines the camera rotation along the latitudinal axis
  36315. * @param radius Defines the camera distance from its target
  36316. * @param target Defines the camera target
  36317. * @param scene Defines the scene the camera belongs to
  36318. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36319. */
  36320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36321. /** @hidden */
  36322. _initCache(): void;
  36323. /** @hidden */
  36324. _updateCache(ignoreParentClass?: boolean): void;
  36325. protected _getTargetPosition(): Vector3;
  36326. private _storedAlpha;
  36327. private _storedBeta;
  36328. private _storedRadius;
  36329. private _storedTarget;
  36330. /**
  36331. * Stores the current state of the camera (alpha, beta, radius and target)
  36332. * @returns the camera itself
  36333. */
  36334. storeState(): Camera;
  36335. /**
  36336. * @hidden
  36337. * Restored camera state. You must call storeState() first
  36338. */
  36339. _restoreStateValues(): boolean;
  36340. /** @hidden */
  36341. _isSynchronizedViewMatrix(): boolean;
  36342. /**
  36343. * Attached controls to the current camera.
  36344. * @param element Defines the element the controls should be listened from
  36345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36346. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36347. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36348. */
  36349. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36350. /**
  36351. * Detach the current controls from the camera.
  36352. * The camera will stop reacting to inputs.
  36353. * @param element Defines the element to stop listening the inputs from
  36354. */
  36355. detachControl(element: HTMLElement): void;
  36356. /** @hidden */
  36357. _checkInputs(): void;
  36358. protected _checkLimits(): void;
  36359. /**
  36360. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  36361. */
  36362. rebuildAnglesAndRadius(): void;
  36363. /**
  36364. * Use a position to define the current camera related information like aplha, beta and radius
  36365. * @param position Defines the position to set the camera at
  36366. */
  36367. setPosition(position: Vector3): void;
  36368. /**
  36369. * Defines the target the camera should look at.
  36370. * This will automatically adapt alpha beta and radius to fit within the new target.
  36371. * @param target Defines the new target as a Vector or a mesh
  36372. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36373. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36374. */
  36375. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36376. /** @hidden */
  36377. _getViewMatrix(): Matrix;
  36378. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36379. /**
  36380. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36381. * @param meshes Defines the mesh to zoom on
  36382. * @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)
  36383. */
  36384. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36385. /**
  36386. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36387. * The target will be changed but the radius
  36388. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36389. * @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)
  36390. */
  36391. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36392. min: Vector3;
  36393. max: Vector3;
  36394. distance: number;
  36395. }, doNotUpdateMaxZ?: boolean): void;
  36396. /**
  36397. * @override
  36398. * Override Camera.createRigCamera
  36399. */
  36400. createRigCamera(name: string, cameraIndex: number): Camera;
  36401. /**
  36402. * @hidden
  36403. * @override
  36404. * Override Camera._updateRigCameras
  36405. */
  36406. _updateRigCameras(): void;
  36407. /**
  36408. * Destroy the camera and release the current resources hold by it.
  36409. */
  36410. dispose(): void;
  36411. /**
  36412. * Gets the current object class name.
  36413. * @return the class name
  36414. */
  36415. getClassName(): string;
  36416. }
  36417. }
  36418. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36419. import { Behavior } from "babylonjs/Behaviors/behavior";
  36420. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36421. /**
  36422. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36423. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36424. */
  36425. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36426. /**
  36427. * Gets the name of the behavior.
  36428. */
  36429. readonly name: string;
  36430. private _zoomStopsAnimation;
  36431. private _idleRotationSpeed;
  36432. private _idleRotationWaitTime;
  36433. private _idleRotationSpinupTime;
  36434. /**
  36435. * Sets the flag that indicates if user zooming should stop animation.
  36436. */
  36437. /**
  36438. * Gets the flag that indicates if user zooming should stop animation.
  36439. */
  36440. zoomStopsAnimation: boolean;
  36441. /**
  36442. * Sets the default speed at which the camera rotates around the model.
  36443. */
  36444. /**
  36445. * Gets the default speed at which the camera rotates around the model.
  36446. */
  36447. idleRotationSpeed: number;
  36448. /**
  36449. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36450. */
  36451. /**
  36452. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36453. */
  36454. idleRotationWaitTime: number;
  36455. /**
  36456. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36457. */
  36458. /**
  36459. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36460. */
  36461. idleRotationSpinupTime: number;
  36462. /**
  36463. * Gets a value indicating if the camera is currently rotating because of this behavior
  36464. */
  36465. readonly rotationInProgress: boolean;
  36466. private _onPrePointerObservableObserver;
  36467. private _onAfterCheckInputsObserver;
  36468. private _attachedCamera;
  36469. private _isPointerDown;
  36470. private _lastFrameTime;
  36471. private _lastInteractionTime;
  36472. private _cameraRotationSpeed;
  36473. /**
  36474. * Initializes the behavior.
  36475. */
  36476. init(): void;
  36477. /**
  36478. * Attaches the behavior to its arc rotate camera.
  36479. * @param camera Defines the camera to attach the behavior to
  36480. */
  36481. attach(camera: ArcRotateCamera): void;
  36482. /**
  36483. * Detaches the behavior from its current arc rotate camera.
  36484. */
  36485. detach(): void;
  36486. /**
  36487. * Returns true if user is scrolling.
  36488. * @return true if user is scrolling.
  36489. */
  36490. private _userIsZooming;
  36491. private _lastFrameRadius;
  36492. private _shouldAnimationStopForInteraction;
  36493. /**
  36494. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36495. */
  36496. private _applyUserInteraction;
  36497. private _userIsMoving;
  36498. }
  36499. }
  36500. declare module "babylonjs/Behaviors/Cameras/index" {
  36501. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36502. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36503. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36504. }
  36505. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36506. import { Mesh } from "babylonjs/Meshes/mesh";
  36507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36508. import { Behavior } from "babylonjs/Behaviors/behavior";
  36509. /**
  36510. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36511. */
  36512. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36513. private ui;
  36514. /**
  36515. * The name of the behavior
  36516. */
  36517. name: string;
  36518. /**
  36519. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36520. */
  36521. distanceAwayFromFace: number;
  36522. /**
  36523. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36524. */
  36525. distanceAwayFromBottomOfFace: number;
  36526. private _faceVectors;
  36527. private _target;
  36528. private _scene;
  36529. private _onRenderObserver;
  36530. private _tmpMatrix;
  36531. private _tmpVector;
  36532. /**
  36533. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36534. * @param ui The transform node that should be attched to the mesh
  36535. */
  36536. constructor(ui: TransformNode);
  36537. /**
  36538. * Initializes the behavior
  36539. */
  36540. init(): void;
  36541. private _closestFace;
  36542. private _zeroVector;
  36543. private _lookAtTmpMatrix;
  36544. private _lookAtToRef;
  36545. /**
  36546. * Attaches the AttachToBoxBehavior to the passed in mesh
  36547. * @param target The mesh that the specified node will be attached to
  36548. */
  36549. attach(target: Mesh): void;
  36550. /**
  36551. * Detaches the behavior from the mesh
  36552. */
  36553. detach(): void;
  36554. }
  36555. }
  36556. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36557. import { Behavior } from "babylonjs/Behaviors/behavior";
  36558. import { Mesh } from "babylonjs/Meshes/mesh";
  36559. /**
  36560. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36561. */
  36562. export class FadeInOutBehavior implements Behavior<Mesh> {
  36563. /**
  36564. * Time in milliseconds to delay before fading in (Default: 0)
  36565. */
  36566. delay: number;
  36567. /**
  36568. * Time in milliseconds for the mesh to fade in (Default: 300)
  36569. */
  36570. fadeInTime: number;
  36571. private _millisecondsPerFrame;
  36572. private _hovered;
  36573. private _hoverValue;
  36574. private _ownerNode;
  36575. /**
  36576. * Instatiates the FadeInOutBehavior
  36577. */
  36578. constructor();
  36579. /**
  36580. * The name of the behavior
  36581. */
  36582. readonly name: string;
  36583. /**
  36584. * Initializes the behavior
  36585. */
  36586. init(): void;
  36587. /**
  36588. * Attaches the fade behavior on the passed in mesh
  36589. * @param ownerNode The mesh that will be faded in/out once attached
  36590. */
  36591. attach(ownerNode: Mesh): void;
  36592. /**
  36593. * Detaches the behavior from the mesh
  36594. */
  36595. detach(): void;
  36596. /**
  36597. * Triggers the mesh to begin fading in or out
  36598. * @param value if the object should fade in or out (true to fade in)
  36599. */
  36600. fadeIn(value: boolean): void;
  36601. private _update;
  36602. private _setAllVisibility;
  36603. }
  36604. }
  36605. declare module "babylonjs/Misc/pivotTools" {
  36606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36607. /**
  36608. * Class containing a set of static utilities functions for managing Pivots
  36609. * @hidden
  36610. */
  36611. export class PivotTools {
  36612. private static _PivotCached;
  36613. private static _OldPivotPoint;
  36614. private static _PivotTranslation;
  36615. private static _PivotTmpVector;
  36616. /** @hidden */
  36617. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36618. /** @hidden */
  36619. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36620. }
  36621. }
  36622. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36623. import { Behavior } from "babylonjs/Behaviors/behavior";
  36624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36625. import { Observable } from "babylonjs/Misc/observable";
  36626. import { Vector3 } from "babylonjs/Maths/math";
  36627. import { Ray } from "babylonjs/Culling/ray";
  36628. /**
  36629. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36630. */
  36631. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36632. private static _AnyMouseID;
  36633. private _attachedNode;
  36634. private _dragPlane;
  36635. private _scene;
  36636. private _pointerObserver;
  36637. private _beforeRenderObserver;
  36638. private static _planeScene;
  36639. /**
  36640. * 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)
  36641. */
  36642. maxDragAngle: number;
  36643. /**
  36644. * @hidden
  36645. */
  36646. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36647. /**
  36648. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36649. */
  36650. currentDraggingPointerID: number;
  36651. /**
  36652. * The last position where the pointer hit the drag plane in world space
  36653. */
  36654. lastDragPosition: Vector3;
  36655. /**
  36656. * If the behavior is currently in a dragging state
  36657. */
  36658. dragging: boolean;
  36659. /**
  36660. * 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)
  36661. */
  36662. dragDeltaRatio: number;
  36663. /**
  36664. * If the drag plane orientation should be updated during the dragging (Default: true)
  36665. */
  36666. updateDragPlane: boolean;
  36667. private _debugMode;
  36668. private _moving;
  36669. /**
  36670. * Fires each time the attached mesh is dragged with the pointer
  36671. * * delta between last drag position and current drag position in world space
  36672. * * dragDistance along the drag axis
  36673. * * dragPlaneNormal normal of the current drag plane used during the drag
  36674. * * dragPlanePoint in world space where the drag intersects the drag plane
  36675. */
  36676. onDragObservable: Observable<{
  36677. delta: Vector3;
  36678. dragPlanePoint: Vector3;
  36679. dragPlaneNormal: Vector3;
  36680. dragDistance: number;
  36681. pointerId: number;
  36682. }>;
  36683. /**
  36684. * Fires each time a drag begins (eg. mouse down on mesh)
  36685. */
  36686. onDragStartObservable: Observable<{
  36687. dragPlanePoint: Vector3;
  36688. pointerId: number;
  36689. }>;
  36690. /**
  36691. * Fires each time a drag ends (eg. mouse release after drag)
  36692. */
  36693. onDragEndObservable: Observable<{
  36694. dragPlanePoint: Vector3;
  36695. pointerId: number;
  36696. }>;
  36697. /**
  36698. * If the attached mesh should be moved when dragged
  36699. */
  36700. moveAttached: boolean;
  36701. /**
  36702. * If the drag behavior will react to drag events (Default: true)
  36703. */
  36704. enabled: boolean;
  36705. /**
  36706. * If camera controls should be detached during the drag
  36707. */
  36708. detachCameraControls: boolean;
  36709. /**
  36710. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36711. */
  36712. useObjectOrienationForDragging: boolean;
  36713. private _options;
  36714. /**
  36715. * Creates a pointer drag behavior that can be attached to a mesh
  36716. * @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)
  36717. */
  36718. constructor(options?: {
  36719. dragAxis?: Vector3;
  36720. dragPlaneNormal?: Vector3;
  36721. });
  36722. /**
  36723. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36724. */
  36725. validateDrag: (targetPosition: Vector3) => boolean;
  36726. /**
  36727. * The name of the behavior
  36728. */
  36729. readonly name: string;
  36730. /**
  36731. * Initializes the behavior
  36732. */
  36733. init(): void;
  36734. private _tmpVector;
  36735. private _alternatePickedPoint;
  36736. private _worldDragAxis;
  36737. private _targetPosition;
  36738. private _attachedElement;
  36739. /**
  36740. * Attaches the drag behavior the passed in mesh
  36741. * @param ownerNode The mesh that will be dragged around once attached
  36742. */
  36743. attach(ownerNode: AbstractMesh): void;
  36744. /**
  36745. * Force relase the drag action by code.
  36746. */
  36747. releaseDrag(): void;
  36748. private _startDragRay;
  36749. private _lastPointerRay;
  36750. /**
  36751. * Simulates the start of a pointer drag event on the behavior
  36752. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36753. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36754. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36755. */
  36756. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36757. private _startDrag;
  36758. private _dragDelta;
  36759. private _moveDrag;
  36760. private _pickWithRayOnDragPlane;
  36761. private _pointA;
  36762. private _pointB;
  36763. private _pointC;
  36764. private _lineA;
  36765. private _lineB;
  36766. private _localAxis;
  36767. private _lookAt;
  36768. private _updateDragPlanePosition;
  36769. /**
  36770. * Detaches the behavior from the mesh
  36771. */
  36772. detach(): void;
  36773. }
  36774. }
  36775. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36776. import { Mesh } from "babylonjs/Meshes/mesh";
  36777. import { Behavior } from "babylonjs/Behaviors/behavior";
  36778. /**
  36779. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36780. */
  36781. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36782. private _dragBehaviorA;
  36783. private _dragBehaviorB;
  36784. private _startDistance;
  36785. private _initialScale;
  36786. private _targetScale;
  36787. private _ownerNode;
  36788. private _sceneRenderObserver;
  36789. /**
  36790. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36791. */
  36792. constructor();
  36793. /**
  36794. * The name of the behavior
  36795. */
  36796. readonly name: string;
  36797. /**
  36798. * Initializes the behavior
  36799. */
  36800. init(): void;
  36801. private _getCurrentDistance;
  36802. /**
  36803. * Attaches the scale behavior the passed in mesh
  36804. * @param ownerNode The mesh that will be scaled around once attached
  36805. */
  36806. attach(ownerNode: Mesh): void;
  36807. /**
  36808. * Detaches the behavior from the mesh
  36809. */
  36810. detach(): void;
  36811. }
  36812. }
  36813. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36814. import { Behavior } from "babylonjs/Behaviors/behavior";
  36815. import { Mesh } from "babylonjs/Meshes/mesh";
  36816. import { Observable } from "babylonjs/Misc/observable";
  36817. /**
  36818. * 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
  36819. */
  36820. export class SixDofDragBehavior implements Behavior<Mesh> {
  36821. private static _virtualScene;
  36822. private _ownerNode;
  36823. private _sceneRenderObserver;
  36824. private _scene;
  36825. private _targetPosition;
  36826. private _virtualOriginMesh;
  36827. private _virtualDragMesh;
  36828. private _pointerObserver;
  36829. private _moving;
  36830. private _startingOrientation;
  36831. /**
  36832. * 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)
  36833. */
  36834. private zDragFactor;
  36835. /**
  36836. * If the object should rotate to face the drag origin
  36837. */
  36838. rotateDraggedObject: boolean;
  36839. /**
  36840. * If the behavior is currently in a dragging state
  36841. */
  36842. dragging: boolean;
  36843. /**
  36844. * 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)
  36845. */
  36846. dragDeltaRatio: number;
  36847. /**
  36848. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36849. */
  36850. currentDraggingPointerID: number;
  36851. /**
  36852. * If camera controls should be detached during the drag
  36853. */
  36854. detachCameraControls: boolean;
  36855. /**
  36856. * Fires each time a drag starts
  36857. */
  36858. onDragStartObservable: Observable<{}>;
  36859. /**
  36860. * Fires each time a drag ends (eg. mouse release after drag)
  36861. */
  36862. onDragEndObservable: Observable<{}>;
  36863. /**
  36864. * 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
  36865. */
  36866. constructor();
  36867. /**
  36868. * The name of the behavior
  36869. */
  36870. readonly name: string;
  36871. /**
  36872. * Initializes the behavior
  36873. */
  36874. init(): void;
  36875. /**
  36876. * Attaches the scale behavior the passed in mesh
  36877. * @param ownerNode The mesh that will be scaled around once attached
  36878. */
  36879. attach(ownerNode: Mesh): void;
  36880. /**
  36881. * Detaches the behavior from the mesh
  36882. */
  36883. detach(): void;
  36884. }
  36885. }
  36886. declare module "babylonjs/Behaviors/Meshes/index" {
  36887. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36888. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36889. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36890. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36891. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36892. }
  36893. declare module "babylonjs/Behaviors/index" {
  36894. export * from "babylonjs/Behaviors/behavior";
  36895. export * from "babylonjs/Behaviors/Cameras/index";
  36896. export * from "babylonjs/Behaviors/Meshes/index";
  36897. }
  36898. declare module "babylonjs/Bones/boneIKController" {
  36899. import { Bone } from "babylonjs/Bones/bone";
  36900. import { Vector3 } from "babylonjs/Maths/math";
  36901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36902. import { Nullable } from "babylonjs/types";
  36903. /**
  36904. * Class used to apply inverse kinematics to bones
  36905. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36906. */
  36907. export class BoneIKController {
  36908. private static _tmpVecs;
  36909. private static _tmpQuat;
  36910. private static _tmpMats;
  36911. /**
  36912. * Gets or sets the target mesh
  36913. */
  36914. targetMesh: AbstractMesh;
  36915. /** Gets or sets the mesh used as pole */
  36916. poleTargetMesh: AbstractMesh;
  36917. /**
  36918. * Gets or sets the bone used as pole
  36919. */
  36920. poleTargetBone: Nullable<Bone>;
  36921. /**
  36922. * Gets or sets the target position
  36923. */
  36924. targetPosition: Vector3;
  36925. /**
  36926. * Gets or sets the pole target position
  36927. */
  36928. poleTargetPosition: Vector3;
  36929. /**
  36930. * Gets or sets the pole target local offset
  36931. */
  36932. poleTargetLocalOffset: Vector3;
  36933. /**
  36934. * Gets or sets the pole angle
  36935. */
  36936. poleAngle: number;
  36937. /**
  36938. * Gets or sets the mesh associated with the controller
  36939. */
  36940. mesh: AbstractMesh;
  36941. /**
  36942. * 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)
  36943. */
  36944. slerpAmount: number;
  36945. private _bone1Quat;
  36946. private _bone1Mat;
  36947. private _bone2Ang;
  36948. private _bone1;
  36949. private _bone2;
  36950. private _bone1Length;
  36951. private _bone2Length;
  36952. private _maxAngle;
  36953. private _maxReach;
  36954. private _rightHandedSystem;
  36955. private _bendAxis;
  36956. private _slerping;
  36957. private _adjustRoll;
  36958. /**
  36959. * Gets or sets maximum allowed angle
  36960. */
  36961. maxAngle: number;
  36962. /**
  36963. * Creates a new BoneIKController
  36964. * @param mesh defines the mesh to control
  36965. * @param bone defines the bone to control
  36966. * @param options defines options to set up the controller
  36967. */
  36968. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36969. targetMesh?: AbstractMesh;
  36970. poleTargetMesh?: AbstractMesh;
  36971. poleTargetBone?: Bone;
  36972. poleTargetLocalOffset?: Vector3;
  36973. poleAngle?: number;
  36974. bendAxis?: Vector3;
  36975. maxAngle?: number;
  36976. slerpAmount?: number;
  36977. });
  36978. private _setMaxAngle;
  36979. /**
  36980. * Force the controller to update the bones
  36981. */
  36982. update(): void;
  36983. }
  36984. }
  36985. declare module "babylonjs/Bones/boneLookController" {
  36986. import { Vector3, Space } from "babylonjs/Maths/math";
  36987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36988. import { Bone } from "babylonjs/Bones/bone";
  36989. /**
  36990. * Class used to make a bone look toward a point in space
  36991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36992. */
  36993. export class BoneLookController {
  36994. private static _tmpVecs;
  36995. private static _tmpQuat;
  36996. private static _tmpMats;
  36997. /**
  36998. * The target Vector3 that the bone will look at
  36999. */
  37000. target: Vector3;
  37001. /**
  37002. * The mesh that the bone is attached to
  37003. */
  37004. mesh: AbstractMesh;
  37005. /**
  37006. * The bone that will be looking to the target
  37007. */
  37008. bone: Bone;
  37009. /**
  37010. * The up axis of the coordinate system that is used when the bone is rotated
  37011. */
  37012. upAxis: Vector3;
  37013. /**
  37014. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37015. */
  37016. upAxisSpace: Space;
  37017. /**
  37018. * Used to make an adjustment to the yaw of the bone
  37019. */
  37020. adjustYaw: number;
  37021. /**
  37022. * Used to make an adjustment to the pitch of the bone
  37023. */
  37024. adjustPitch: number;
  37025. /**
  37026. * Used to make an adjustment to the roll of the bone
  37027. */
  37028. adjustRoll: number;
  37029. /**
  37030. * 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)
  37031. */
  37032. slerpAmount: number;
  37033. private _minYaw;
  37034. private _maxYaw;
  37035. private _minPitch;
  37036. private _maxPitch;
  37037. private _minYawSin;
  37038. private _minYawCos;
  37039. private _maxYawSin;
  37040. private _maxYawCos;
  37041. private _midYawConstraint;
  37042. private _minPitchTan;
  37043. private _maxPitchTan;
  37044. private _boneQuat;
  37045. private _slerping;
  37046. private _transformYawPitch;
  37047. private _transformYawPitchInv;
  37048. private _firstFrameSkipped;
  37049. private _yawRange;
  37050. private _fowardAxis;
  37051. /**
  37052. * Gets or sets the minimum yaw angle that the bone can look to
  37053. */
  37054. minYaw: number;
  37055. /**
  37056. * Gets or sets the maximum yaw angle that the bone can look to
  37057. */
  37058. maxYaw: number;
  37059. /**
  37060. * Gets or sets the minimum pitch angle that the bone can look to
  37061. */
  37062. minPitch: number;
  37063. /**
  37064. * Gets or sets the maximum pitch angle that the bone can look to
  37065. */
  37066. maxPitch: number;
  37067. /**
  37068. * Create a BoneLookController
  37069. * @param mesh the mesh that the bone belongs to
  37070. * @param bone the bone that will be looking to the target
  37071. * @param target the target Vector3 to look at
  37072. * @param settings optional settings:
  37073. * * maxYaw: the maximum angle the bone will yaw to
  37074. * * minYaw: the minimum angle the bone will yaw to
  37075. * * maxPitch: the maximum angle the bone will pitch to
  37076. * * minPitch: the minimum angle the bone will yaw to
  37077. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37078. * * upAxis: the up axis of the coordinate system
  37079. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37080. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37081. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37082. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37083. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37084. * * adjustRoll: used to make an adjustment to the roll of the bone
  37085. **/
  37086. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37087. maxYaw?: number;
  37088. minYaw?: number;
  37089. maxPitch?: number;
  37090. minPitch?: number;
  37091. slerpAmount?: number;
  37092. upAxis?: Vector3;
  37093. upAxisSpace?: Space;
  37094. yawAxis?: Vector3;
  37095. pitchAxis?: Vector3;
  37096. adjustYaw?: number;
  37097. adjustPitch?: number;
  37098. adjustRoll?: number;
  37099. });
  37100. /**
  37101. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37102. */
  37103. update(): void;
  37104. private _getAngleDiff;
  37105. private _getAngleBetween;
  37106. private _isAngleBetween;
  37107. }
  37108. }
  37109. declare module "babylonjs/Bones/index" {
  37110. export * from "babylonjs/Bones/bone";
  37111. export * from "babylonjs/Bones/boneIKController";
  37112. export * from "babylonjs/Bones/boneLookController";
  37113. export * from "babylonjs/Bones/skeleton";
  37114. }
  37115. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37116. import { Nullable } from "babylonjs/types";
  37117. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37118. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37119. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37120. /**
  37121. * Manage the gamepad inputs to control an arc rotate camera.
  37122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37123. */
  37124. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37125. /**
  37126. * Defines the camera the input is attached to.
  37127. */
  37128. camera: ArcRotateCamera;
  37129. /**
  37130. * Defines the gamepad the input is gathering event from.
  37131. */
  37132. gamepad: Nullable<Gamepad>;
  37133. /**
  37134. * Defines the gamepad rotation sensiblity.
  37135. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37136. */
  37137. gamepadRotationSensibility: number;
  37138. /**
  37139. * Defines the gamepad move sensiblity.
  37140. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37141. */
  37142. gamepadMoveSensibility: number;
  37143. private _onGamepadConnectedObserver;
  37144. private _onGamepadDisconnectedObserver;
  37145. /**
  37146. * Attach the input controls to a specific dom element to get the input from.
  37147. * @param element Defines the element the controls should be listened from
  37148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37149. */
  37150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37151. /**
  37152. * Detach the current controls from the specified dom element.
  37153. * @param element Defines the element to stop listening the inputs from
  37154. */
  37155. detachControl(element: Nullable<HTMLElement>): void;
  37156. /**
  37157. * Update the current camera state depending on the inputs that have been used this frame.
  37158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37159. */
  37160. checkInputs(): void;
  37161. /**
  37162. * Gets the class name of the current intput.
  37163. * @returns the class name
  37164. */
  37165. getClassName(): string;
  37166. /**
  37167. * Get the friendly name associated with the input class.
  37168. * @returns the input friendly name
  37169. */
  37170. getSimpleName(): string;
  37171. }
  37172. }
  37173. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37174. import { Nullable } from "babylonjs/types";
  37175. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37176. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37177. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37178. interface ArcRotateCameraInputsManager {
  37179. /**
  37180. * Add orientation input support to the input manager.
  37181. * @returns the current input manager
  37182. */
  37183. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37184. }
  37185. }
  37186. /**
  37187. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37189. */
  37190. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37191. /**
  37192. * Defines the camera the input is attached to.
  37193. */
  37194. camera: ArcRotateCamera;
  37195. /**
  37196. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37197. */
  37198. alphaCorrection: number;
  37199. /**
  37200. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37201. */
  37202. gammaCorrection: number;
  37203. private _alpha;
  37204. private _gamma;
  37205. private _dirty;
  37206. private _deviceOrientationHandler;
  37207. /**
  37208. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37209. */
  37210. constructor();
  37211. /**
  37212. * Attach the input controls to a specific dom element to get the input from.
  37213. * @param element Defines the element the controls should be listened from
  37214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37215. */
  37216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37217. /** @hidden */
  37218. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37219. /**
  37220. * Update the current camera state depending on the inputs that have been used this frame.
  37221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37222. */
  37223. checkInputs(): void;
  37224. /**
  37225. * Detach the current controls from the specified dom element.
  37226. * @param element Defines the element to stop listening the inputs from
  37227. */
  37228. detachControl(element: Nullable<HTMLElement>): void;
  37229. /**
  37230. * Gets the class name of the current intput.
  37231. * @returns the class name
  37232. */
  37233. getClassName(): string;
  37234. /**
  37235. * Get the friendly name associated with the input class.
  37236. * @returns the input friendly name
  37237. */
  37238. getSimpleName(): string;
  37239. }
  37240. }
  37241. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37242. import { Nullable } from "babylonjs/types";
  37243. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37244. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37245. /**
  37246. * Listen to mouse events to control the camera.
  37247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37248. */
  37249. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37250. /**
  37251. * Defines the camera the input is attached to.
  37252. */
  37253. camera: FlyCamera;
  37254. /**
  37255. * Defines if touch is enabled. (Default is true.)
  37256. */
  37257. touchEnabled: boolean;
  37258. /**
  37259. * Defines the buttons associated with the input to handle camera rotation.
  37260. */
  37261. buttons: number[];
  37262. /**
  37263. * Assign buttons for Yaw control.
  37264. */
  37265. buttonsYaw: number[];
  37266. /**
  37267. * Assign buttons for Pitch control.
  37268. */
  37269. buttonsPitch: number[];
  37270. /**
  37271. * Assign buttons for Roll control.
  37272. */
  37273. buttonsRoll: number[];
  37274. /**
  37275. * Detect if any button is being pressed while mouse is moved.
  37276. * -1 = Mouse locked.
  37277. * 0 = Left button.
  37278. * 1 = Middle Button.
  37279. * 2 = Right Button.
  37280. */
  37281. activeButton: number;
  37282. /**
  37283. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37284. * Higher values reduce its sensitivity.
  37285. */
  37286. angularSensibility: number;
  37287. private _mousemoveCallback;
  37288. private _observer;
  37289. private _rollObserver;
  37290. private previousPosition;
  37291. private noPreventDefault;
  37292. private element;
  37293. /**
  37294. * Listen to mouse events to control the camera.
  37295. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37297. */
  37298. constructor(touchEnabled?: boolean);
  37299. /**
  37300. * Attach the mouse control to the HTML DOM element.
  37301. * @param element Defines the element that listens to the input events.
  37302. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37303. */
  37304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37305. /**
  37306. * Detach the current controls from the specified dom element.
  37307. * @param element Defines the element to stop listening the inputs from
  37308. */
  37309. detachControl(element: Nullable<HTMLElement>): void;
  37310. /**
  37311. * Gets the class name of the current input.
  37312. * @returns the class name.
  37313. */
  37314. getClassName(): string;
  37315. /**
  37316. * Get the friendly name associated with the input class.
  37317. * @returns the input's friendly name.
  37318. */
  37319. getSimpleName(): string;
  37320. private _pointerInput;
  37321. private _onMouseMove;
  37322. /**
  37323. * Rotate camera by mouse offset.
  37324. */
  37325. private rotateCamera;
  37326. }
  37327. }
  37328. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37329. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37330. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37331. /**
  37332. * Default Inputs manager for the FlyCamera.
  37333. * It groups all the default supported inputs for ease of use.
  37334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37335. */
  37336. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37337. /**
  37338. * Instantiates a new FlyCameraInputsManager.
  37339. * @param camera Defines the camera the inputs belong to.
  37340. */
  37341. constructor(camera: FlyCamera);
  37342. /**
  37343. * Add keyboard input support to the input manager.
  37344. * @returns the new FlyCameraKeyboardMoveInput().
  37345. */
  37346. addKeyboard(): FlyCameraInputsManager;
  37347. /**
  37348. * Add mouse input support to the input manager.
  37349. * @param touchEnabled Enable touch screen support.
  37350. * @returns the new FlyCameraMouseInput().
  37351. */
  37352. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37353. }
  37354. }
  37355. declare module "babylonjs/Cameras/flyCamera" {
  37356. import { Scene } from "babylonjs/scene";
  37357. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37359. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37360. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37361. /**
  37362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37363. * such as in a 3D Space Shooter or a Flight Simulator.
  37364. */
  37365. export class FlyCamera extends TargetCamera {
  37366. /**
  37367. * Define the collision ellipsoid of the camera.
  37368. * This is helpful for simulating a camera body, like a player's body.
  37369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37370. */
  37371. ellipsoid: Vector3;
  37372. /**
  37373. * Define an offset for the position of the ellipsoid around the camera.
  37374. * This can be helpful if the camera is attached away from the player's body center,
  37375. * such as at its head.
  37376. */
  37377. ellipsoidOffset: Vector3;
  37378. /**
  37379. * Enable or disable collisions of the camera with the rest of the scene objects.
  37380. */
  37381. checkCollisions: boolean;
  37382. /**
  37383. * Enable or disable gravity on the camera.
  37384. */
  37385. applyGravity: boolean;
  37386. /**
  37387. * Define the current direction the camera is moving to.
  37388. */
  37389. cameraDirection: Vector3;
  37390. /**
  37391. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37392. * This overrides and empties cameraRotation.
  37393. */
  37394. rotationQuaternion: Quaternion;
  37395. /**
  37396. * Track Roll to maintain the wanted Rolling when looking around.
  37397. */
  37398. _trackRoll: number;
  37399. /**
  37400. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37401. */
  37402. rollCorrect: number;
  37403. /**
  37404. * Mimic a banked turn, Rolling the camera when Yawing.
  37405. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37406. */
  37407. bankedTurn: boolean;
  37408. /**
  37409. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37410. */
  37411. bankedTurnLimit: number;
  37412. /**
  37413. * Value of 0 disables the banked Roll.
  37414. * Value of 1 is equal to the Yaw angle in radians.
  37415. */
  37416. bankedTurnMultiplier: number;
  37417. /**
  37418. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37419. */
  37420. inputs: FlyCameraInputsManager;
  37421. /**
  37422. * Gets the input sensibility for mouse input.
  37423. * Higher values reduce sensitivity.
  37424. */
  37425. /**
  37426. * Sets the input sensibility for a mouse input.
  37427. * Higher values reduce sensitivity.
  37428. */
  37429. angularSensibility: number;
  37430. /**
  37431. * Get the keys for camera movement forward.
  37432. */
  37433. /**
  37434. * Set the keys for camera movement forward.
  37435. */
  37436. keysForward: number[];
  37437. /**
  37438. * Get the keys for camera movement backward.
  37439. */
  37440. keysBackward: number[];
  37441. /**
  37442. * Get the keys for camera movement up.
  37443. */
  37444. /**
  37445. * Set the keys for camera movement up.
  37446. */
  37447. keysUp: number[];
  37448. /**
  37449. * Get the keys for camera movement down.
  37450. */
  37451. /**
  37452. * Set the keys for camera movement down.
  37453. */
  37454. keysDown: number[];
  37455. /**
  37456. * Get the keys for camera movement left.
  37457. */
  37458. /**
  37459. * Set the keys for camera movement left.
  37460. */
  37461. keysLeft: number[];
  37462. /**
  37463. * Set the keys for camera movement right.
  37464. */
  37465. /**
  37466. * Set the keys for camera movement right.
  37467. */
  37468. keysRight: number[];
  37469. /**
  37470. * Event raised when the camera collides with a mesh in the scene.
  37471. */
  37472. onCollide: (collidedMesh: AbstractMesh) => void;
  37473. private _collider;
  37474. private _needMoveForGravity;
  37475. private _oldPosition;
  37476. private _diffPosition;
  37477. private _newPosition;
  37478. /** @hidden */
  37479. _localDirection: Vector3;
  37480. /** @hidden */
  37481. _transformedDirection: Vector3;
  37482. /**
  37483. * Instantiates a FlyCamera.
  37484. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37485. * such as in a 3D Space Shooter or a Flight Simulator.
  37486. * @param name Define the name of the camera in the scene.
  37487. * @param position Define the starting position of the camera in the scene.
  37488. * @param scene Define the scene the camera belongs to.
  37489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37490. */
  37491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37492. /**
  37493. * Attach a control to the HTML DOM element.
  37494. * @param element Defines the element that listens to the input events.
  37495. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37496. */
  37497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37498. /**
  37499. * Detach a control from the HTML DOM element.
  37500. * The camera will stop reacting to that input.
  37501. * @param element Defines the element that listens to the input events.
  37502. */
  37503. detachControl(element: HTMLElement): void;
  37504. private _collisionMask;
  37505. /**
  37506. * Get the mask that the camera ignores in collision events.
  37507. */
  37508. /**
  37509. * Set the mask that the camera ignores in collision events.
  37510. */
  37511. collisionMask: number;
  37512. /** @hidden */
  37513. _collideWithWorld(displacement: Vector3): void;
  37514. /** @hidden */
  37515. private _onCollisionPositionChange;
  37516. /** @hidden */
  37517. _checkInputs(): void;
  37518. /** @hidden */
  37519. _decideIfNeedsToMove(): boolean;
  37520. /** @hidden */
  37521. _updatePosition(): void;
  37522. /**
  37523. * Restore the Roll to its target value at the rate specified.
  37524. * @param rate - Higher means slower restoring.
  37525. * @hidden
  37526. */
  37527. restoreRoll(rate: number): void;
  37528. /**
  37529. * Destroy the camera and release the current resources held by it.
  37530. */
  37531. dispose(): void;
  37532. /**
  37533. * Get the current object class name.
  37534. * @returns the class name.
  37535. */
  37536. getClassName(): string;
  37537. }
  37538. }
  37539. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37540. import { Nullable } from "babylonjs/types";
  37541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37542. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37543. /**
  37544. * Listen to keyboard events to control the camera.
  37545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37546. */
  37547. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37548. /**
  37549. * Defines the camera the input is attached to.
  37550. */
  37551. camera: FlyCamera;
  37552. /**
  37553. * The list of keyboard keys used to control the forward move of the camera.
  37554. */
  37555. keysForward: number[];
  37556. /**
  37557. * The list of keyboard keys used to control the backward move of the camera.
  37558. */
  37559. keysBackward: number[];
  37560. /**
  37561. * The list of keyboard keys used to control the forward move of the camera.
  37562. */
  37563. keysUp: number[];
  37564. /**
  37565. * The list of keyboard keys used to control the backward move of the camera.
  37566. */
  37567. keysDown: number[];
  37568. /**
  37569. * The list of keyboard keys used to control the right strafe move of the camera.
  37570. */
  37571. keysRight: number[];
  37572. /**
  37573. * The list of keyboard keys used to control the left strafe move of the camera.
  37574. */
  37575. keysLeft: number[];
  37576. private _keys;
  37577. private _onCanvasBlurObserver;
  37578. private _onKeyboardObserver;
  37579. private _engine;
  37580. private _scene;
  37581. /**
  37582. * Attach the input controls to a specific dom element to get the input from.
  37583. * @param element Defines the element the controls should be listened from
  37584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37585. */
  37586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37587. /**
  37588. * Detach the current controls from the specified dom element.
  37589. * @param element Defines the element to stop listening the inputs from
  37590. */
  37591. detachControl(element: Nullable<HTMLElement>): void;
  37592. /**
  37593. * Gets the class name of the current intput.
  37594. * @returns the class name
  37595. */
  37596. getClassName(): string;
  37597. /** @hidden */
  37598. _onLostFocus(e: FocusEvent): void;
  37599. /**
  37600. * Get the friendly name associated with the input class.
  37601. * @returns the input friendly name
  37602. */
  37603. getSimpleName(): string;
  37604. /**
  37605. * Update the current camera state depending on the inputs that have been used this frame.
  37606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37607. */
  37608. checkInputs(): void;
  37609. }
  37610. }
  37611. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37612. import { Nullable } from "babylonjs/types";
  37613. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37614. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37615. module "babylonjs/Cameras/freeCameraInputsManager" {
  37616. interface FreeCameraInputsManager {
  37617. /**
  37618. * Add orientation input support to the input manager.
  37619. * @returns the current input manager
  37620. */
  37621. addDeviceOrientation(): FreeCameraInputsManager;
  37622. }
  37623. }
  37624. /**
  37625. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37626. * Screen rotation is taken into account.
  37627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37628. */
  37629. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37630. private _camera;
  37631. private _screenOrientationAngle;
  37632. private _constantTranform;
  37633. private _screenQuaternion;
  37634. private _alpha;
  37635. private _beta;
  37636. private _gamma;
  37637. /**
  37638. * Instantiates a new input
  37639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37640. */
  37641. constructor();
  37642. /**
  37643. * Define the camera controlled by the input.
  37644. */
  37645. camera: FreeCamera;
  37646. /**
  37647. * Attach the input controls to a specific dom element to get the input from.
  37648. * @param element Defines the element the controls should be listened from
  37649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37650. */
  37651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37652. private _orientationChanged;
  37653. private _deviceOrientation;
  37654. /**
  37655. * Detach the current controls from the specified dom element.
  37656. * @param element Defines the element to stop listening the inputs from
  37657. */
  37658. detachControl(element: Nullable<HTMLElement>): void;
  37659. /**
  37660. * Update the current camera state depending on the inputs that have been used this frame.
  37661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37662. */
  37663. checkInputs(): void;
  37664. /**
  37665. * Gets the class name of the current intput.
  37666. * @returns the class name
  37667. */
  37668. getClassName(): string;
  37669. /**
  37670. * Get the friendly name associated with the input class.
  37671. * @returns the input friendly name
  37672. */
  37673. getSimpleName(): string;
  37674. }
  37675. }
  37676. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37677. import { Nullable } from "babylonjs/types";
  37678. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37679. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37680. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37681. /**
  37682. * Manage the gamepad inputs to control a free camera.
  37683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37684. */
  37685. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37686. /**
  37687. * Define the camera the input is attached to.
  37688. */
  37689. camera: FreeCamera;
  37690. /**
  37691. * Define the Gamepad controlling the input
  37692. */
  37693. gamepad: Nullable<Gamepad>;
  37694. /**
  37695. * Defines the gamepad rotation sensiblity.
  37696. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37697. */
  37698. gamepadAngularSensibility: number;
  37699. /**
  37700. * Defines the gamepad move sensiblity.
  37701. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37702. */
  37703. gamepadMoveSensibility: number;
  37704. private _onGamepadConnectedObserver;
  37705. private _onGamepadDisconnectedObserver;
  37706. private _cameraTransform;
  37707. private _deltaTransform;
  37708. private _vector3;
  37709. private _vector2;
  37710. /**
  37711. * Attach the input controls to a specific dom element to get the input from.
  37712. * @param element Defines the element the controls should be listened from
  37713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37714. */
  37715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37716. /**
  37717. * Detach the current controls from the specified dom element.
  37718. * @param element Defines the element to stop listening the inputs from
  37719. */
  37720. detachControl(element: Nullable<HTMLElement>): void;
  37721. /**
  37722. * Update the current camera state depending on the inputs that have been used this frame.
  37723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37724. */
  37725. checkInputs(): void;
  37726. /**
  37727. * Gets the class name of the current intput.
  37728. * @returns the class name
  37729. */
  37730. getClassName(): string;
  37731. /**
  37732. * Get the friendly name associated with the input class.
  37733. * @returns the input friendly name
  37734. */
  37735. getSimpleName(): string;
  37736. }
  37737. }
  37738. declare module "babylonjs/Misc/virtualJoystick" {
  37739. import { Nullable } from "babylonjs/types";
  37740. import { Vector3 } from "babylonjs/Maths/math";
  37741. /**
  37742. * Defines the potential axis of a Joystick
  37743. */
  37744. export enum JoystickAxis {
  37745. /** X axis */
  37746. X = 0,
  37747. /** Y axis */
  37748. Y = 1,
  37749. /** Z axis */
  37750. Z = 2
  37751. }
  37752. /**
  37753. * Class used to define virtual joystick (used in touch mode)
  37754. */
  37755. export class VirtualJoystick {
  37756. /**
  37757. * Gets or sets a boolean indicating that left and right values must be inverted
  37758. */
  37759. reverseLeftRight: boolean;
  37760. /**
  37761. * Gets or sets a boolean indicating that up and down values must be inverted
  37762. */
  37763. reverseUpDown: boolean;
  37764. /**
  37765. * Gets the offset value for the position (ie. the change of the position value)
  37766. */
  37767. deltaPosition: Vector3;
  37768. /**
  37769. * Gets a boolean indicating if the virtual joystick was pressed
  37770. */
  37771. pressed: boolean;
  37772. /**
  37773. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37774. */
  37775. static Canvas: Nullable<HTMLCanvasElement>;
  37776. private static _globalJoystickIndex;
  37777. private static vjCanvasContext;
  37778. private static vjCanvasWidth;
  37779. private static vjCanvasHeight;
  37780. private static halfWidth;
  37781. private _action;
  37782. private _axisTargetedByLeftAndRight;
  37783. private _axisTargetedByUpAndDown;
  37784. private _joystickSensibility;
  37785. private _inversedSensibility;
  37786. private _joystickPointerID;
  37787. private _joystickColor;
  37788. private _joystickPointerPos;
  37789. private _joystickPreviousPointerPos;
  37790. private _joystickPointerStartPos;
  37791. private _deltaJoystickVector;
  37792. private _leftJoystick;
  37793. private _touches;
  37794. private _onPointerDownHandlerRef;
  37795. private _onPointerMoveHandlerRef;
  37796. private _onPointerUpHandlerRef;
  37797. private _onResize;
  37798. /**
  37799. * Creates a new virtual joystick
  37800. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37801. */
  37802. constructor(leftJoystick?: boolean);
  37803. /**
  37804. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37805. * @param newJoystickSensibility defines the new sensibility
  37806. */
  37807. setJoystickSensibility(newJoystickSensibility: number): void;
  37808. private _onPointerDown;
  37809. private _onPointerMove;
  37810. private _onPointerUp;
  37811. /**
  37812. * Change the color of the virtual joystick
  37813. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37814. */
  37815. setJoystickColor(newColor: string): void;
  37816. /**
  37817. * Defines a callback to call when the joystick is touched
  37818. * @param action defines the callback
  37819. */
  37820. setActionOnTouch(action: () => any): void;
  37821. /**
  37822. * Defines which axis you'd like to control for left & right
  37823. * @param axis defines the axis to use
  37824. */
  37825. setAxisForLeftRight(axis: JoystickAxis): void;
  37826. /**
  37827. * Defines which axis you'd like to control for up & down
  37828. * @param axis defines the axis to use
  37829. */
  37830. setAxisForUpDown(axis: JoystickAxis): void;
  37831. private _drawVirtualJoystick;
  37832. /**
  37833. * Release internal HTML canvas
  37834. */
  37835. releaseCanvas(): void;
  37836. }
  37837. }
  37838. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37839. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37840. import { Nullable } from "babylonjs/types";
  37841. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37843. module "babylonjs/Cameras/freeCameraInputsManager" {
  37844. interface FreeCameraInputsManager {
  37845. /**
  37846. * Add virtual joystick input support to the input manager.
  37847. * @returns the current input manager
  37848. */
  37849. addVirtualJoystick(): FreeCameraInputsManager;
  37850. }
  37851. }
  37852. /**
  37853. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37855. */
  37856. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37857. /**
  37858. * Defines the camera the input is attached to.
  37859. */
  37860. camera: FreeCamera;
  37861. private _leftjoystick;
  37862. private _rightjoystick;
  37863. /**
  37864. * Gets the left stick of the virtual joystick.
  37865. * @returns The virtual Joystick
  37866. */
  37867. getLeftJoystick(): VirtualJoystick;
  37868. /**
  37869. * Gets the right stick of the virtual joystick.
  37870. * @returns The virtual Joystick
  37871. */
  37872. getRightJoystick(): VirtualJoystick;
  37873. /**
  37874. * Update the current camera state depending on the inputs that have been used this frame.
  37875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37876. */
  37877. checkInputs(): void;
  37878. /**
  37879. * Attach the input controls to a specific dom element to get the input from.
  37880. * @param element Defines the element the controls should be listened from
  37881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37882. */
  37883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37884. /**
  37885. * Detach the current controls from the specified dom element.
  37886. * @param element Defines the element to stop listening the inputs from
  37887. */
  37888. detachControl(element: Nullable<HTMLElement>): void;
  37889. /**
  37890. * Gets the class name of the current intput.
  37891. * @returns the class name
  37892. */
  37893. getClassName(): string;
  37894. /**
  37895. * Get the friendly name associated with the input class.
  37896. * @returns the input friendly name
  37897. */
  37898. getSimpleName(): string;
  37899. }
  37900. }
  37901. declare module "babylonjs/Cameras/Inputs/index" {
  37902. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37903. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37904. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37905. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37906. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37907. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37908. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37909. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37910. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37911. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37912. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37913. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37914. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37915. }
  37916. declare module "babylonjs/Cameras/touchCamera" {
  37917. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37918. import { Scene } from "babylonjs/scene";
  37919. import { Vector3 } from "babylonjs/Maths/math";
  37920. /**
  37921. * This represents a FPS type of camera controlled by touch.
  37922. * This is like a universal camera minus the Gamepad controls.
  37923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37924. */
  37925. export class TouchCamera extends FreeCamera {
  37926. /**
  37927. * Defines the touch sensibility for rotation.
  37928. * The higher the faster.
  37929. */
  37930. touchAngularSensibility: number;
  37931. /**
  37932. * Defines the touch sensibility for move.
  37933. * The higher the faster.
  37934. */
  37935. touchMoveSensibility: number;
  37936. /**
  37937. * Instantiates a new touch camera.
  37938. * This represents a FPS type of camera controlled by touch.
  37939. * This is like a universal camera minus the Gamepad controls.
  37940. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37941. * @param name Define the name of the camera in the scene
  37942. * @param position Define the start position of the camera in the scene
  37943. * @param scene Define the scene the camera belongs to
  37944. */
  37945. constructor(name: string, position: Vector3, scene: Scene);
  37946. /**
  37947. * Gets the current object class name.
  37948. * @return the class name
  37949. */
  37950. getClassName(): string;
  37951. /** @hidden */
  37952. _setupInputs(): void;
  37953. }
  37954. }
  37955. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37957. import { Scene } from "babylonjs/scene";
  37958. import { Vector3, Axis } from "babylonjs/Maths/math";
  37959. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37960. /**
  37961. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37962. * being tilted forward or back and left or right.
  37963. */
  37964. export class DeviceOrientationCamera extends FreeCamera {
  37965. private _initialQuaternion;
  37966. private _quaternionCache;
  37967. /**
  37968. * Creates a new device orientation camera
  37969. * @param name The name of the camera
  37970. * @param position The start position camera
  37971. * @param scene The scene the camera belongs to
  37972. */
  37973. constructor(name: string, position: Vector3, scene: Scene);
  37974. /**
  37975. * Gets the current instance class name ("DeviceOrientationCamera").
  37976. * This helps avoiding instanceof at run time.
  37977. * @returns the class name
  37978. */
  37979. getClassName(): string;
  37980. /**
  37981. * @hidden
  37982. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37983. */
  37984. _checkInputs(): void;
  37985. /**
  37986. * Reset the camera to its default orientation on the specified axis only.
  37987. * @param axis The axis to reset
  37988. */
  37989. resetToCurrentRotation(axis?: Axis): void;
  37990. }
  37991. }
  37992. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37994. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37995. import { Nullable } from "babylonjs/types";
  37996. /**
  37997. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37999. */
  38000. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38001. /**
  38002. * Defines the camera the input is attached to.
  38003. */
  38004. camera: FollowCamera;
  38005. /**
  38006. * Defines the list of key codes associated with the up action (increase heightOffset)
  38007. */
  38008. keysUp: number[];
  38009. /**
  38010. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38011. */
  38012. keysDown: number[];
  38013. /**
  38014. * Defines the list of key codes associated with the left action (increase rotation)
  38015. */
  38016. keysLeft: number[];
  38017. /**
  38018. * Defines the list of key codes associated with the right action (decrease rotation)
  38019. */
  38020. keysRight: number[];
  38021. /**
  38022. * Defines the rate of change of heightOffset.
  38023. */
  38024. heightSensibility: number;
  38025. /**
  38026. * Defines the rate of change of rotationOffset.
  38027. */
  38028. rotationSensibility: number;
  38029. /**
  38030. * Defines the rate of change of radius.
  38031. */
  38032. radiusSensibility: number;
  38033. /**
  38034. * Defines the minimum heightOffset value.
  38035. */
  38036. minHeightOffset: number;
  38037. /**
  38038. * Defines the minimum radius value.
  38039. */
  38040. minRadius: number;
  38041. private _keys;
  38042. private _altPressed;
  38043. private _onCanvasBlurObserver;
  38044. private _onKeyboardObserver;
  38045. private _engine;
  38046. private _scene;
  38047. /**
  38048. * Attach the input controls to a specific dom element to get the input from.
  38049. * @param element Defines the element the controls should be listened from
  38050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38051. */
  38052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38053. /**
  38054. * Detach the current controls from the specified dom element.
  38055. * @param element Defines the element to stop listening the inputs from
  38056. */
  38057. detachControl(element: Nullable<HTMLElement>): void;
  38058. /**
  38059. * Update the current camera state depending on the inputs that have been used this frame.
  38060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38061. */
  38062. checkInputs(): void;
  38063. /**
  38064. * Gets the class name of the current intput.
  38065. * @returns the class name
  38066. */
  38067. getClassName(): string;
  38068. /**
  38069. * Get the friendly name associated with the input class.
  38070. * @returns the input friendly name
  38071. */
  38072. getSimpleName(): string;
  38073. }
  38074. }
  38075. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38076. import { Nullable } from "babylonjs/types";
  38077. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38079. /**
  38080. * Manage the mouse wheel inputs to control a follow camera.
  38081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38082. */
  38083. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38084. /**
  38085. * Defines the camera the input is attached to.
  38086. */
  38087. camera: FollowCamera;
  38088. /**
  38089. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  38090. */
  38091. axisControlRadius: boolean;
  38092. /**
  38093. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  38094. */
  38095. axisControlHeight: boolean;
  38096. /**
  38097. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  38098. */
  38099. axisControlRotation: boolean;
  38100. /**
  38101. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38102. * relation to mouseWheel events.
  38103. */
  38104. wheelPrecision: number;
  38105. /**
  38106. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38107. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38108. */
  38109. wheelDeltaPercentage: number;
  38110. private _wheel;
  38111. private _observer;
  38112. /**
  38113. * Attach the input controls to a specific dom element to get the input from.
  38114. * @param element Defines the element the controls should be listened from
  38115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38116. */
  38117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38118. /**
  38119. * Detach the current controls from the specified dom element.
  38120. * @param element Defines the element to stop listening the inputs from
  38121. */
  38122. detachControl(element: Nullable<HTMLElement>): void;
  38123. /**
  38124. * Gets the class name of the current intput.
  38125. * @returns the class name
  38126. */
  38127. getClassName(): string;
  38128. /**
  38129. * Get the friendly name associated with the input class.
  38130. * @returns the input friendly name
  38131. */
  38132. getSimpleName(): string;
  38133. }
  38134. }
  38135. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38136. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38137. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38138. /**
  38139. * Default Inputs manager for the FollowCamera.
  38140. * It groups all the default supported inputs for ease of use.
  38141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38142. */
  38143. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38144. /**
  38145. * Instantiates a new FollowCameraInputsManager.
  38146. * @param camera Defines the camera the inputs belong to
  38147. */
  38148. constructor(camera: FollowCamera);
  38149. /**
  38150. * Add keyboard input support to the input manager.
  38151. * @returns the current input manager
  38152. */
  38153. addKeyboard(): FollowCameraInputsManager;
  38154. /**
  38155. * Add mouse wheel input support to the input manager.
  38156. * @returns the current input manager
  38157. */
  38158. addMouseWheel(): FollowCameraInputsManager;
  38159. /**
  38160. * Add pointers input support to the input manager.
  38161. * @returns the current input manager
  38162. */
  38163. addPointers(): FollowCameraInputsManager;
  38164. /**
  38165. * Add orientation input support to the input manager.
  38166. * @returns the current input manager
  38167. */
  38168. addVRDeviceOrientation(): FollowCameraInputsManager;
  38169. }
  38170. }
  38171. declare module "babylonjs/Cameras/followCamera" {
  38172. import { Nullable } from "babylonjs/types";
  38173. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38174. import { Scene } from "babylonjs/scene";
  38175. import { Vector3 } from "babylonjs/Maths/math";
  38176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38177. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38178. /**
  38179. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38180. * an arc rotate version arcFollowCamera are available.
  38181. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38182. */
  38183. export class FollowCamera extends TargetCamera {
  38184. /**
  38185. * Distance the follow camera should follow an object at
  38186. */
  38187. radius: number;
  38188. /**
  38189. * Define a rotation offset between the camera and the object it follows
  38190. */
  38191. rotationOffset: number;
  38192. /**
  38193. * Define a height offset between the camera and the object it follows.
  38194. * It can help following an object from the top (like a car chaing a plane)
  38195. */
  38196. heightOffset: number;
  38197. /**
  38198. * Define how fast the camera can accelerate to follow it s target.
  38199. */
  38200. cameraAcceleration: number;
  38201. /**
  38202. * Define the speed limit of the camera following an object.
  38203. */
  38204. maxCameraSpeed: number;
  38205. /**
  38206. * Define the target of the camera.
  38207. */
  38208. lockedTarget: Nullable<AbstractMesh>;
  38209. /**
  38210. * Defines the input associated with the camera.
  38211. */
  38212. inputs: FollowCameraInputsManager;
  38213. /**
  38214. * Instantiates the follow camera.
  38215. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38216. * @param name Define the name of the camera in the scene
  38217. * @param position Define the position of the camera
  38218. * @param scene Define the scene the camera belong to
  38219. * @param lockedTarget Define the target of the camera
  38220. */
  38221. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38222. private _follow;
  38223. /**
  38224. * Attached controls to the current camera.
  38225. * @param element Defines the element the controls should be listened from
  38226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38227. */
  38228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38229. /**
  38230. * Detach the current controls from the camera.
  38231. * The camera will stop reacting to inputs.
  38232. * @param element Defines the element to stop listening the inputs from
  38233. */
  38234. detachControl(element: HTMLElement): void;
  38235. /** @hidden */
  38236. _checkInputs(): void;
  38237. /**
  38238. * Gets the camera class name.
  38239. * @returns the class name
  38240. */
  38241. getClassName(): string;
  38242. }
  38243. /**
  38244. * Arc Rotate version of the follow camera.
  38245. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38246. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38247. */
  38248. export class ArcFollowCamera extends TargetCamera {
  38249. /** The longitudinal angle of the camera */
  38250. alpha: number;
  38251. /** The latitudinal angle of the camera */
  38252. beta: number;
  38253. /** The radius of the camera from its target */
  38254. radius: number;
  38255. /** Define the camera target (the messh it should follow) */
  38256. target: Nullable<AbstractMesh>;
  38257. private _cartesianCoordinates;
  38258. /**
  38259. * Instantiates a new ArcFollowCamera
  38260. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38261. * @param name Define the name of the camera
  38262. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38263. * @param beta Define the rotation angle of the camera around the elevation axis
  38264. * @param radius Define the radius of the camera from its target point
  38265. * @param target Define the target of the camera
  38266. * @param scene Define the scene the camera belongs to
  38267. */
  38268. constructor(name: string,
  38269. /** The longitudinal angle of the camera */
  38270. alpha: number,
  38271. /** The latitudinal angle of the camera */
  38272. beta: number,
  38273. /** The radius of the camera from its target */
  38274. radius: number,
  38275. /** Define the camera target (the messh it should follow) */
  38276. target: Nullable<AbstractMesh>, scene: Scene);
  38277. private _follow;
  38278. /** @hidden */
  38279. _checkInputs(): void;
  38280. /**
  38281. * Returns the class name of the object.
  38282. * It is mostly used internally for serialization purposes.
  38283. */
  38284. getClassName(): string;
  38285. }
  38286. }
  38287. declare module "babylonjs/Cameras/universalCamera" {
  38288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38289. import { Scene } from "babylonjs/scene";
  38290. import { Vector3 } from "babylonjs/Maths/math";
  38291. /**
  38292. * 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,
  38293. * which still works and will still be found in many Playgrounds.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. */
  38296. export class UniversalCamera extends TouchCamera {
  38297. /**
  38298. * Defines the gamepad rotation sensiblity.
  38299. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38300. */
  38301. gamepadAngularSensibility: number;
  38302. /**
  38303. * Defines the gamepad move sensiblity.
  38304. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38305. */
  38306. gamepadMoveSensibility: number;
  38307. /**
  38308. * 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,
  38309. * which still works and will still be found in many Playgrounds.
  38310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38311. * @param name Define the name of the camera in the scene
  38312. * @param position Define the start position of the camera in the scene
  38313. * @param scene Define the scene the camera belongs to
  38314. */
  38315. constructor(name: string, position: Vector3, scene: Scene);
  38316. /**
  38317. * Gets the current object class name.
  38318. * @return the class name
  38319. */
  38320. getClassName(): string;
  38321. }
  38322. }
  38323. declare module "babylonjs/Cameras/gamepadCamera" {
  38324. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38325. import { Scene } from "babylonjs/scene";
  38326. import { Vector3 } from "babylonjs/Maths/math";
  38327. /**
  38328. * This represents a FPS type of camera. This is only here for back compat purpose.
  38329. * Please use the UniversalCamera instead as both are identical.
  38330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38331. */
  38332. export class GamepadCamera extends UniversalCamera {
  38333. /**
  38334. * Instantiates a new Gamepad Camera
  38335. * This represents a FPS type of camera. This is only here for back compat purpose.
  38336. * Please use the UniversalCamera instead as both are identical.
  38337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38338. * @param name Define the name of the camera in the scene
  38339. * @param position Define the start position of the camera in the scene
  38340. * @param scene Define the scene the camera belongs to
  38341. */
  38342. constructor(name: string, position: Vector3, scene: Scene);
  38343. /**
  38344. * Gets the current object class name.
  38345. * @return the class name
  38346. */
  38347. getClassName(): string;
  38348. }
  38349. }
  38350. declare module "babylonjs/Shaders/pass.fragment" {
  38351. /** @hidden */
  38352. export var passPixelShader: {
  38353. name: string;
  38354. shader: string;
  38355. };
  38356. }
  38357. declare module "babylonjs/Shaders/passCube.fragment" {
  38358. /** @hidden */
  38359. export var passCubePixelShader: {
  38360. name: string;
  38361. shader: string;
  38362. };
  38363. }
  38364. declare module "babylonjs/PostProcesses/passPostProcess" {
  38365. import { Nullable } from "babylonjs/types";
  38366. import { Camera } from "babylonjs/Cameras/camera";
  38367. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38368. import { Engine } from "babylonjs/Engines/engine";
  38369. import "babylonjs/Shaders/pass.fragment";
  38370. import "babylonjs/Shaders/passCube.fragment";
  38371. /**
  38372. * PassPostProcess which produces an output the same as it's input
  38373. */
  38374. export class PassPostProcess extends PostProcess {
  38375. /**
  38376. * Creates the PassPostProcess
  38377. * @param name The name of the effect.
  38378. * @param options The required width/height ratio to downsize to before computing the render pass.
  38379. * @param camera The camera to apply the render pass to.
  38380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38381. * @param engine The engine which the post process will be applied. (default: current engine)
  38382. * @param reusable If the post process can be reused on the same frame. (default: false)
  38383. * @param textureType The type of texture to be used when performing the post processing.
  38384. * @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)
  38385. */
  38386. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38387. }
  38388. /**
  38389. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38390. */
  38391. export class PassCubePostProcess extends PostProcess {
  38392. private _face;
  38393. /**
  38394. * Gets or sets the cube face to display.
  38395. * * 0 is +X
  38396. * * 1 is -X
  38397. * * 2 is +Y
  38398. * * 3 is -Y
  38399. * * 4 is +Z
  38400. * * 5 is -Z
  38401. */
  38402. face: number;
  38403. /**
  38404. * Creates the PassCubePostProcess
  38405. * @param name The name of the effect.
  38406. * @param options The required width/height ratio to downsize to before computing the render pass.
  38407. * @param camera The camera to apply the render pass to.
  38408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38409. * @param engine The engine which the post process will be applied. (default: current engine)
  38410. * @param reusable If the post process can be reused on the same frame. (default: false)
  38411. * @param textureType The type of texture to be used when performing the post processing.
  38412. * @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)
  38413. */
  38414. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38415. }
  38416. }
  38417. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38418. /** @hidden */
  38419. export var anaglyphPixelShader: {
  38420. name: string;
  38421. shader: string;
  38422. };
  38423. }
  38424. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38425. import { Engine } from "babylonjs/Engines/engine";
  38426. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38427. import { Camera } from "babylonjs/Cameras/camera";
  38428. import "babylonjs/Shaders/anaglyph.fragment";
  38429. /**
  38430. * Postprocess used to generate anaglyphic rendering
  38431. */
  38432. export class AnaglyphPostProcess extends PostProcess {
  38433. private _passedProcess;
  38434. /**
  38435. * Creates a new AnaglyphPostProcess
  38436. * @param name defines postprocess name
  38437. * @param options defines creation options or target ratio scale
  38438. * @param rigCameras defines cameras using this postprocess
  38439. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38440. * @param engine defines hosting engine
  38441. * @param reusable defines if the postprocess will be reused multiple times per frame
  38442. */
  38443. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38444. }
  38445. }
  38446. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38447. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38448. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38449. import { Scene } from "babylonjs/scene";
  38450. import { Vector3 } from "babylonjs/Maths/math";
  38451. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38452. /**
  38453. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38454. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38455. */
  38456. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38457. /**
  38458. * Creates a new AnaglyphArcRotateCamera
  38459. * @param name defines camera name
  38460. * @param alpha defines alpha angle (in radians)
  38461. * @param beta defines beta angle (in radians)
  38462. * @param radius defines radius
  38463. * @param target defines camera target
  38464. * @param interaxialDistance defines distance between each color axis
  38465. * @param scene defines the hosting scene
  38466. */
  38467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38468. /**
  38469. * Gets camera class name
  38470. * @returns AnaglyphArcRotateCamera
  38471. */
  38472. getClassName(): string;
  38473. }
  38474. }
  38475. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38476. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38477. import { Scene } from "babylonjs/scene";
  38478. import { Vector3 } from "babylonjs/Maths/math";
  38479. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38480. /**
  38481. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38482. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38483. */
  38484. export class AnaglyphFreeCamera extends FreeCamera {
  38485. /**
  38486. * Creates a new AnaglyphFreeCamera
  38487. * @param name defines camera name
  38488. * @param position defines initial position
  38489. * @param interaxialDistance defines distance between each color axis
  38490. * @param scene defines the hosting scene
  38491. */
  38492. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38493. /**
  38494. * Gets camera class name
  38495. * @returns AnaglyphFreeCamera
  38496. */
  38497. getClassName(): string;
  38498. }
  38499. }
  38500. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38501. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38502. import { Scene } from "babylonjs/scene";
  38503. import { Vector3 } from "babylonjs/Maths/math";
  38504. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38505. /**
  38506. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38507. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38508. */
  38509. export class AnaglyphGamepadCamera extends GamepadCamera {
  38510. /**
  38511. * Creates a new AnaglyphGamepadCamera
  38512. * @param name defines camera name
  38513. * @param position defines initial position
  38514. * @param interaxialDistance defines distance between each color axis
  38515. * @param scene defines the hosting scene
  38516. */
  38517. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38518. /**
  38519. * Gets camera class name
  38520. * @returns AnaglyphGamepadCamera
  38521. */
  38522. getClassName(): string;
  38523. }
  38524. }
  38525. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38526. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38527. import { Scene } from "babylonjs/scene";
  38528. import { Vector3 } from "babylonjs/Maths/math";
  38529. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38530. /**
  38531. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38532. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38533. */
  38534. export class AnaglyphUniversalCamera extends UniversalCamera {
  38535. /**
  38536. * Creates a new AnaglyphUniversalCamera
  38537. * @param name defines camera name
  38538. * @param position defines initial position
  38539. * @param interaxialDistance defines distance between each color axis
  38540. * @param scene defines the hosting scene
  38541. */
  38542. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38543. /**
  38544. * Gets camera class name
  38545. * @returns AnaglyphUniversalCamera
  38546. */
  38547. getClassName(): string;
  38548. }
  38549. }
  38550. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38551. /** @hidden */
  38552. export var stereoscopicInterlacePixelShader: {
  38553. name: string;
  38554. shader: string;
  38555. };
  38556. }
  38557. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38558. import { Camera } from "babylonjs/Cameras/camera";
  38559. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38560. import { Engine } from "babylonjs/Engines/engine";
  38561. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38562. /**
  38563. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38564. */
  38565. export class StereoscopicInterlacePostProcess extends PostProcess {
  38566. private _stepSize;
  38567. private _passedProcess;
  38568. /**
  38569. * Initializes a StereoscopicInterlacePostProcess
  38570. * @param name The name of the effect.
  38571. * @param rigCameras The rig cameras to be appled to the post process
  38572. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38574. * @param engine The engine which the post process will be applied. (default: current engine)
  38575. * @param reusable If the post process can be reused on the same frame. (default: false)
  38576. */
  38577. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38578. }
  38579. }
  38580. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38581. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38582. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38583. import { Scene } from "babylonjs/scene";
  38584. import { Vector3 } from "babylonjs/Maths/math";
  38585. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38586. /**
  38587. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38588. * @see http://doc.babylonjs.com/features/cameras
  38589. */
  38590. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38591. /**
  38592. * Creates a new StereoscopicArcRotateCamera
  38593. * @param name defines camera name
  38594. * @param alpha defines alpha angle (in radians)
  38595. * @param beta defines beta angle (in radians)
  38596. * @param radius defines radius
  38597. * @param target defines camera target
  38598. * @param interaxialDistance defines distance between each color axis
  38599. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38600. * @param scene defines the hosting scene
  38601. */
  38602. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38603. /**
  38604. * Gets camera class name
  38605. * @returns StereoscopicArcRotateCamera
  38606. */
  38607. getClassName(): string;
  38608. }
  38609. }
  38610. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38612. import { Scene } from "babylonjs/scene";
  38613. import { Vector3 } from "babylonjs/Maths/math";
  38614. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38615. /**
  38616. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38617. * @see http://doc.babylonjs.com/features/cameras
  38618. */
  38619. export class StereoscopicFreeCamera extends FreeCamera {
  38620. /**
  38621. * Creates a new StereoscopicFreeCamera
  38622. * @param name defines camera name
  38623. * @param position defines initial position
  38624. * @param interaxialDistance defines distance between each color axis
  38625. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38626. * @param scene defines the hosting scene
  38627. */
  38628. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38629. /**
  38630. * Gets camera class name
  38631. * @returns StereoscopicFreeCamera
  38632. */
  38633. getClassName(): string;
  38634. }
  38635. }
  38636. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38637. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38638. import { Scene } from "babylonjs/scene";
  38639. import { Vector3 } from "babylonjs/Maths/math";
  38640. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38641. /**
  38642. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38643. * @see http://doc.babylonjs.com/features/cameras
  38644. */
  38645. export class StereoscopicGamepadCamera extends GamepadCamera {
  38646. /**
  38647. * Creates a new StereoscopicGamepadCamera
  38648. * @param name defines camera name
  38649. * @param position defines initial position
  38650. * @param interaxialDistance defines distance between each color axis
  38651. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38652. * @param scene defines the hosting scene
  38653. */
  38654. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38655. /**
  38656. * Gets camera class name
  38657. * @returns StereoscopicGamepadCamera
  38658. */
  38659. getClassName(): string;
  38660. }
  38661. }
  38662. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38663. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38664. import { Scene } from "babylonjs/scene";
  38665. import { Vector3 } from "babylonjs/Maths/math";
  38666. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38667. /**
  38668. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38669. * @see http://doc.babylonjs.com/features/cameras
  38670. */
  38671. export class StereoscopicUniversalCamera extends UniversalCamera {
  38672. /**
  38673. * Creates a new StereoscopicUniversalCamera
  38674. * @param name defines camera name
  38675. * @param position defines initial position
  38676. * @param interaxialDistance defines distance between each color axis
  38677. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38678. * @param scene defines the hosting scene
  38679. */
  38680. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38681. /**
  38682. * Gets camera class name
  38683. * @returns StereoscopicUniversalCamera
  38684. */
  38685. getClassName(): string;
  38686. }
  38687. }
  38688. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38689. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38693. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38697. }
  38698. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38700. import { Scene } from "babylonjs/scene";
  38701. import { Vector3 } from "babylonjs/Maths/math";
  38702. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38703. /**
  38704. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38705. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38706. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38707. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38708. */
  38709. export class VirtualJoysticksCamera extends FreeCamera {
  38710. /**
  38711. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38712. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38713. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38714. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38715. * @param name Define the name of the camera in the scene
  38716. * @param position Define the start position of the camera in the scene
  38717. * @param scene Define the scene the camera belongs to
  38718. */
  38719. constructor(name: string, position: Vector3, scene: Scene);
  38720. /**
  38721. * Gets the current object class name.
  38722. * @return the class name
  38723. */
  38724. getClassName(): string;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38728. import { Matrix } from "babylonjs/Maths/math";
  38729. /**
  38730. * This represents all the required metrics to create a VR camera.
  38731. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38732. */
  38733. export class VRCameraMetrics {
  38734. /**
  38735. * Define the horizontal resolution off the screen.
  38736. */
  38737. hResolution: number;
  38738. /**
  38739. * Define the vertical resolution off the screen.
  38740. */
  38741. vResolution: number;
  38742. /**
  38743. * Define the horizontal screen size.
  38744. */
  38745. hScreenSize: number;
  38746. /**
  38747. * Define the vertical screen size.
  38748. */
  38749. vScreenSize: number;
  38750. /**
  38751. * Define the vertical screen center position.
  38752. */
  38753. vScreenCenter: number;
  38754. /**
  38755. * Define the distance of the eyes to the screen.
  38756. */
  38757. eyeToScreenDistance: number;
  38758. /**
  38759. * Define the distance between both lenses
  38760. */
  38761. lensSeparationDistance: number;
  38762. /**
  38763. * Define the distance between both viewer's eyes.
  38764. */
  38765. interpupillaryDistance: number;
  38766. /**
  38767. * Define the distortion factor of the VR postprocess.
  38768. * Please, touch with care.
  38769. */
  38770. distortionK: number[];
  38771. /**
  38772. * Define the chromatic aberration correction factors for the VR post process.
  38773. */
  38774. chromaAbCorrection: number[];
  38775. /**
  38776. * Define the scale factor of the post process.
  38777. * The smaller the better but the slower.
  38778. */
  38779. postProcessScaleFactor: number;
  38780. /**
  38781. * Define an offset for the lens center.
  38782. */
  38783. lensCenterOffset: number;
  38784. /**
  38785. * Define if the current vr camera should compensate the distortion of the lense or not.
  38786. */
  38787. compensateDistortion: boolean;
  38788. /**
  38789. * Gets the rendering aspect ratio based on the provided resolutions.
  38790. */
  38791. readonly aspectRatio: number;
  38792. /**
  38793. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38794. */
  38795. readonly aspectRatioFov: number;
  38796. /**
  38797. * @hidden
  38798. */
  38799. readonly leftHMatrix: Matrix;
  38800. /**
  38801. * @hidden
  38802. */
  38803. readonly rightHMatrix: Matrix;
  38804. /**
  38805. * @hidden
  38806. */
  38807. readonly leftPreViewMatrix: Matrix;
  38808. /**
  38809. * @hidden
  38810. */
  38811. readonly rightPreViewMatrix: Matrix;
  38812. /**
  38813. * Get the default VRMetrics based on the most generic setup.
  38814. * @returns the default vr metrics
  38815. */
  38816. static GetDefault(): VRCameraMetrics;
  38817. }
  38818. }
  38819. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38820. /** @hidden */
  38821. export var vrDistortionCorrectionPixelShader: {
  38822. name: string;
  38823. shader: string;
  38824. };
  38825. }
  38826. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38827. import { Camera } from "babylonjs/Cameras/camera";
  38828. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38829. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38830. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38831. /**
  38832. * VRDistortionCorrectionPostProcess used for mobile VR
  38833. */
  38834. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38835. private _isRightEye;
  38836. private _distortionFactors;
  38837. private _postProcessScaleFactor;
  38838. private _lensCenterOffset;
  38839. private _scaleIn;
  38840. private _scaleFactor;
  38841. private _lensCenter;
  38842. /**
  38843. * Initializes the VRDistortionCorrectionPostProcess
  38844. * @param name The name of the effect.
  38845. * @param camera The camera to apply the render pass to.
  38846. * @param isRightEye If this is for the right eye distortion
  38847. * @param vrMetrics All the required metrics for the VR camera
  38848. */
  38849. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38850. }
  38851. }
  38852. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38853. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38854. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38855. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38856. import { Scene } from "babylonjs/scene";
  38857. import { Vector3 } from "babylonjs/Maths/math";
  38858. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38859. import "babylonjs/Cameras/RigModes/vrRigMode";
  38860. /**
  38861. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38862. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38863. */
  38864. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38865. /**
  38866. * Creates a new VRDeviceOrientationArcRotateCamera
  38867. * @param name defines camera name
  38868. * @param alpha defines the camera rotation along the logitudinal axis
  38869. * @param beta defines the camera rotation along the latitudinal axis
  38870. * @param radius defines the camera distance from its target
  38871. * @param target defines the camera target
  38872. * @param scene defines the scene the camera belongs to
  38873. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38874. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38875. */
  38876. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38877. /**
  38878. * Gets camera class name
  38879. * @returns VRDeviceOrientationArcRotateCamera
  38880. */
  38881. getClassName(): string;
  38882. }
  38883. }
  38884. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38885. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38886. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38887. import { Scene } from "babylonjs/scene";
  38888. import { Vector3 } from "babylonjs/Maths/math";
  38889. import "babylonjs/Cameras/RigModes/vrRigMode";
  38890. /**
  38891. * Camera used to simulate VR rendering (based on FreeCamera)
  38892. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38893. */
  38894. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38895. /**
  38896. * Creates a new VRDeviceOrientationFreeCamera
  38897. * @param name defines camera name
  38898. * @param position defines the start position of the camera
  38899. * @param scene defines the scene the camera belongs to
  38900. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38901. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38902. */
  38903. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38904. /**
  38905. * Gets camera class name
  38906. * @returns VRDeviceOrientationFreeCamera
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38912. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38913. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38914. import { Scene } from "babylonjs/scene";
  38915. import { Vector3 } from "babylonjs/Maths/math";
  38916. /**
  38917. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38918. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38919. */
  38920. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38921. /**
  38922. * Creates a new VRDeviceOrientationGamepadCamera
  38923. * @param name defines camera name
  38924. * @param position defines the start position of the camera
  38925. * @param scene defines the scene the camera belongs to
  38926. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38927. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38928. */
  38929. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38930. /**
  38931. * Gets camera class name
  38932. * @returns VRDeviceOrientationGamepadCamera
  38933. */
  38934. getClassName(): string;
  38935. }
  38936. }
  38937. declare module "babylonjs/Gamepads/xboxGamepad" {
  38938. import { Observable } from "babylonjs/Misc/observable";
  38939. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38940. /**
  38941. * Defines supported buttons for XBox360 compatible gamepads
  38942. */
  38943. export enum Xbox360Button {
  38944. /** A */
  38945. A = 0,
  38946. /** B */
  38947. B = 1,
  38948. /** X */
  38949. X = 2,
  38950. /** Y */
  38951. Y = 3,
  38952. /** Start */
  38953. Start = 4,
  38954. /** Back */
  38955. Back = 5,
  38956. /** Left button */
  38957. LB = 6,
  38958. /** Right button */
  38959. RB = 7,
  38960. /** Left stick */
  38961. LeftStick = 8,
  38962. /** Right stick */
  38963. RightStick = 9
  38964. }
  38965. /** Defines values for XBox360 DPad */
  38966. export enum Xbox360Dpad {
  38967. /** Up */
  38968. Up = 0,
  38969. /** Down */
  38970. Down = 1,
  38971. /** Left */
  38972. Left = 2,
  38973. /** Right */
  38974. Right = 3
  38975. }
  38976. /**
  38977. * Defines a XBox360 gamepad
  38978. */
  38979. export class Xbox360Pad extends Gamepad {
  38980. private _leftTrigger;
  38981. private _rightTrigger;
  38982. private _onlefttriggerchanged;
  38983. private _onrighttriggerchanged;
  38984. private _onbuttondown;
  38985. private _onbuttonup;
  38986. private _ondpaddown;
  38987. private _ondpadup;
  38988. /** Observable raised when a button is pressed */
  38989. onButtonDownObservable: Observable<Xbox360Button>;
  38990. /** Observable raised when a button is released */
  38991. onButtonUpObservable: Observable<Xbox360Button>;
  38992. /** Observable raised when a pad is pressed */
  38993. onPadDownObservable: Observable<Xbox360Dpad>;
  38994. /** Observable raised when a pad is released */
  38995. onPadUpObservable: Observable<Xbox360Dpad>;
  38996. private _buttonA;
  38997. private _buttonB;
  38998. private _buttonX;
  38999. private _buttonY;
  39000. private _buttonBack;
  39001. private _buttonStart;
  39002. private _buttonLB;
  39003. private _buttonRB;
  39004. private _buttonLeftStick;
  39005. private _buttonRightStick;
  39006. private _dPadUp;
  39007. private _dPadDown;
  39008. private _dPadLeft;
  39009. private _dPadRight;
  39010. private _isXboxOnePad;
  39011. /**
  39012. * Creates a new XBox360 gamepad object
  39013. * @param id defines the id of this gamepad
  39014. * @param index defines its index
  39015. * @param gamepad defines the internal HTML gamepad object
  39016. * @param xboxOne defines if it is a XBox One gamepad
  39017. */
  39018. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39019. /**
  39020. * Defines the callback to call when left trigger is pressed
  39021. * @param callback defines the callback to use
  39022. */
  39023. onlefttriggerchanged(callback: (value: number) => void): void;
  39024. /**
  39025. * Defines the callback to call when right trigger is pressed
  39026. * @param callback defines the callback to use
  39027. */
  39028. onrighttriggerchanged(callback: (value: number) => void): void;
  39029. /**
  39030. * Gets the left trigger value
  39031. */
  39032. /**
  39033. * Sets the left trigger value
  39034. */
  39035. leftTrigger: number;
  39036. /**
  39037. * Gets the right trigger value
  39038. */
  39039. /**
  39040. * Sets the right trigger value
  39041. */
  39042. rightTrigger: number;
  39043. /**
  39044. * Defines the callback to call when a button is pressed
  39045. * @param callback defines the callback to use
  39046. */
  39047. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39048. /**
  39049. * Defines the callback to call when a button is released
  39050. * @param callback defines the callback to use
  39051. */
  39052. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39053. /**
  39054. * Defines the callback to call when a pad is pressed
  39055. * @param callback defines the callback to use
  39056. */
  39057. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39058. /**
  39059. * Defines the callback to call when a pad is released
  39060. * @param callback defines the callback to use
  39061. */
  39062. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39063. private _setButtonValue;
  39064. private _setDPadValue;
  39065. /**
  39066. * Gets the value of the `A` button
  39067. */
  39068. /**
  39069. * Sets the value of the `A` button
  39070. */
  39071. buttonA: number;
  39072. /**
  39073. * Gets the value of the `B` button
  39074. */
  39075. /**
  39076. * Sets the value of the `B` button
  39077. */
  39078. buttonB: number;
  39079. /**
  39080. * Gets the value of the `X` button
  39081. */
  39082. /**
  39083. * Sets the value of the `X` button
  39084. */
  39085. buttonX: number;
  39086. /**
  39087. * Gets the value of the `Y` button
  39088. */
  39089. /**
  39090. * Sets the value of the `Y` button
  39091. */
  39092. buttonY: number;
  39093. /**
  39094. * Gets the value of the `Start` button
  39095. */
  39096. /**
  39097. * Sets the value of the `Start` button
  39098. */
  39099. buttonStart: number;
  39100. /**
  39101. * Gets the value of the `Back` button
  39102. */
  39103. /**
  39104. * Sets the value of the `Back` button
  39105. */
  39106. buttonBack: number;
  39107. /**
  39108. * Gets the value of the `Left` button
  39109. */
  39110. /**
  39111. * Sets the value of the `Left` button
  39112. */
  39113. buttonLB: number;
  39114. /**
  39115. * Gets the value of the `Right` button
  39116. */
  39117. /**
  39118. * Sets the value of the `Right` button
  39119. */
  39120. buttonRB: number;
  39121. /**
  39122. * Gets the value of the Left joystick
  39123. */
  39124. /**
  39125. * Sets the value of the Left joystick
  39126. */
  39127. buttonLeftStick: number;
  39128. /**
  39129. * Gets the value of the Right joystick
  39130. */
  39131. /**
  39132. * Sets the value of the Right joystick
  39133. */
  39134. buttonRightStick: number;
  39135. /**
  39136. * Gets the value of D-pad up
  39137. */
  39138. /**
  39139. * Sets the value of D-pad up
  39140. */
  39141. dPadUp: number;
  39142. /**
  39143. * Gets the value of D-pad down
  39144. */
  39145. /**
  39146. * Sets the value of D-pad down
  39147. */
  39148. dPadDown: number;
  39149. /**
  39150. * Gets the value of D-pad left
  39151. */
  39152. /**
  39153. * Sets the value of D-pad left
  39154. */
  39155. dPadLeft: number;
  39156. /**
  39157. * Gets the value of D-pad right
  39158. */
  39159. /**
  39160. * Sets the value of D-pad right
  39161. */
  39162. dPadRight: number;
  39163. /**
  39164. * Force the gamepad to synchronize with device values
  39165. */
  39166. update(): void;
  39167. /**
  39168. * Disposes the gamepad
  39169. */
  39170. dispose(): void;
  39171. }
  39172. }
  39173. declare module "babylonjs/Materials/pushMaterial" {
  39174. import { Nullable } from "babylonjs/types";
  39175. import { Scene } from "babylonjs/scene";
  39176. import { Matrix } from "babylonjs/Maths/math";
  39177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39178. import { Mesh } from "babylonjs/Meshes/mesh";
  39179. import { Material } from "babylonjs/Materials/material";
  39180. import { Effect } from "babylonjs/Materials/effect";
  39181. /**
  39182. * Base class of materials working in push mode in babylon JS
  39183. * @hidden
  39184. */
  39185. export class PushMaterial extends Material {
  39186. protected _activeEffect: Effect;
  39187. protected _normalMatrix: Matrix;
  39188. /**
  39189. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39190. * This means that the material can keep using a previous shader while a new one is being compiled.
  39191. * This is mostly used when shader parallel compilation is supported (true by default)
  39192. */
  39193. allowShaderHotSwapping: boolean;
  39194. constructor(name: string, scene: Scene);
  39195. getEffect(): Effect;
  39196. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39197. /**
  39198. * Binds the given world matrix to the active effect
  39199. *
  39200. * @param world the matrix to bind
  39201. */
  39202. bindOnlyWorldMatrix(world: Matrix): void;
  39203. /**
  39204. * Binds the given normal matrix to the active effect
  39205. *
  39206. * @param normalMatrix the matrix to bind
  39207. */
  39208. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39209. bind(world: Matrix, mesh?: Mesh): void;
  39210. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39211. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39212. }
  39213. }
  39214. declare module "babylonjs/Materials/materialFlags" {
  39215. /**
  39216. * This groups all the flags used to control the materials channel.
  39217. */
  39218. export class MaterialFlags {
  39219. private static _DiffuseTextureEnabled;
  39220. /**
  39221. * Are diffuse textures enabled in the application.
  39222. */
  39223. static DiffuseTextureEnabled: boolean;
  39224. private static _AmbientTextureEnabled;
  39225. /**
  39226. * Are ambient textures enabled in the application.
  39227. */
  39228. static AmbientTextureEnabled: boolean;
  39229. private static _OpacityTextureEnabled;
  39230. /**
  39231. * Are opacity textures enabled in the application.
  39232. */
  39233. static OpacityTextureEnabled: boolean;
  39234. private static _ReflectionTextureEnabled;
  39235. /**
  39236. * Are reflection textures enabled in the application.
  39237. */
  39238. static ReflectionTextureEnabled: boolean;
  39239. private static _EmissiveTextureEnabled;
  39240. /**
  39241. * Are emissive textures enabled in the application.
  39242. */
  39243. static EmissiveTextureEnabled: boolean;
  39244. private static _SpecularTextureEnabled;
  39245. /**
  39246. * Are specular textures enabled in the application.
  39247. */
  39248. static SpecularTextureEnabled: boolean;
  39249. private static _BumpTextureEnabled;
  39250. /**
  39251. * Are bump textures enabled in the application.
  39252. */
  39253. static BumpTextureEnabled: boolean;
  39254. private static _LightmapTextureEnabled;
  39255. /**
  39256. * Are lightmap textures enabled in the application.
  39257. */
  39258. static LightmapTextureEnabled: boolean;
  39259. private static _RefractionTextureEnabled;
  39260. /**
  39261. * Are refraction textures enabled in the application.
  39262. */
  39263. static RefractionTextureEnabled: boolean;
  39264. private static _ColorGradingTextureEnabled;
  39265. /**
  39266. * Are color grading textures enabled in the application.
  39267. */
  39268. static ColorGradingTextureEnabled: boolean;
  39269. private static _FresnelEnabled;
  39270. /**
  39271. * Are fresnels enabled in the application.
  39272. */
  39273. static FresnelEnabled: boolean;
  39274. }
  39275. }
  39276. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39277. /** @hidden */
  39278. export var defaultFragmentDeclaration: {
  39279. name: string;
  39280. shader: string;
  39281. };
  39282. }
  39283. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39284. /** @hidden */
  39285. export var defaultUboDeclaration: {
  39286. name: string;
  39287. shader: string;
  39288. };
  39289. }
  39290. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39291. /** @hidden */
  39292. export var lightFragmentDeclaration: {
  39293. name: string;
  39294. shader: string;
  39295. };
  39296. }
  39297. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39298. /** @hidden */
  39299. export var lightUboDeclaration: {
  39300. name: string;
  39301. shader: string;
  39302. };
  39303. }
  39304. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39305. /** @hidden */
  39306. export var lightsFragmentFunctions: {
  39307. name: string;
  39308. shader: string;
  39309. };
  39310. }
  39311. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39312. /** @hidden */
  39313. export var shadowsFragmentFunctions: {
  39314. name: string;
  39315. shader: string;
  39316. };
  39317. }
  39318. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39319. /** @hidden */
  39320. export var fresnelFunction: {
  39321. name: string;
  39322. shader: string;
  39323. };
  39324. }
  39325. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39326. /** @hidden */
  39327. export var reflectionFunction: {
  39328. name: string;
  39329. shader: string;
  39330. };
  39331. }
  39332. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39333. /** @hidden */
  39334. export var bumpFragmentFunctions: {
  39335. name: string;
  39336. shader: string;
  39337. };
  39338. }
  39339. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39340. /** @hidden */
  39341. export var logDepthDeclaration: {
  39342. name: string;
  39343. shader: string;
  39344. };
  39345. }
  39346. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39347. /** @hidden */
  39348. export var bumpFragment: {
  39349. name: string;
  39350. shader: string;
  39351. };
  39352. }
  39353. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39354. /** @hidden */
  39355. export var depthPrePass: {
  39356. name: string;
  39357. shader: string;
  39358. };
  39359. }
  39360. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39361. /** @hidden */
  39362. export var lightFragment: {
  39363. name: string;
  39364. shader: string;
  39365. };
  39366. }
  39367. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39368. /** @hidden */
  39369. export var logDepthFragment: {
  39370. name: string;
  39371. shader: string;
  39372. };
  39373. }
  39374. declare module "babylonjs/Shaders/default.fragment" {
  39375. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39376. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39378. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39379. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39380. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39381. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39382. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39383. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39384. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39385. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39386. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39387. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39388. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39389. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39390. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39391. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39392. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39393. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39394. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39395. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39396. /** @hidden */
  39397. export var defaultPixelShader: {
  39398. name: string;
  39399. shader: string;
  39400. };
  39401. }
  39402. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39403. /** @hidden */
  39404. export var defaultVertexDeclaration: {
  39405. name: string;
  39406. shader: string;
  39407. };
  39408. }
  39409. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39410. /** @hidden */
  39411. export var bumpVertexDeclaration: {
  39412. name: string;
  39413. shader: string;
  39414. };
  39415. }
  39416. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39417. /** @hidden */
  39418. export var bumpVertex: {
  39419. name: string;
  39420. shader: string;
  39421. };
  39422. }
  39423. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39424. /** @hidden */
  39425. export var fogVertex: {
  39426. name: string;
  39427. shader: string;
  39428. };
  39429. }
  39430. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39431. /** @hidden */
  39432. export var shadowsVertex: {
  39433. name: string;
  39434. shader: string;
  39435. };
  39436. }
  39437. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39438. /** @hidden */
  39439. export var pointCloudVertex: {
  39440. name: string;
  39441. shader: string;
  39442. };
  39443. }
  39444. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39445. /** @hidden */
  39446. export var logDepthVertex: {
  39447. name: string;
  39448. shader: string;
  39449. };
  39450. }
  39451. declare module "babylonjs/Shaders/default.vertex" {
  39452. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39453. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39457. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39459. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39460. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39464. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39468. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39469. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39470. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39471. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39472. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39473. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39474. /** @hidden */
  39475. export var defaultVertexShader: {
  39476. name: string;
  39477. shader: string;
  39478. };
  39479. }
  39480. declare module "babylonjs/Materials/standardMaterial" {
  39481. import { SmartArray } from "babylonjs/Misc/smartArray";
  39482. import { IAnimatable } from "babylonjs/Misc/tools";
  39483. import { Nullable } from "babylonjs/types";
  39484. import { Scene } from "babylonjs/scene";
  39485. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39486. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39488. import { Mesh } from "babylonjs/Meshes/mesh";
  39489. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39490. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39491. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39492. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39493. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39496. import "babylonjs/Shaders/default.fragment";
  39497. import "babylonjs/Shaders/default.vertex";
  39498. /** @hidden */
  39499. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39500. MAINUV1: boolean;
  39501. MAINUV2: boolean;
  39502. DIFFUSE: boolean;
  39503. DIFFUSEDIRECTUV: number;
  39504. AMBIENT: boolean;
  39505. AMBIENTDIRECTUV: number;
  39506. OPACITY: boolean;
  39507. OPACITYDIRECTUV: number;
  39508. OPACITYRGB: boolean;
  39509. REFLECTION: boolean;
  39510. EMISSIVE: boolean;
  39511. EMISSIVEDIRECTUV: number;
  39512. SPECULAR: boolean;
  39513. SPECULARDIRECTUV: number;
  39514. BUMP: boolean;
  39515. BUMPDIRECTUV: number;
  39516. PARALLAX: boolean;
  39517. PARALLAXOCCLUSION: boolean;
  39518. SPECULAROVERALPHA: boolean;
  39519. CLIPPLANE: boolean;
  39520. CLIPPLANE2: boolean;
  39521. CLIPPLANE3: boolean;
  39522. CLIPPLANE4: boolean;
  39523. ALPHATEST: boolean;
  39524. DEPTHPREPASS: boolean;
  39525. ALPHAFROMDIFFUSE: boolean;
  39526. POINTSIZE: boolean;
  39527. FOG: boolean;
  39528. SPECULARTERM: boolean;
  39529. DIFFUSEFRESNEL: boolean;
  39530. OPACITYFRESNEL: boolean;
  39531. REFLECTIONFRESNEL: boolean;
  39532. REFRACTIONFRESNEL: boolean;
  39533. EMISSIVEFRESNEL: boolean;
  39534. FRESNEL: boolean;
  39535. NORMAL: boolean;
  39536. UV1: boolean;
  39537. UV2: boolean;
  39538. VERTEXCOLOR: boolean;
  39539. VERTEXALPHA: boolean;
  39540. NUM_BONE_INFLUENCERS: number;
  39541. BonesPerMesh: number;
  39542. BONETEXTURE: boolean;
  39543. INSTANCES: boolean;
  39544. GLOSSINESS: boolean;
  39545. ROUGHNESS: boolean;
  39546. EMISSIVEASILLUMINATION: boolean;
  39547. LINKEMISSIVEWITHDIFFUSE: boolean;
  39548. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39549. LIGHTMAP: boolean;
  39550. LIGHTMAPDIRECTUV: number;
  39551. OBJECTSPACE_NORMALMAP: boolean;
  39552. USELIGHTMAPASSHADOWMAP: boolean;
  39553. REFLECTIONMAP_3D: boolean;
  39554. REFLECTIONMAP_SPHERICAL: boolean;
  39555. REFLECTIONMAP_PLANAR: boolean;
  39556. REFLECTIONMAP_CUBIC: boolean;
  39557. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39558. REFLECTIONMAP_PROJECTION: boolean;
  39559. REFLECTIONMAP_SKYBOX: boolean;
  39560. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39561. REFLECTIONMAP_EXPLICIT: boolean;
  39562. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39563. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39564. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39565. INVERTCUBICMAP: boolean;
  39566. LOGARITHMICDEPTH: boolean;
  39567. REFRACTION: boolean;
  39568. REFRACTIONMAP_3D: boolean;
  39569. REFLECTIONOVERALPHA: boolean;
  39570. TWOSIDEDLIGHTING: boolean;
  39571. SHADOWFLOAT: boolean;
  39572. MORPHTARGETS: boolean;
  39573. MORPHTARGETS_NORMAL: boolean;
  39574. MORPHTARGETS_TANGENT: boolean;
  39575. NUM_MORPH_INFLUENCERS: number;
  39576. NONUNIFORMSCALING: boolean;
  39577. PREMULTIPLYALPHA: boolean;
  39578. IMAGEPROCESSING: boolean;
  39579. VIGNETTE: boolean;
  39580. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39581. VIGNETTEBLENDMODEOPAQUE: boolean;
  39582. TONEMAPPING: boolean;
  39583. TONEMAPPING_ACES: boolean;
  39584. CONTRAST: boolean;
  39585. COLORCURVES: boolean;
  39586. COLORGRADING: boolean;
  39587. COLORGRADING3D: boolean;
  39588. SAMPLER3DGREENDEPTH: boolean;
  39589. SAMPLER3DBGRMAP: boolean;
  39590. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39591. /**
  39592. * If the reflection texture on this material is in linear color space
  39593. * @hidden
  39594. */
  39595. IS_REFLECTION_LINEAR: boolean;
  39596. /**
  39597. * If the refraction texture on this material is in linear color space
  39598. * @hidden
  39599. */
  39600. IS_REFRACTION_LINEAR: boolean;
  39601. EXPOSURE: boolean;
  39602. constructor();
  39603. setReflectionMode(modeToEnable: string): void;
  39604. }
  39605. /**
  39606. * This is the default material used in Babylon. It is the best trade off between quality
  39607. * and performances.
  39608. * @see http://doc.babylonjs.com/babylon101/materials
  39609. */
  39610. export class StandardMaterial extends PushMaterial {
  39611. private _diffuseTexture;
  39612. /**
  39613. * The basic texture of the material as viewed under a light.
  39614. */
  39615. diffuseTexture: Nullable<BaseTexture>;
  39616. private _ambientTexture;
  39617. /**
  39618. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39619. */
  39620. ambientTexture: Nullable<BaseTexture>;
  39621. private _opacityTexture;
  39622. /**
  39623. * Define the transparency of the material from a texture.
  39624. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39625. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39626. */
  39627. opacityTexture: Nullable<BaseTexture>;
  39628. private _reflectionTexture;
  39629. /**
  39630. * Define the texture used to display the reflection.
  39631. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39632. */
  39633. reflectionTexture: Nullable<BaseTexture>;
  39634. private _emissiveTexture;
  39635. /**
  39636. * Define texture of the material as if self lit.
  39637. * This will be mixed in the final result even in the absence of light.
  39638. */
  39639. emissiveTexture: Nullable<BaseTexture>;
  39640. private _specularTexture;
  39641. /**
  39642. * Define how the color and intensity of the highlight given by the light in the material.
  39643. */
  39644. specularTexture: Nullable<BaseTexture>;
  39645. private _bumpTexture;
  39646. /**
  39647. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39648. * 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.
  39649. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39650. */
  39651. bumpTexture: Nullable<BaseTexture>;
  39652. private _lightmapTexture;
  39653. /**
  39654. * Complex lighting can be computationally expensive to compute at runtime.
  39655. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39656. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39657. */
  39658. lightmapTexture: Nullable<BaseTexture>;
  39659. private _refractionTexture;
  39660. /**
  39661. * Define the texture used to display the refraction.
  39662. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39663. */
  39664. refractionTexture: Nullable<BaseTexture>;
  39665. /**
  39666. * The color of the material lit by the environmental background lighting.
  39667. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39668. */
  39669. ambientColor: Color3;
  39670. /**
  39671. * The basic color of the material as viewed under a light.
  39672. */
  39673. diffuseColor: Color3;
  39674. /**
  39675. * Define how the color and intensity of the highlight given by the light in the material.
  39676. */
  39677. specularColor: Color3;
  39678. /**
  39679. * Define the color of the material as if self lit.
  39680. * This will be mixed in the final result even in the absence of light.
  39681. */
  39682. emissiveColor: Color3;
  39683. /**
  39684. * Defines how sharp are the highlights in the material.
  39685. * The bigger the value the sharper giving a more glossy feeling to the result.
  39686. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39687. */
  39688. specularPower: number;
  39689. private _useAlphaFromDiffuseTexture;
  39690. /**
  39691. * Does the transparency come from the diffuse texture alpha channel.
  39692. */
  39693. useAlphaFromDiffuseTexture: boolean;
  39694. private _useEmissiveAsIllumination;
  39695. /**
  39696. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39697. */
  39698. useEmissiveAsIllumination: boolean;
  39699. private _linkEmissiveWithDiffuse;
  39700. /**
  39701. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39702. * the emissive level when the final color is close to one.
  39703. */
  39704. linkEmissiveWithDiffuse: boolean;
  39705. private _useSpecularOverAlpha;
  39706. /**
  39707. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39708. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39709. */
  39710. useSpecularOverAlpha: boolean;
  39711. private _useReflectionOverAlpha;
  39712. /**
  39713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39715. */
  39716. useReflectionOverAlpha: boolean;
  39717. private _disableLighting;
  39718. /**
  39719. * Does lights from the scene impacts this material.
  39720. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39721. */
  39722. disableLighting: boolean;
  39723. private _useObjectSpaceNormalMap;
  39724. /**
  39725. * Allows using an object space normal map (instead of tangent space).
  39726. */
  39727. useObjectSpaceNormalMap: boolean;
  39728. private _useParallax;
  39729. /**
  39730. * Is parallax enabled or not.
  39731. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39732. */
  39733. useParallax: boolean;
  39734. private _useParallaxOcclusion;
  39735. /**
  39736. * Is parallax occlusion enabled or not.
  39737. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39738. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39739. */
  39740. useParallaxOcclusion: boolean;
  39741. /**
  39742. * 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.
  39743. */
  39744. parallaxScaleBias: number;
  39745. private _roughness;
  39746. /**
  39747. * Helps to define how blurry the reflections should appears in the material.
  39748. */
  39749. roughness: number;
  39750. /**
  39751. * In case of refraction, define the value of the indice of refraction.
  39752. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39753. */
  39754. indexOfRefraction: number;
  39755. /**
  39756. * Invert the refraction texture alongside the y axis.
  39757. * It can be useful with procedural textures or probe for instance.
  39758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39759. */
  39760. invertRefractionY: boolean;
  39761. /**
  39762. * Defines the alpha limits in alpha test mode.
  39763. */
  39764. alphaCutOff: number;
  39765. private _useLightmapAsShadowmap;
  39766. /**
  39767. * In case of light mapping, define whether the map contains light or shadow informations.
  39768. */
  39769. useLightmapAsShadowmap: boolean;
  39770. private _diffuseFresnelParameters;
  39771. /**
  39772. * Define the diffuse fresnel parameters of the material.
  39773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39774. */
  39775. diffuseFresnelParameters: FresnelParameters;
  39776. private _opacityFresnelParameters;
  39777. /**
  39778. * Define the opacity fresnel parameters of the material.
  39779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39780. */
  39781. opacityFresnelParameters: FresnelParameters;
  39782. private _reflectionFresnelParameters;
  39783. /**
  39784. * Define the reflection fresnel parameters of the material.
  39785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39786. */
  39787. reflectionFresnelParameters: FresnelParameters;
  39788. private _refractionFresnelParameters;
  39789. /**
  39790. * Define the refraction fresnel parameters of the material.
  39791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39792. */
  39793. refractionFresnelParameters: FresnelParameters;
  39794. private _emissiveFresnelParameters;
  39795. /**
  39796. * Define the emissive fresnel parameters of the material.
  39797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39798. */
  39799. emissiveFresnelParameters: FresnelParameters;
  39800. private _useReflectionFresnelFromSpecular;
  39801. /**
  39802. * If true automatically deducts the fresnels values from the material specularity.
  39803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39804. */
  39805. useReflectionFresnelFromSpecular: boolean;
  39806. private _useGlossinessFromSpecularMapAlpha;
  39807. /**
  39808. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39809. */
  39810. useGlossinessFromSpecularMapAlpha: boolean;
  39811. private _maxSimultaneousLights;
  39812. /**
  39813. * Defines the maximum number of lights that can be used in the material
  39814. */
  39815. maxSimultaneousLights: number;
  39816. private _invertNormalMapX;
  39817. /**
  39818. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39819. */
  39820. invertNormalMapX: boolean;
  39821. private _invertNormalMapY;
  39822. /**
  39823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39824. */
  39825. invertNormalMapY: boolean;
  39826. private _twoSidedLighting;
  39827. /**
  39828. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39829. */
  39830. twoSidedLighting: boolean;
  39831. /**
  39832. * Default configuration related to image processing available in the standard Material.
  39833. */
  39834. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39835. /**
  39836. * Gets the image processing configuration used either in this material.
  39837. */
  39838. /**
  39839. * Sets the Default image processing configuration used either in the this material.
  39840. *
  39841. * If sets to null, the scene one is in use.
  39842. */
  39843. imageProcessingConfiguration: ImageProcessingConfiguration;
  39844. /**
  39845. * Keep track of the image processing observer to allow dispose and replace.
  39846. */
  39847. private _imageProcessingObserver;
  39848. /**
  39849. * Attaches a new image processing configuration to the Standard Material.
  39850. * @param configuration
  39851. */
  39852. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39853. /**
  39854. * Gets wether the color curves effect is enabled.
  39855. */
  39856. /**
  39857. * Sets wether the color curves effect is enabled.
  39858. */
  39859. cameraColorCurvesEnabled: boolean;
  39860. /**
  39861. * Gets wether the color grading effect is enabled.
  39862. */
  39863. /**
  39864. * Gets wether the color grading effect is enabled.
  39865. */
  39866. cameraColorGradingEnabled: boolean;
  39867. /**
  39868. * Gets wether tonemapping is enabled or not.
  39869. */
  39870. /**
  39871. * Sets wether tonemapping is enabled or not
  39872. */
  39873. cameraToneMappingEnabled: boolean;
  39874. /**
  39875. * The camera exposure used on this material.
  39876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39877. * This corresponds to a photographic exposure.
  39878. */
  39879. /**
  39880. * The camera exposure used on this material.
  39881. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39882. * This corresponds to a photographic exposure.
  39883. */
  39884. cameraExposure: number;
  39885. /**
  39886. * Gets The camera contrast used on this material.
  39887. */
  39888. /**
  39889. * Sets The camera contrast used on this material.
  39890. */
  39891. cameraContrast: number;
  39892. /**
  39893. * Gets the Color Grading 2D Lookup Texture.
  39894. */
  39895. /**
  39896. * Sets the Color Grading 2D Lookup Texture.
  39897. */
  39898. cameraColorGradingTexture: Nullable<BaseTexture>;
  39899. /**
  39900. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39901. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39902. * 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;
  39903. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39904. */
  39905. /**
  39906. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39907. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39908. * 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;
  39909. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39910. */
  39911. cameraColorCurves: Nullable<ColorCurves>;
  39912. /**
  39913. * Custom callback helping to override the default shader used in the material.
  39914. */
  39915. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39916. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39917. protected _worldViewProjectionMatrix: Matrix;
  39918. protected _globalAmbientColor: Color3;
  39919. protected _useLogarithmicDepth: boolean;
  39920. /**
  39921. * Instantiates a new standard material.
  39922. * This is the default material used in Babylon. It is the best trade off between quality
  39923. * and performances.
  39924. * @see http://doc.babylonjs.com/babylon101/materials
  39925. * @param name Define the name of the material in the scene
  39926. * @param scene Define the scene the material belong to
  39927. */
  39928. constructor(name: string, scene: Scene);
  39929. /**
  39930. * Gets a boolean indicating that current material needs to register RTT
  39931. */
  39932. readonly hasRenderTargetTextures: boolean;
  39933. /**
  39934. * Gets the current class name of the material e.g. "StandardMaterial"
  39935. * Mainly use in serialization.
  39936. * @returns the class name
  39937. */
  39938. getClassName(): string;
  39939. /**
  39940. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39941. * You can try switching to logarithmic depth.
  39942. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39943. */
  39944. useLogarithmicDepth: boolean;
  39945. /**
  39946. * Specifies if the material will require alpha blending
  39947. * @returns a boolean specifying if alpha blending is needed
  39948. */
  39949. needAlphaBlending(): boolean;
  39950. /**
  39951. * Specifies if this material should be rendered in alpha test mode
  39952. * @returns a boolean specifying if an alpha test is needed.
  39953. */
  39954. needAlphaTesting(): boolean;
  39955. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39956. /**
  39957. * Get the texture used for alpha test purpose.
  39958. * @returns the diffuse texture in case of the standard material.
  39959. */
  39960. getAlphaTestTexture(): Nullable<BaseTexture>;
  39961. /**
  39962. * Get if the submesh is ready to be used and all its information available.
  39963. * Child classes can use it to update shaders
  39964. * @param mesh defines the mesh to check
  39965. * @param subMesh defines which submesh to check
  39966. * @param useInstances specifies that instances should be used
  39967. * @returns a boolean indicating that the submesh is ready or not
  39968. */
  39969. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39970. /**
  39971. * Builds the material UBO layouts.
  39972. * Used internally during the effect preparation.
  39973. */
  39974. buildUniformLayout(): void;
  39975. /**
  39976. * Unbinds the material from the mesh
  39977. */
  39978. unbind(): void;
  39979. /**
  39980. * Binds the submesh to this material by preparing the effect and shader to draw
  39981. * @param world defines the world transformation matrix
  39982. * @param mesh defines the mesh containing the submesh
  39983. * @param subMesh defines the submesh to bind the material to
  39984. */
  39985. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39986. /**
  39987. * Get the list of animatables in the material.
  39988. * @returns the list of animatables object used in the material
  39989. */
  39990. getAnimatables(): IAnimatable[];
  39991. /**
  39992. * Gets the active textures from the material
  39993. * @returns an array of textures
  39994. */
  39995. getActiveTextures(): BaseTexture[];
  39996. /**
  39997. * Specifies if the material uses a texture
  39998. * @param texture defines the texture to check against the material
  39999. * @returns a boolean specifying if the material uses the texture
  40000. */
  40001. hasTexture(texture: BaseTexture): boolean;
  40002. /**
  40003. * Disposes the material
  40004. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40005. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40006. */
  40007. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40008. /**
  40009. * Makes a duplicate of the material, and gives it a new name
  40010. * @param name defines the new name for the duplicated material
  40011. * @returns the cloned material
  40012. */
  40013. clone(name: string): StandardMaterial;
  40014. /**
  40015. * Serializes this material in a JSON representation
  40016. * @returns the serialized material object
  40017. */
  40018. serialize(): any;
  40019. /**
  40020. * Creates a standard material from parsed material data
  40021. * @param source defines the JSON representation of the material
  40022. * @param scene defines the hosting scene
  40023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40024. * @returns a new standard material
  40025. */
  40026. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40027. /**
  40028. * Are diffuse textures enabled in the application.
  40029. */
  40030. static DiffuseTextureEnabled: boolean;
  40031. /**
  40032. * Are ambient textures enabled in the application.
  40033. */
  40034. static AmbientTextureEnabled: boolean;
  40035. /**
  40036. * Are opacity textures enabled in the application.
  40037. */
  40038. static OpacityTextureEnabled: boolean;
  40039. /**
  40040. * Are reflection textures enabled in the application.
  40041. */
  40042. static ReflectionTextureEnabled: boolean;
  40043. /**
  40044. * Are emissive textures enabled in the application.
  40045. */
  40046. static EmissiveTextureEnabled: boolean;
  40047. /**
  40048. * Are specular textures enabled in the application.
  40049. */
  40050. static SpecularTextureEnabled: boolean;
  40051. /**
  40052. * Are bump textures enabled in the application.
  40053. */
  40054. static BumpTextureEnabled: boolean;
  40055. /**
  40056. * Are lightmap textures enabled in the application.
  40057. */
  40058. static LightmapTextureEnabled: boolean;
  40059. /**
  40060. * Are refraction textures enabled in the application.
  40061. */
  40062. static RefractionTextureEnabled: boolean;
  40063. /**
  40064. * Are color grading textures enabled in the application.
  40065. */
  40066. static ColorGradingTextureEnabled: boolean;
  40067. /**
  40068. * Are fresnels enabled in the application.
  40069. */
  40070. static FresnelEnabled: boolean;
  40071. }
  40072. }
  40073. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40074. import { Scene } from "babylonjs/scene";
  40075. import { Texture } from "babylonjs/Materials/Textures/texture";
  40076. /**
  40077. * A class extending Texture allowing drawing on a texture
  40078. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40079. */
  40080. export class DynamicTexture extends Texture {
  40081. private _generateMipMaps;
  40082. private _canvas;
  40083. private _context;
  40084. private _engine;
  40085. /**
  40086. * Creates a DynamicTexture
  40087. * @param name defines the name of the texture
  40088. * @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
  40089. * @param scene defines the scene where you want the texture
  40090. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40091. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40092. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40093. */
  40094. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40095. /**
  40096. * Get the current class name of the texture useful for serialization or dynamic coding.
  40097. * @returns "DynamicTexture"
  40098. */
  40099. getClassName(): string;
  40100. /**
  40101. * Gets the current state of canRescale
  40102. */
  40103. readonly canRescale: boolean;
  40104. private _recreate;
  40105. /**
  40106. * Scales the texture
  40107. * @param ratio the scale factor to apply to both width and height
  40108. */
  40109. scale(ratio: number): void;
  40110. /**
  40111. * Resizes the texture
  40112. * @param width the new width
  40113. * @param height the new height
  40114. */
  40115. scaleTo(width: number, height: number): void;
  40116. /**
  40117. * Gets the context of the canvas used by the texture
  40118. * @returns the canvas context of the dynamic texture
  40119. */
  40120. getContext(): CanvasRenderingContext2D;
  40121. /**
  40122. * Clears the texture
  40123. */
  40124. clear(): void;
  40125. /**
  40126. * Updates the texture
  40127. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40128. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40129. */
  40130. update(invertY?: boolean, premulAlpha?: boolean): void;
  40131. /**
  40132. * Draws text onto the texture
  40133. * @param text defines the text to be drawn
  40134. * @param x defines the placement of the text from the left
  40135. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40136. * @param font defines the font to be used with font-style, font-size, font-name
  40137. * @param color defines the color used for the text
  40138. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40139. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40140. * @param update defines whether texture is immediately update (default is true)
  40141. */
  40142. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40143. /**
  40144. * Clones the texture
  40145. * @returns the clone of the texture.
  40146. */
  40147. clone(): DynamicTexture;
  40148. /**
  40149. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40150. * @returns a serialized dynamic texture object
  40151. */
  40152. serialize(): any;
  40153. /** @hidden */
  40154. _rebuild(): void;
  40155. }
  40156. }
  40157. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40158. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40160. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40161. /** @hidden */
  40162. export var imageProcessingPixelShader: {
  40163. name: string;
  40164. shader: string;
  40165. };
  40166. }
  40167. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40168. import { Nullable } from "babylonjs/types";
  40169. import { Color4 } from "babylonjs/Maths/math";
  40170. import { Camera } from "babylonjs/Cameras/camera";
  40171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40172. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40173. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40174. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40175. import { Engine } from "babylonjs/Engines/engine";
  40176. import "babylonjs/Shaders/imageProcessing.fragment";
  40177. import "babylonjs/Shaders/postprocess.vertex";
  40178. /**
  40179. * ImageProcessingPostProcess
  40180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40181. */
  40182. export class ImageProcessingPostProcess extends PostProcess {
  40183. /**
  40184. * Default configuration related to image processing available in the PBR Material.
  40185. */
  40186. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40187. /**
  40188. * Gets the image processing configuration used either in this material.
  40189. */
  40190. /**
  40191. * Sets the Default image processing configuration used either in the this material.
  40192. *
  40193. * If sets to null, the scene one is in use.
  40194. */
  40195. imageProcessingConfiguration: ImageProcessingConfiguration;
  40196. /**
  40197. * Keep track of the image processing observer to allow dispose and replace.
  40198. */
  40199. private _imageProcessingObserver;
  40200. /**
  40201. * Attaches a new image processing configuration to the PBR Material.
  40202. * @param configuration
  40203. */
  40204. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40205. /**
  40206. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40207. */
  40208. /**
  40209. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40210. */
  40211. colorCurves: Nullable<ColorCurves>;
  40212. /**
  40213. * Gets wether the color curves effect is enabled.
  40214. */
  40215. /**
  40216. * Sets wether the color curves effect is enabled.
  40217. */
  40218. colorCurvesEnabled: boolean;
  40219. /**
  40220. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40221. */
  40222. /**
  40223. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40224. */
  40225. colorGradingTexture: Nullable<BaseTexture>;
  40226. /**
  40227. * Gets wether the color grading effect is enabled.
  40228. */
  40229. /**
  40230. * Gets wether the color grading effect is enabled.
  40231. */
  40232. colorGradingEnabled: boolean;
  40233. /**
  40234. * Gets exposure used in the effect.
  40235. */
  40236. /**
  40237. * Sets exposure used in the effect.
  40238. */
  40239. exposure: number;
  40240. /**
  40241. * Gets wether tonemapping is enabled or not.
  40242. */
  40243. /**
  40244. * Sets wether tonemapping is enabled or not
  40245. */
  40246. toneMappingEnabled: boolean;
  40247. /**
  40248. * Gets contrast used in the effect.
  40249. */
  40250. /**
  40251. * Sets contrast used in the effect.
  40252. */
  40253. contrast: number;
  40254. /**
  40255. * Gets Vignette stretch size.
  40256. */
  40257. /**
  40258. * Sets Vignette stretch size.
  40259. */
  40260. vignetteStretch: number;
  40261. /**
  40262. * Gets Vignette centre X Offset.
  40263. */
  40264. /**
  40265. * Sets Vignette centre X Offset.
  40266. */
  40267. vignetteCentreX: number;
  40268. /**
  40269. * Gets Vignette centre Y Offset.
  40270. */
  40271. /**
  40272. * Sets Vignette centre Y Offset.
  40273. */
  40274. vignetteCentreY: number;
  40275. /**
  40276. * Gets Vignette weight or intensity of the vignette effect.
  40277. */
  40278. /**
  40279. * Sets Vignette weight or intensity of the vignette effect.
  40280. */
  40281. vignetteWeight: number;
  40282. /**
  40283. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40284. * if vignetteEnabled is set to true.
  40285. */
  40286. /**
  40287. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40288. * if vignetteEnabled is set to true.
  40289. */
  40290. vignetteColor: Color4;
  40291. /**
  40292. * Gets Camera field of view used by the Vignette effect.
  40293. */
  40294. /**
  40295. * Sets Camera field of view used by the Vignette effect.
  40296. */
  40297. vignetteCameraFov: number;
  40298. /**
  40299. * Gets the vignette blend mode allowing different kind of effect.
  40300. */
  40301. /**
  40302. * Sets the vignette blend mode allowing different kind of effect.
  40303. */
  40304. vignetteBlendMode: number;
  40305. /**
  40306. * Gets wether the vignette effect is enabled.
  40307. */
  40308. /**
  40309. * Sets wether the vignette effect is enabled.
  40310. */
  40311. vignetteEnabled: boolean;
  40312. private _fromLinearSpace;
  40313. /**
  40314. * Gets wether the input of the processing is in Gamma or Linear Space.
  40315. */
  40316. /**
  40317. * Sets wether the input of the processing is in Gamma or Linear Space.
  40318. */
  40319. fromLinearSpace: boolean;
  40320. /**
  40321. * Defines cache preventing GC.
  40322. */
  40323. private _defines;
  40324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40325. /**
  40326. * "ImageProcessingPostProcess"
  40327. * @returns "ImageProcessingPostProcess"
  40328. */
  40329. getClassName(): string;
  40330. protected _updateParameters(): void;
  40331. dispose(camera?: Camera): void;
  40332. }
  40333. }
  40334. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40335. import { Observable } from "babylonjs/Misc/observable";
  40336. import { Nullable } from "babylonjs/types";
  40337. import { Camera } from "babylonjs/Cameras/camera";
  40338. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40339. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40340. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40341. import { Scene } from "babylonjs/scene";
  40342. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40343. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40345. import { Mesh } from "babylonjs/Meshes/mesh";
  40346. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40347. /**
  40348. * Options to modify the vr teleportation behavior.
  40349. */
  40350. export interface VRTeleportationOptions {
  40351. /**
  40352. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40353. */
  40354. floorMeshName?: string;
  40355. /**
  40356. * A list of meshes to be used as the teleportation floor. (default: empty)
  40357. */
  40358. floorMeshes?: Mesh[];
  40359. }
  40360. /**
  40361. * Options to modify the vr experience helper's behavior.
  40362. */
  40363. export interface VRExperienceHelperOptions extends WebVROptions {
  40364. /**
  40365. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40366. */
  40367. createDeviceOrientationCamera?: boolean;
  40368. /**
  40369. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40370. */
  40371. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40372. /**
  40373. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40374. */
  40375. laserToggle?: boolean;
  40376. /**
  40377. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40378. */
  40379. floorMeshes?: Mesh[];
  40380. }
  40381. /**
  40382. * Helps to quickly add VR support to an existing scene.
  40383. * See http://doc.babylonjs.com/how_to/webvr_helper
  40384. */
  40385. export class VRExperienceHelper {
  40386. /** Options to modify the vr experience helper's behavior. */
  40387. webVROptions: VRExperienceHelperOptions;
  40388. private _scene;
  40389. private _position;
  40390. private _btnVR;
  40391. private _btnVRDisplayed;
  40392. private _webVRsupported;
  40393. private _webVRready;
  40394. private _webVRrequesting;
  40395. private _webVRpresenting;
  40396. private _hasEnteredVR;
  40397. private _fullscreenVRpresenting;
  40398. private _canvas;
  40399. private _webVRCamera;
  40400. private _vrDeviceOrientationCamera;
  40401. private _deviceOrientationCamera;
  40402. private _existingCamera;
  40403. private _onKeyDown;
  40404. private _onVrDisplayPresentChange;
  40405. private _onVRDisplayChanged;
  40406. private _onVRRequestPresentStart;
  40407. private _onVRRequestPresentComplete;
  40408. /**
  40409. * Observable raised when entering VR.
  40410. */
  40411. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40412. /**
  40413. * Observable raised when exiting VR.
  40414. */
  40415. onExitingVRObservable: Observable<VRExperienceHelper>;
  40416. /**
  40417. * Observable raised when controller mesh is loaded.
  40418. */
  40419. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40420. /** Return this.onEnteringVRObservable
  40421. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40422. */
  40423. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40424. /** Return this.onExitingVRObservable
  40425. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40426. */
  40427. readonly onExitingVR: Observable<VRExperienceHelper>;
  40428. /** Return this.onControllerMeshLoadedObservable
  40429. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40430. */
  40431. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40432. private _rayLength;
  40433. private _useCustomVRButton;
  40434. private _teleportationRequested;
  40435. private _teleportActive;
  40436. private _floorMeshName;
  40437. private _floorMeshesCollection;
  40438. private _rotationAllowed;
  40439. private _teleportBackwardsVector;
  40440. private _teleportationTarget;
  40441. private _isDefaultTeleportationTarget;
  40442. private _postProcessMove;
  40443. private _teleportationFillColor;
  40444. private _teleportationBorderColor;
  40445. private _rotationAngle;
  40446. private _haloCenter;
  40447. private _cameraGazer;
  40448. private _padSensibilityUp;
  40449. private _padSensibilityDown;
  40450. private _leftController;
  40451. private _rightController;
  40452. /**
  40453. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40454. */
  40455. onNewMeshSelected: Observable<AbstractMesh>;
  40456. /**
  40457. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40458. */
  40459. onNewMeshPicked: Observable<PickingInfo>;
  40460. private _circleEase;
  40461. /**
  40462. * Observable raised before camera teleportation
  40463. */
  40464. onBeforeCameraTeleport: Observable<Vector3>;
  40465. /**
  40466. * Observable raised after camera teleportation
  40467. */
  40468. onAfterCameraTeleport: Observable<Vector3>;
  40469. /**
  40470. * Observable raised when current selected mesh gets unselected
  40471. */
  40472. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40473. private _raySelectionPredicate;
  40474. /**
  40475. * To be optionaly changed by user to define custom ray selection
  40476. */
  40477. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40478. /**
  40479. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40480. */
  40481. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40482. /**
  40483. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40484. */
  40485. teleportationEnabled: boolean;
  40486. private _defaultHeight;
  40487. private _teleportationInitialized;
  40488. private _interactionsEnabled;
  40489. private _interactionsRequested;
  40490. private _displayGaze;
  40491. private _displayLaserPointer;
  40492. /**
  40493. * The mesh used to display where the user is going to teleport.
  40494. */
  40495. /**
  40496. * Sets the mesh to be used to display where the user is going to teleport.
  40497. */
  40498. teleportationTarget: Mesh;
  40499. /**
  40500. * 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
  40501. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40502. * See http://doc.babylonjs.com/resources/baking_transformations
  40503. */
  40504. gazeTrackerMesh: Mesh;
  40505. /**
  40506. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40507. */
  40508. updateGazeTrackerScale: boolean;
  40509. /**
  40510. * If the gaze trackers color should be updated when selecting meshes
  40511. */
  40512. updateGazeTrackerColor: boolean;
  40513. /**
  40514. * The gaze tracking mesh corresponding to the left controller
  40515. */
  40516. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40517. /**
  40518. * The gaze tracking mesh corresponding to the right controller
  40519. */
  40520. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40521. /**
  40522. * If the ray of the gaze should be displayed.
  40523. */
  40524. /**
  40525. * Sets if the ray of the gaze should be displayed.
  40526. */
  40527. displayGaze: boolean;
  40528. /**
  40529. * If the ray of the LaserPointer should be displayed.
  40530. */
  40531. /**
  40532. * Sets if the ray of the LaserPointer should be displayed.
  40533. */
  40534. displayLaserPointer: boolean;
  40535. /**
  40536. * The deviceOrientationCamera used as the camera when not in VR.
  40537. */
  40538. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40539. /**
  40540. * Based on the current WebVR support, returns the current VR camera used.
  40541. */
  40542. readonly currentVRCamera: Nullable<Camera>;
  40543. /**
  40544. * The webVRCamera which is used when in VR.
  40545. */
  40546. readonly webVRCamera: WebVRFreeCamera;
  40547. /**
  40548. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40549. */
  40550. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40551. private readonly _teleportationRequestInitiated;
  40552. /**
  40553. * Instantiates a VRExperienceHelper.
  40554. * Helps to quickly add VR support to an existing scene.
  40555. * @param scene The scene the VRExperienceHelper belongs to.
  40556. * @param webVROptions Options to modify the vr experience helper's behavior.
  40557. */
  40558. constructor(scene: Scene,
  40559. /** Options to modify the vr experience helper's behavior. */
  40560. webVROptions?: VRExperienceHelperOptions);
  40561. private _onDefaultMeshLoaded;
  40562. private _onResize;
  40563. private _onFullscreenChange;
  40564. /**
  40565. * Gets a value indicating if we are currently in VR mode.
  40566. */
  40567. readonly isInVRMode: boolean;
  40568. private onVrDisplayPresentChange;
  40569. private onVRDisplayChanged;
  40570. private moveButtonToBottomRight;
  40571. private displayVRButton;
  40572. private updateButtonVisibility;
  40573. private _cachedAngularSensibility;
  40574. /**
  40575. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40576. * Otherwise, will use the fullscreen API.
  40577. */
  40578. enterVR(): void;
  40579. /**
  40580. * Attempt to exit VR, or fullscreen.
  40581. */
  40582. exitVR(): void;
  40583. /**
  40584. * The position of the vr experience helper.
  40585. */
  40586. /**
  40587. * Sets the position of the vr experience helper.
  40588. */
  40589. position: Vector3;
  40590. /**
  40591. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40592. */
  40593. enableInteractions(): void;
  40594. private readonly _noControllerIsActive;
  40595. private beforeRender;
  40596. private _isTeleportationFloor;
  40597. /**
  40598. * Adds a floor mesh to be used for teleportation.
  40599. * @param floorMesh the mesh to be used for teleportation.
  40600. */
  40601. addFloorMesh(floorMesh: Mesh): void;
  40602. /**
  40603. * Removes a floor mesh from being used for teleportation.
  40604. * @param floorMesh the mesh to be removed.
  40605. */
  40606. removeFloorMesh(floorMesh: Mesh): void;
  40607. /**
  40608. * Enables interactions and teleportation using the VR controllers and gaze.
  40609. * @param vrTeleportationOptions options to modify teleportation behavior.
  40610. */
  40611. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40612. private _onNewGamepadConnected;
  40613. private _tryEnableInteractionOnController;
  40614. private _onNewGamepadDisconnected;
  40615. private _enableInteractionOnController;
  40616. private _checkTeleportWithRay;
  40617. private _checkRotate;
  40618. private _checkTeleportBackwards;
  40619. private _enableTeleportationOnController;
  40620. private _createTeleportationCircles;
  40621. private _displayTeleportationTarget;
  40622. private _hideTeleportationTarget;
  40623. private _rotateCamera;
  40624. private _moveTeleportationSelectorTo;
  40625. private _workingVector;
  40626. private _workingQuaternion;
  40627. private _workingMatrix;
  40628. /**
  40629. * Teleports the users feet to the desired location
  40630. * @param location The location where the user's feet should be placed
  40631. */
  40632. teleportCamera(location: Vector3): void;
  40633. private _convertNormalToDirectionOfRay;
  40634. private _castRayAndSelectObject;
  40635. private _notifySelectedMeshUnselected;
  40636. /**
  40637. * Sets the color of the laser ray from the vr controllers.
  40638. * @param color new color for the ray.
  40639. */
  40640. changeLaserColor(color: Color3): void;
  40641. /**
  40642. * Sets the color of the ray from the vr headsets gaze.
  40643. * @param color new color for the ray.
  40644. */
  40645. changeGazeColor(color: Color3): void;
  40646. /**
  40647. * Exits VR and disposes of the vr experience helper
  40648. */
  40649. dispose(): void;
  40650. /**
  40651. * Gets the name of the VRExperienceHelper class
  40652. * @returns "VRExperienceHelper"
  40653. */
  40654. getClassName(): string;
  40655. }
  40656. }
  40657. declare module "babylonjs/Cameras/VR/index" {
  40658. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40659. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40660. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40661. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40662. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40663. export * from "babylonjs/Cameras/VR/webVRCamera";
  40664. }
  40665. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40666. import { Observable } from "babylonjs/Misc/observable";
  40667. import { Nullable } from "babylonjs/types";
  40668. import { IDisposable, Scene } from "babylonjs/scene";
  40669. import { Vector3 } from "babylonjs/Maths/math";
  40670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40671. import { Ray } from "babylonjs/Culling/ray";
  40672. /**
  40673. * Manages an XRSession
  40674. * @see https://doc.babylonjs.com/how_to/webxr
  40675. */
  40676. export class WebXRSessionManager implements IDisposable {
  40677. private scene;
  40678. /**
  40679. * Fires every time a new xrFrame arrives which can be used to update the camera
  40680. */
  40681. onXRFrameObservable: Observable<any>;
  40682. /**
  40683. * Fires when the xr session is ended either by the device or manually done
  40684. */
  40685. onXRSessionEnded: Observable<any>;
  40686. /** @hidden */
  40687. _xrSession: XRSession;
  40688. /** @hidden */
  40689. _frameOfReference: XRFrameOfReference;
  40690. /** @hidden */
  40691. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40692. /** @hidden */
  40693. _currentXRFrame: Nullable<XRFrame>;
  40694. private _xrNavigator;
  40695. private _xrDevice;
  40696. private _tmpMatrix;
  40697. /**
  40698. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40699. * @param scene The scene which the session should be created for
  40700. */
  40701. constructor(scene: Scene);
  40702. /**
  40703. * Initializes the manager
  40704. * After initialization enterXR can be called to start an XR session
  40705. * @returns Promise which resolves after it is initialized
  40706. */
  40707. initializeAsync(): Promise<void>;
  40708. /**
  40709. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40710. * @param sessionCreationOptions xr options to create the session with
  40711. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40712. * @returns Promise which resolves after it enters XR
  40713. */
  40714. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40715. /**
  40716. * Stops the xrSession and restores the renderloop
  40717. * @returns Promise which resolves after it exits XR
  40718. */
  40719. exitXRAsync(): Promise<void>;
  40720. /**
  40721. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40722. * @param ray ray to cast into the environment
  40723. * @returns Promise which resolves with a collision point in the environment if it exists
  40724. */
  40725. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40726. /**
  40727. * Checks if a session would be supported for the creation options specified
  40728. * @param options creation options to check if they are supported
  40729. * @returns true if supported
  40730. */
  40731. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40732. /**
  40733. * @hidden
  40734. * Converts the render layer of xrSession to a render target
  40735. * @param session session to create render target for
  40736. * @param scene scene the new render target should be created for
  40737. */
  40738. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40739. /**
  40740. * Disposes of the session manager
  40741. */
  40742. dispose(): void;
  40743. }
  40744. }
  40745. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40746. import { Scene } from "babylonjs/scene";
  40747. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40748. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40749. /**
  40750. * WebXR Camera which holds the views for the xrSession
  40751. * @see https://doc.babylonjs.com/how_to/webxr
  40752. */
  40753. export class WebXRCamera extends FreeCamera {
  40754. private static _TmpMatrix;
  40755. /**
  40756. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40757. * @param name the name of the camera
  40758. * @param scene the scene to add the camera to
  40759. */
  40760. constructor(name: string, scene: Scene);
  40761. private _updateNumberOfRigCameras;
  40762. /** @hidden */
  40763. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40764. /**
  40765. * Updates the cameras position from the current pose information of the XR session
  40766. * @param xrSessionManager the session containing pose information
  40767. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40768. */
  40769. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40770. }
  40771. }
  40772. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40773. import { Nullable } from "babylonjs/types";
  40774. import { Observable } from "babylonjs/Misc/observable";
  40775. import { IDisposable, Scene } from "babylonjs/scene";
  40776. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40778. import { Ray } from "babylonjs/Culling/ray";
  40779. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40780. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40781. /**
  40782. * States of the webXR experience
  40783. */
  40784. export enum WebXRState {
  40785. /**
  40786. * Transitioning to being in XR mode
  40787. */
  40788. ENTERING_XR = 0,
  40789. /**
  40790. * Transitioning to non XR mode
  40791. */
  40792. EXITING_XR = 1,
  40793. /**
  40794. * In XR mode and presenting
  40795. */
  40796. IN_XR = 2,
  40797. /**
  40798. * Not entered XR mode
  40799. */
  40800. NOT_IN_XR = 3
  40801. }
  40802. /**
  40803. * Helper class used to enable XR
  40804. * @see https://doc.babylonjs.com/how_to/webxr
  40805. */
  40806. export class WebXRExperienceHelper implements IDisposable {
  40807. private scene;
  40808. /**
  40809. * 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
  40810. */
  40811. container: AbstractMesh;
  40812. /**
  40813. * Camera used to render xr content
  40814. */
  40815. camera: WebXRCamera;
  40816. /**
  40817. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40818. */
  40819. state: WebXRState;
  40820. private _setState;
  40821. private static _TmpVector;
  40822. /**
  40823. * Fires when the state of the experience helper has changed
  40824. */
  40825. onStateChangedObservable: Observable<WebXRState>;
  40826. /** @hidden */
  40827. _sessionManager: WebXRSessionManager;
  40828. private _nonVRCamera;
  40829. private _originalSceneAutoClear;
  40830. private _supported;
  40831. /**
  40832. * Creates the experience helper
  40833. * @param scene the scene to attach the experience helper to
  40834. * @returns a promise for the experience helper
  40835. */
  40836. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40837. /**
  40838. * Creates a WebXRExperienceHelper
  40839. * @param scene The scene the helper should be created in
  40840. */
  40841. private constructor();
  40842. /**
  40843. * Exits XR mode and returns the scene to its original state
  40844. * @returns promise that resolves after xr mode has exited
  40845. */
  40846. exitXRAsync(): Promise<void>;
  40847. /**
  40848. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40849. * @param sessionCreationOptions options for the XR session
  40850. * @param frameOfReference frame of reference of the XR session
  40851. * @returns promise that resolves after xr mode has entered
  40852. */
  40853. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40854. /**
  40855. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40856. * @param ray ray to cast into the environment
  40857. * @returns Promise which resolves with a collision point in the environment if it exists
  40858. */
  40859. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40860. /**
  40861. * Updates the global position of the camera by moving the camera's container
  40862. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40863. * @param position The desired global position of the camera
  40864. */
  40865. setPositionOfCameraUsingContainer(position: Vector3): void;
  40866. /**
  40867. * Rotates the xr camera by rotating the camera's container around the camera's position
  40868. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40869. * @param rotation the desired quaternion rotation to apply to the camera
  40870. */
  40871. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40872. /**
  40873. * Checks if the creation options are supported by the xr session
  40874. * @param options creation options
  40875. * @returns true if supported
  40876. */
  40877. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40878. /**
  40879. * Disposes of the experience helper
  40880. */
  40881. dispose(): void;
  40882. }
  40883. }
  40884. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40885. import { Nullable } from "babylonjs/types";
  40886. import { Observable } from "babylonjs/Misc/observable";
  40887. import { IDisposable, Scene } from "babylonjs/scene";
  40888. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40889. /**
  40890. * Button which can be used to enter a different mode of XR
  40891. */
  40892. export class WebXREnterExitUIButton {
  40893. /** button element */
  40894. element: HTMLElement;
  40895. /** XR initialization options for the button */
  40896. initializationOptions: XRSessionCreationOptions;
  40897. /**
  40898. * Creates a WebXREnterExitUIButton
  40899. * @param element button element
  40900. * @param initializationOptions XR initialization options for the button
  40901. */
  40902. constructor(
  40903. /** button element */
  40904. element: HTMLElement,
  40905. /** XR initialization options for the button */
  40906. initializationOptions: XRSessionCreationOptions);
  40907. /**
  40908. * Overwritable function which can be used to update the button's visuals when the state changes
  40909. * @param activeButton the current active button in the UI
  40910. */
  40911. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40912. }
  40913. /**
  40914. * Options to create the webXR UI
  40915. */
  40916. export class WebXREnterExitUIOptions {
  40917. /**
  40918. * Context to enter xr with
  40919. */
  40920. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40921. /**
  40922. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40923. */
  40924. customButtons?: Array<WebXREnterExitUIButton>;
  40925. }
  40926. /**
  40927. * UI to allow the user to enter/exit XR mode
  40928. */
  40929. export class WebXREnterExitUI implements IDisposable {
  40930. private scene;
  40931. private _overlay;
  40932. private _buttons;
  40933. private _activeButton;
  40934. /**
  40935. * Fired every time the active button is changed.
  40936. *
  40937. * When xr is entered via a button that launches xr that button will be the callback parameter
  40938. *
  40939. * When exiting xr the callback parameter will be null)
  40940. */
  40941. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40942. /**
  40943. * Creates UI to allow the user to enter/exit XR mode
  40944. * @param scene the scene to add the ui to
  40945. * @param helper the xr experience helper to enter/exit xr with
  40946. * @param options options to configure the UI
  40947. * @returns the created ui
  40948. */
  40949. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40950. private constructor();
  40951. private _updateButtons;
  40952. /**
  40953. * Disposes of the object
  40954. */
  40955. dispose(): void;
  40956. }
  40957. }
  40958. declare module "babylonjs/Cameras/XR/webXRInput" {
  40959. import { IDisposable, Scene } from "babylonjs/scene";
  40960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40961. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40962. /**
  40963. * Represents an XR input
  40964. */
  40965. export class WebXRController {
  40966. /**
  40967. * 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
  40968. */
  40969. grip?: AbstractMesh;
  40970. /**
  40971. * Pointer which can be used to select objects or attach a visible laser to
  40972. */
  40973. pointer: AbstractMesh;
  40974. /**
  40975. * Creates the controller
  40976. * @see https://doc.babylonjs.com/how_to/webxr
  40977. * @param scene the scene which the controller should be associated to
  40978. */
  40979. constructor(scene: Scene);
  40980. /**
  40981. * Disposes of the object
  40982. */
  40983. dispose(): void;
  40984. }
  40985. /**
  40986. * XR input used to track XR inputs such as controllers/rays
  40987. */
  40988. export class WebXRInput implements IDisposable {
  40989. private helper;
  40990. /**
  40991. * XR controllers being tracked
  40992. */
  40993. controllers: Array<WebXRController>;
  40994. private _tmpMatrix;
  40995. private _frameObserver;
  40996. /**
  40997. * Initializes the WebXRInput
  40998. * @param helper experience helper which the input should be created for
  40999. */
  41000. constructor(helper: WebXRExperienceHelper);
  41001. /**
  41002. * Disposes of the object
  41003. */
  41004. dispose(): void;
  41005. }
  41006. }
  41007. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41008. import { Nullable } from "babylonjs/types";
  41009. import { IDisposable } from "babylonjs/scene";
  41010. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41011. /**
  41012. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41013. */
  41014. export class WebXRManagedOutputCanvas implements IDisposable {
  41015. private _canvas;
  41016. /**
  41017. * xrpresent context of the canvas which can be used to display/mirror xr content
  41018. */
  41019. canvasContext: Nullable<WebGLRenderingContext>;
  41020. /**
  41021. * Initializes the canvas to be added/removed upon entering/exiting xr
  41022. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41023. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41024. */
  41025. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41026. /**
  41027. * Disposes of the object
  41028. */
  41029. dispose(): void;
  41030. private _setManagedOutputCanvas;
  41031. private _addCanvas;
  41032. private _removeCanvas;
  41033. }
  41034. }
  41035. declare module "babylonjs/Cameras/XR/index" {
  41036. export * from "babylonjs/Cameras/XR/webXRCamera";
  41037. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41038. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41039. export * from "babylonjs/Cameras/XR/webXRInput";
  41040. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41041. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41042. }
  41043. declare module "babylonjs/Cameras/RigModes/index" {
  41044. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41045. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41046. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41047. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41048. }
  41049. declare module "babylonjs/Cameras/index" {
  41050. export * from "babylonjs/Cameras/Inputs/index";
  41051. export * from "babylonjs/Cameras/cameraInputsManager";
  41052. export * from "babylonjs/Cameras/camera";
  41053. export * from "babylonjs/Cameras/targetCamera";
  41054. export * from "babylonjs/Cameras/freeCamera";
  41055. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41056. export * from "babylonjs/Cameras/touchCamera";
  41057. export * from "babylonjs/Cameras/arcRotateCamera";
  41058. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41059. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41060. export * from "babylonjs/Cameras/flyCamera";
  41061. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41062. export * from "babylonjs/Cameras/followCamera";
  41063. export * from "babylonjs/Cameras/gamepadCamera";
  41064. export * from "babylonjs/Cameras/Stereoscopic/index";
  41065. export * from "babylonjs/Cameras/universalCamera";
  41066. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41067. export * from "babylonjs/Cameras/VR/index";
  41068. export * from "babylonjs/Cameras/XR/index";
  41069. export * from "babylonjs/Cameras/RigModes/index";
  41070. }
  41071. declare module "babylonjs/Collisions/index" {
  41072. export * from "babylonjs/Collisions/collider";
  41073. export * from "babylonjs/Collisions/collisionCoordinator";
  41074. export * from "babylonjs/Collisions/pickingInfo";
  41075. export * from "babylonjs/Collisions/intersectionInfo";
  41076. }
  41077. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41078. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41079. import { Vector3, Plane } from "babylonjs/Maths/math";
  41080. import { Ray } from "babylonjs/Culling/ray";
  41081. /**
  41082. * Contains an array of blocks representing the octree
  41083. */
  41084. export interface IOctreeContainer<T> {
  41085. /**
  41086. * Blocks within the octree
  41087. */
  41088. blocks: Array<OctreeBlock<T>>;
  41089. }
  41090. /**
  41091. * Class used to store a cell in an octree
  41092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41093. */
  41094. export class OctreeBlock<T> {
  41095. /**
  41096. * Gets the content of the current block
  41097. */
  41098. entries: T[];
  41099. /**
  41100. * Gets the list of block children
  41101. */
  41102. blocks: Array<OctreeBlock<T>>;
  41103. private _depth;
  41104. private _maxDepth;
  41105. private _capacity;
  41106. private _minPoint;
  41107. private _maxPoint;
  41108. private _boundingVectors;
  41109. private _creationFunc;
  41110. /**
  41111. * Creates a new block
  41112. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41113. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41114. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41115. * @param depth defines the current depth of this block in the octree
  41116. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41117. * @param creationFunc defines a callback to call when an element is added to the block
  41118. */
  41119. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41120. /**
  41121. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41122. */
  41123. readonly capacity: number;
  41124. /**
  41125. * Gets the minimum vector (in world space) of the block's bounding box
  41126. */
  41127. readonly minPoint: Vector3;
  41128. /**
  41129. * Gets the maximum vector (in world space) of the block's bounding box
  41130. */
  41131. readonly maxPoint: Vector3;
  41132. /**
  41133. * Add a new element to this block
  41134. * @param entry defines the element to add
  41135. */
  41136. addEntry(entry: T): void;
  41137. /**
  41138. * Remove an element from this block
  41139. * @param entry defines the element to remove
  41140. */
  41141. removeEntry(entry: T): void;
  41142. /**
  41143. * Add an array of elements to this block
  41144. * @param entries defines the array of elements to add
  41145. */
  41146. addEntries(entries: T[]): void;
  41147. /**
  41148. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41149. * @param frustumPlanes defines the frustum planes to test
  41150. * @param selection defines the array to store current content if selection is positive
  41151. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41152. */
  41153. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41154. /**
  41155. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41156. * @param sphereCenter defines the bounding sphere center
  41157. * @param sphereRadius defines the bounding sphere radius
  41158. * @param selection defines the array to store current content if selection is positive
  41159. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41160. */
  41161. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41162. /**
  41163. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41164. * @param ray defines the ray to test with
  41165. * @param selection defines the array to store current content if selection is positive
  41166. */
  41167. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41168. /**
  41169. * Subdivide the content into child blocks (this block will then be empty)
  41170. */
  41171. createInnerBlocks(): void;
  41172. /**
  41173. * @hidden
  41174. */
  41175. 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;
  41176. }
  41177. }
  41178. declare module "babylonjs/Culling/Octrees/octree" {
  41179. import { SmartArray } from "babylonjs/Misc/smartArray";
  41180. import { Vector3, Plane } from "babylonjs/Maths/math";
  41181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41183. import { Ray } from "babylonjs/Culling/ray";
  41184. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41185. /**
  41186. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41187. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41188. */
  41189. export class Octree<T> {
  41190. /** 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.) */
  41191. maxDepth: number;
  41192. /**
  41193. * Blocks within the octree containing objects
  41194. */
  41195. blocks: Array<OctreeBlock<T>>;
  41196. /**
  41197. * Content stored in the octree
  41198. */
  41199. dynamicContent: T[];
  41200. private _maxBlockCapacity;
  41201. private _selectionContent;
  41202. private _creationFunc;
  41203. /**
  41204. * Creates a octree
  41205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41206. * @param creationFunc function to be used to instatiate the octree
  41207. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41208. * @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.)
  41209. */
  41210. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41211. /** 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.) */
  41212. maxDepth?: number);
  41213. /**
  41214. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41215. * @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);
  41216. * @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);
  41217. * @param entries meshes to be added to the octree blocks
  41218. */
  41219. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41220. /**
  41221. * Adds a mesh to the octree
  41222. * @param entry Mesh to add to the octree
  41223. */
  41224. addMesh(entry: T): void;
  41225. /**
  41226. * Remove an element from the octree
  41227. * @param entry defines the element to remove
  41228. */
  41229. removeMesh(entry: T): void;
  41230. /**
  41231. * Selects an array of meshes within the frustum
  41232. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41233. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41234. * @returns array of meshes within the frustum
  41235. */
  41236. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41237. /**
  41238. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41239. * @param sphereCenter defines the bounding sphere center
  41240. * @param sphereRadius defines the bounding sphere radius
  41241. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41242. * @returns an array of objects that intersect the sphere
  41243. */
  41244. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41245. /**
  41246. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41247. * @param ray defines the ray to test with
  41248. * @returns array of intersected objects
  41249. */
  41250. intersectsRay(ray: Ray): SmartArray<T>;
  41251. /**
  41252. * Adds a mesh into the octree block if it intersects the block
  41253. */
  41254. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41255. /**
  41256. * Adds a submesh into the octree block if it intersects the block
  41257. */
  41258. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41259. }
  41260. }
  41261. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41262. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41263. import { Scene } from "babylonjs/scene";
  41264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41266. import { Collider } from "babylonjs/Collisions/collider";
  41267. import { Ray } from "babylonjs/Culling/ray";
  41268. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41269. module "babylonjs/scene" {
  41270. interface Scene {
  41271. /**
  41272. * @hidden
  41273. * Backing Filed
  41274. */
  41275. _selectionOctree: Octree<AbstractMesh>;
  41276. /**
  41277. * Gets the octree used to boost mesh selection (picking)
  41278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41279. */
  41280. selectionOctree: Octree<AbstractMesh>;
  41281. /**
  41282. * Creates or updates the octree used to boost selection (picking)
  41283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41284. * @param maxCapacity defines the maximum capacity per leaf
  41285. * @param maxDepth defines the maximum depth of the octree
  41286. * @returns an octree of AbstractMesh
  41287. */
  41288. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41289. }
  41290. }
  41291. module "babylonjs/Meshes/abstractMesh" {
  41292. interface AbstractMesh {
  41293. /**
  41294. * @hidden
  41295. * Backing Field
  41296. */
  41297. _submeshesOctree: Octree<SubMesh>;
  41298. /**
  41299. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41300. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41301. * @param maxCapacity defines the maximum size of each block (64 by default)
  41302. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41303. * @returns the new octree
  41304. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41306. */
  41307. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41308. }
  41309. }
  41310. /**
  41311. * Defines the octree scene component responsible to manage any octrees
  41312. * in a given scene.
  41313. */
  41314. export class OctreeSceneComponent {
  41315. /**
  41316. * The component name helpfull to identify the component in the list of scene components.
  41317. */
  41318. readonly name: string;
  41319. /**
  41320. * The scene the component belongs to.
  41321. */
  41322. scene: Scene;
  41323. /**
  41324. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41325. */
  41326. readonly checksIsEnabled: boolean;
  41327. /**
  41328. * Creates a new instance of the component for the given scene
  41329. * @param scene Defines the scene to register the component in
  41330. */
  41331. constructor(scene: Scene);
  41332. /**
  41333. * Registers the component in a given scene
  41334. */
  41335. register(): void;
  41336. /**
  41337. * Return the list of active meshes
  41338. * @returns the list of active meshes
  41339. */
  41340. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41341. /**
  41342. * Return the list of active sub meshes
  41343. * @param mesh The mesh to get the candidates sub meshes from
  41344. * @returns the list of active sub meshes
  41345. */
  41346. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41347. private _tempRay;
  41348. /**
  41349. * Return the list of sub meshes intersecting with a given local ray
  41350. * @param mesh defines the mesh to find the submesh for
  41351. * @param localRay defines the ray in local space
  41352. * @returns the list of intersecting sub meshes
  41353. */
  41354. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41355. /**
  41356. * Return the list of sub meshes colliding with a collider
  41357. * @param mesh defines the mesh to find the submesh for
  41358. * @param collider defines the collider to evaluate the collision against
  41359. * @returns the list of colliding sub meshes
  41360. */
  41361. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41362. /**
  41363. * Rebuilds the elements related to this component in case of
  41364. * context lost for instance.
  41365. */
  41366. rebuild(): void;
  41367. /**
  41368. * Disposes the component and the associated ressources.
  41369. */
  41370. dispose(): void;
  41371. }
  41372. }
  41373. declare module "babylonjs/Culling/Octrees/index" {
  41374. export * from "babylonjs/Culling/Octrees/octree";
  41375. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41376. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41377. }
  41378. declare module "babylonjs/Culling/index" {
  41379. export * from "babylonjs/Culling/boundingBox";
  41380. export * from "babylonjs/Culling/boundingInfo";
  41381. export * from "babylonjs/Culling/boundingSphere";
  41382. export * from "babylonjs/Culling/Octrees/index";
  41383. export * from "babylonjs/Culling/ray";
  41384. }
  41385. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41386. import { IDisposable, Scene } from "babylonjs/scene";
  41387. import { Nullable } from "babylonjs/types";
  41388. import { Observable } from "babylonjs/Misc/observable";
  41389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41390. /**
  41391. * Renders a layer on top of an existing scene
  41392. */
  41393. export class UtilityLayerRenderer implements IDisposable {
  41394. /** the original scene that will be rendered on top of */
  41395. originalScene: Scene;
  41396. private _pointerCaptures;
  41397. private _lastPointerEvents;
  41398. private static _DefaultUtilityLayer;
  41399. private static _DefaultKeepDepthUtilityLayer;
  41400. /**
  41401. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41402. */
  41403. pickUtilitySceneFirst: boolean;
  41404. /**
  41405. * 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)
  41406. */
  41407. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41408. /**
  41409. * 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)
  41410. */
  41411. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41412. /**
  41413. * The scene that is rendered on top of the original scene
  41414. */
  41415. utilityLayerScene: Scene;
  41416. /**
  41417. * If the utility layer should automatically be rendered on top of existing scene
  41418. */
  41419. shouldRender: boolean;
  41420. /**
  41421. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41422. */
  41423. onlyCheckPointerDownEvents: boolean;
  41424. /**
  41425. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41426. */
  41427. processAllEvents: boolean;
  41428. /**
  41429. * Observable raised when the pointer move from the utility layer scene to the main scene
  41430. */
  41431. onPointerOutObservable: Observable<number>;
  41432. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41433. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41434. private _afterRenderObserver;
  41435. private _sceneDisposeObserver;
  41436. private _originalPointerObserver;
  41437. /**
  41438. * Instantiates a UtilityLayerRenderer
  41439. * @param originalScene the original scene that will be rendered on top of
  41440. * @param handleEvents boolean indicating if the utility layer should handle events
  41441. */
  41442. constructor(
  41443. /** the original scene that will be rendered on top of */
  41444. originalScene: Scene, handleEvents?: boolean);
  41445. private _notifyObservers;
  41446. /**
  41447. * Renders the utility layers scene on top of the original scene
  41448. */
  41449. render(): void;
  41450. /**
  41451. * Disposes of the renderer
  41452. */
  41453. dispose(): void;
  41454. private _updateCamera;
  41455. }
  41456. }
  41457. declare module "babylonjs/Gizmos/gizmo" {
  41458. import { Nullable } from "babylonjs/types";
  41459. import { IDisposable } from "babylonjs/scene";
  41460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41461. import { Mesh } from "babylonjs/Meshes/mesh";
  41462. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41463. /**
  41464. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41465. */
  41466. export class Gizmo implements IDisposable {
  41467. /** The utility layer the gizmo will be added to */
  41468. gizmoLayer: UtilityLayerRenderer;
  41469. /**
  41470. * The root mesh of the gizmo
  41471. */
  41472. protected _rootMesh: Mesh;
  41473. private _attachedMesh;
  41474. /**
  41475. * Ratio for the scale of the gizmo (Default: 1)
  41476. */
  41477. scaleRatio: number;
  41478. private _tmpMatrix;
  41479. /**
  41480. * If a custom mesh has been set (Default: false)
  41481. */
  41482. protected _customMeshSet: boolean;
  41483. /**
  41484. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41485. * * When set, interactions will be enabled
  41486. */
  41487. attachedMesh: Nullable<AbstractMesh>;
  41488. /**
  41489. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41490. * @param mesh The mesh to replace the default mesh of the gizmo
  41491. */
  41492. setCustomMesh(mesh: Mesh): void;
  41493. /**
  41494. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41495. */
  41496. updateGizmoRotationToMatchAttachedMesh: boolean;
  41497. /**
  41498. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41499. */
  41500. updateGizmoPositionToMatchAttachedMesh: boolean;
  41501. /**
  41502. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41503. */
  41504. protected _updateScale: boolean;
  41505. protected _interactionsEnabled: boolean;
  41506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41507. private _beforeRenderObserver;
  41508. /**
  41509. * Creates a gizmo
  41510. * @param gizmoLayer The utility layer the gizmo will be added to
  41511. */
  41512. constructor(
  41513. /** The utility layer the gizmo will be added to */
  41514. gizmoLayer?: UtilityLayerRenderer);
  41515. private _tempVector;
  41516. /**
  41517. * @hidden
  41518. * Updates the gizmo to match the attached mesh's position/rotation
  41519. */
  41520. protected _update(): void;
  41521. /**
  41522. * Disposes of the gizmo
  41523. */
  41524. dispose(): void;
  41525. }
  41526. }
  41527. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41528. import { Observable } from "babylonjs/Misc/observable";
  41529. import { Nullable } from "babylonjs/types";
  41530. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41531. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41533. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41534. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41535. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41536. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41537. import { Scene } from "babylonjs/scene";
  41538. /**
  41539. * Single axis drag gizmo
  41540. */
  41541. export class AxisDragGizmo extends Gizmo {
  41542. /**
  41543. * Drag behavior responsible for the gizmos dragging interactions
  41544. */
  41545. dragBehavior: PointerDragBehavior;
  41546. private _pointerObserver;
  41547. /**
  41548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41549. */
  41550. snapDistance: number;
  41551. /**
  41552. * Event that fires each time the gizmo snaps to a new location.
  41553. * * snapDistance is the the change in distance
  41554. */
  41555. onSnapObservable: Observable<{
  41556. snapDistance: number;
  41557. }>;
  41558. /** @hidden */
  41559. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41560. /** @hidden */
  41561. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41562. /**
  41563. * Creates an AxisDragGizmo
  41564. * @param gizmoLayer The utility layer the gizmo will be added to
  41565. * @param dragAxis The axis which the gizmo will be able to drag on
  41566. * @param color The color of the gizmo
  41567. */
  41568. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41569. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41570. /**
  41571. * Disposes of the gizmo
  41572. */
  41573. dispose(): void;
  41574. }
  41575. }
  41576. declare module "babylonjs/Debug/axesViewer" {
  41577. import { Vector3 } from "babylonjs/Maths/math";
  41578. import { Nullable } from "babylonjs/types";
  41579. import { Scene } from "babylonjs/scene";
  41580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41581. /**
  41582. * The Axes viewer will show 3 axes in a specific point in space
  41583. */
  41584. export class AxesViewer {
  41585. private _xAxis;
  41586. private _yAxis;
  41587. private _zAxis;
  41588. private _scaleLinesFactor;
  41589. private _instanced;
  41590. /**
  41591. * Gets the hosting scene
  41592. */
  41593. scene: Scene;
  41594. /**
  41595. * Gets or sets a number used to scale line length
  41596. */
  41597. scaleLines: number;
  41598. /** Gets the node hierarchy used to render x-axis */
  41599. readonly xAxis: TransformNode;
  41600. /** Gets the node hierarchy used to render y-axis */
  41601. readonly yAxis: TransformNode;
  41602. /** Gets the node hierarchy used to render z-axis */
  41603. readonly zAxis: TransformNode;
  41604. /**
  41605. * Creates a new AxesViewer
  41606. * @param scene defines the hosting scene
  41607. * @param scaleLines defines a number used to scale line length (1 by default)
  41608. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41609. * @param xAxis defines the node hierarchy used to render the x-axis
  41610. * @param yAxis defines the node hierarchy used to render the y-axis
  41611. * @param zAxis defines the node hierarchy used to render the z-axis
  41612. */
  41613. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41614. /**
  41615. * Force the viewer to update
  41616. * @param position defines the position of the viewer
  41617. * @param xaxis defines the x axis of the viewer
  41618. * @param yaxis defines the y axis of the viewer
  41619. * @param zaxis defines the z axis of the viewer
  41620. */
  41621. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41622. /**
  41623. * Creates an instance of this axes viewer.
  41624. * @returns a new axes viewer with instanced meshes
  41625. */
  41626. createInstance(): AxesViewer;
  41627. /** Releases resources */
  41628. dispose(): void;
  41629. private static _SetRenderingGroupId;
  41630. }
  41631. }
  41632. declare module "babylonjs/Debug/boneAxesViewer" {
  41633. import { Nullable } from "babylonjs/types";
  41634. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41635. import { Vector3 } from "babylonjs/Maths/math";
  41636. import { Mesh } from "babylonjs/Meshes/mesh";
  41637. import { Bone } from "babylonjs/Bones/bone";
  41638. import { Scene } from "babylonjs/scene";
  41639. /**
  41640. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41641. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41642. */
  41643. export class BoneAxesViewer extends AxesViewer {
  41644. /**
  41645. * Gets or sets the target mesh where to display the axes viewer
  41646. */
  41647. mesh: Nullable<Mesh>;
  41648. /**
  41649. * Gets or sets the target bone where to display the axes viewer
  41650. */
  41651. bone: Nullable<Bone>;
  41652. /** Gets current position */
  41653. pos: Vector3;
  41654. /** Gets direction of X axis */
  41655. xaxis: Vector3;
  41656. /** Gets direction of Y axis */
  41657. yaxis: Vector3;
  41658. /** Gets direction of Z axis */
  41659. zaxis: Vector3;
  41660. /**
  41661. * Creates a new BoneAxesViewer
  41662. * @param scene defines the hosting scene
  41663. * @param bone defines the target bone
  41664. * @param mesh defines the target mesh
  41665. * @param scaleLines defines a scaling factor for line length (1 by default)
  41666. */
  41667. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41668. /**
  41669. * Force the viewer to update
  41670. */
  41671. update(): void;
  41672. /** Releases resources */
  41673. dispose(): void;
  41674. }
  41675. }
  41676. declare module "babylonjs/Debug/debugLayer" {
  41677. import { Observable } from "babylonjs/Misc/observable";
  41678. import { Scene } from "babylonjs/scene";
  41679. /**
  41680. * Interface used to define scene explorer extensibility option
  41681. */
  41682. export interface IExplorerExtensibilityOption {
  41683. /**
  41684. * Define the option label
  41685. */
  41686. label: string;
  41687. /**
  41688. * Defines the action to execute on click
  41689. */
  41690. action: (entity: any) => void;
  41691. }
  41692. /**
  41693. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41694. */
  41695. export interface IExplorerExtensibilityGroup {
  41696. /**
  41697. * Defines a predicate to test if a given type mut be extended
  41698. */
  41699. predicate: (entity: any) => boolean;
  41700. /**
  41701. * Gets the list of options added to a type
  41702. */
  41703. entries: IExplorerExtensibilityOption[];
  41704. }
  41705. /**
  41706. * Interface used to define the options to use to create the Inspector
  41707. */
  41708. export interface IInspectorOptions {
  41709. /**
  41710. * Display in overlay mode (default: false)
  41711. */
  41712. overlay?: boolean;
  41713. /**
  41714. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41715. */
  41716. globalRoot?: HTMLElement;
  41717. /**
  41718. * Display the Scene explorer
  41719. */
  41720. showExplorer?: boolean;
  41721. /**
  41722. * Display the property inspector
  41723. */
  41724. showInspector?: boolean;
  41725. /**
  41726. * Display in embed mode (both panes on the right)
  41727. */
  41728. embedMode?: boolean;
  41729. /**
  41730. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41731. */
  41732. handleResize?: boolean;
  41733. /**
  41734. * Allow the panes to popup (default: true)
  41735. */
  41736. enablePopup?: boolean;
  41737. /**
  41738. * Allow the panes to be closed by users (default: true)
  41739. */
  41740. enableClose?: boolean;
  41741. /**
  41742. * Optional list of extensibility entries
  41743. */
  41744. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41745. }
  41746. module "babylonjs/scene" {
  41747. interface Scene {
  41748. /**
  41749. * @hidden
  41750. * Backing field
  41751. */
  41752. _debugLayer: DebugLayer;
  41753. /**
  41754. * Gets the debug layer (aka Inspector) associated with the scene
  41755. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41756. */
  41757. debugLayer: DebugLayer;
  41758. }
  41759. }
  41760. /**
  41761. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41762. * what is happening in your scene
  41763. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41764. */
  41765. export class DebugLayer {
  41766. /**
  41767. * Define the url to get the inspector script from.
  41768. * By default it uses the babylonjs CDN.
  41769. * @ignoreNaming
  41770. */
  41771. static InspectorURL: string;
  41772. private _scene;
  41773. private BJSINSPECTOR;
  41774. /**
  41775. * Observable triggered when a property is changed through the inspector.
  41776. */
  41777. onPropertyChangedObservable: Observable<{
  41778. object: any;
  41779. property: string;
  41780. value: any;
  41781. initialValue: any;
  41782. }>;
  41783. /**
  41784. * Instantiates a new debug layer.
  41785. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41786. * what is happening in your scene
  41787. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41788. * @param scene Defines the scene to inspect
  41789. */
  41790. constructor(scene: Scene);
  41791. /** Creates the inspector window. */
  41792. private _createInspector;
  41793. /** Get the inspector from bundle or global */
  41794. private _getGlobalInspector;
  41795. /**
  41796. * Get if the inspector is visible or not.
  41797. * @returns true if visible otherwise, false
  41798. */
  41799. isVisible(): boolean;
  41800. /**
  41801. * Hide the inspector and close its window.
  41802. */
  41803. hide(): void;
  41804. /**
  41805. * Launch the debugLayer.
  41806. * @param config Define the configuration of the inspector
  41807. */
  41808. show(config?: IInspectorOptions): void;
  41809. }
  41810. }
  41811. declare module "babylonjs/Debug/physicsViewer" {
  41812. import { Nullable } from "babylonjs/types";
  41813. import { Scene } from "babylonjs/scene";
  41814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41815. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41816. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41817. /**
  41818. * Used to show the physics impostor around the specific mesh
  41819. */
  41820. export class PhysicsViewer {
  41821. /** @hidden */
  41822. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41823. /** @hidden */
  41824. protected _meshes: Array<Nullable<AbstractMesh>>;
  41825. /** @hidden */
  41826. protected _scene: Nullable<Scene>;
  41827. /** @hidden */
  41828. protected _numMeshes: number;
  41829. /** @hidden */
  41830. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41831. private _renderFunction;
  41832. private _utilityLayer;
  41833. private _debugBoxMesh;
  41834. private _debugSphereMesh;
  41835. private _debugMaterial;
  41836. /**
  41837. * Creates a new PhysicsViewer
  41838. * @param scene defines the hosting scene
  41839. */
  41840. constructor(scene: Scene);
  41841. /** @hidden */
  41842. protected _updateDebugMeshes(): void;
  41843. /**
  41844. * Renders a specified physic impostor
  41845. * @param impostor defines the impostor to render
  41846. * @returns the new debug mesh used to render the impostor
  41847. */
  41848. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41849. /**
  41850. * Hides a specified physic impostor
  41851. * @param impostor defines the impostor to hide
  41852. */
  41853. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41854. private _getDebugMaterial;
  41855. private _getDebugBoxMesh;
  41856. private _getDebugSphereMesh;
  41857. private _getDebugMesh;
  41858. /** Releases all resources */
  41859. dispose(): void;
  41860. }
  41861. }
  41862. declare module "babylonjs/Debug/rayHelper" {
  41863. import { Nullable } from "babylonjs/types";
  41864. import { Ray } from "babylonjs/Culling/ray";
  41865. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41866. import { Scene } from "babylonjs/scene";
  41867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41868. /**
  41869. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41870. * in order to better appreciate the issue one might have.
  41871. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41872. */
  41873. export class RayHelper {
  41874. /**
  41875. * Defines the ray we are currently tryin to visualize.
  41876. */
  41877. ray: Nullable<Ray>;
  41878. private _renderPoints;
  41879. private _renderLine;
  41880. private _renderFunction;
  41881. private _scene;
  41882. private _updateToMeshFunction;
  41883. private _attachedToMesh;
  41884. private _meshSpaceDirection;
  41885. private _meshSpaceOrigin;
  41886. /**
  41887. * Helper function to create a colored helper in a scene in one line.
  41888. * @param ray Defines the ray we are currently tryin to visualize
  41889. * @param scene Defines the scene the ray is used in
  41890. * @param color Defines the color we want to see the ray in
  41891. * @returns The newly created ray helper.
  41892. */
  41893. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41894. /**
  41895. * Instantiate a new ray helper.
  41896. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41897. * in order to better appreciate the issue one might have.
  41898. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41899. * @param ray Defines the ray we are currently tryin to visualize
  41900. */
  41901. constructor(ray: Ray);
  41902. /**
  41903. * Shows the ray we are willing to debug.
  41904. * @param scene Defines the scene the ray needs to be rendered in
  41905. * @param color Defines the color the ray needs to be rendered in
  41906. */
  41907. show(scene: Scene, color?: Color3): void;
  41908. /**
  41909. * Hides the ray we are debugging.
  41910. */
  41911. hide(): void;
  41912. private _render;
  41913. /**
  41914. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41915. * @param mesh Defines the mesh we want the helper attached to
  41916. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41917. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41918. * @param length Defines the length of the ray
  41919. */
  41920. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41921. /**
  41922. * Detach the ray helper from the mesh it has previously been attached to.
  41923. */
  41924. detachFromMesh(): void;
  41925. private _updateToMesh;
  41926. /**
  41927. * Dispose the helper and release its associated resources.
  41928. */
  41929. dispose(): void;
  41930. }
  41931. }
  41932. declare module "babylonjs/Debug/skeletonViewer" {
  41933. import { Color3 } from "babylonjs/Maths/math";
  41934. import { Scene } from "babylonjs/scene";
  41935. import { Nullable } from "babylonjs/types";
  41936. import { Skeleton } from "babylonjs/Bones/skeleton";
  41937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41938. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41939. /**
  41940. * Class used to render a debug view of a given skeleton
  41941. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41942. */
  41943. export class SkeletonViewer {
  41944. /** defines the skeleton to render */
  41945. skeleton: Skeleton;
  41946. /** defines the mesh attached to the skeleton */
  41947. mesh: AbstractMesh;
  41948. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41949. autoUpdateBonesMatrices: boolean;
  41950. /** defines the rendering group id to use with the viewer */
  41951. renderingGroupId: number;
  41952. /** Gets or sets the color used to render the skeleton */
  41953. color: Color3;
  41954. private _scene;
  41955. private _debugLines;
  41956. private _debugMesh;
  41957. private _isEnabled;
  41958. private _renderFunction;
  41959. private _utilityLayer;
  41960. /**
  41961. * Returns the mesh used to render the bones
  41962. */
  41963. readonly debugMesh: Nullable<LinesMesh>;
  41964. /**
  41965. * Creates a new SkeletonViewer
  41966. * @param skeleton defines the skeleton to render
  41967. * @param mesh defines the mesh attached to the skeleton
  41968. * @param scene defines the hosting scene
  41969. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41970. * @param renderingGroupId defines the rendering group id to use with the viewer
  41971. */
  41972. constructor(
  41973. /** defines the skeleton to render */
  41974. skeleton: Skeleton,
  41975. /** defines the mesh attached to the skeleton */
  41976. mesh: AbstractMesh, scene: Scene,
  41977. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41978. autoUpdateBonesMatrices?: boolean,
  41979. /** defines the rendering group id to use with the viewer */
  41980. renderingGroupId?: number);
  41981. /** Gets or sets a boolean indicating if the viewer is enabled */
  41982. isEnabled: boolean;
  41983. private _getBonePosition;
  41984. private _getLinesForBonesWithLength;
  41985. private _getLinesForBonesNoLength;
  41986. /** Update the viewer to sync with current skeleton state */
  41987. update(): void;
  41988. /** Release associated resources */
  41989. dispose(): void;
  41990. }
  41991. }
  41992. declare module "babylonjs/Debug/index" {
  41993. export * from "babylonjs/Debug/axesViewer";
  41994. export * from "babylonjs/Debug/boneAxesViewer";
  41995. export * from "babylonjs/Debug/debugLayer";
  41996. export * from "babylonjs/Debug/physicsViewer";
  41997. export * from "babylonjs/Debug/rayHelper";
  41998. export * from "babylonjs/Debug/skeletonViewer";
  41999. }
  42000. declare module "babylonjs/Engines/nullEngine" {
  42001. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42002. import { Scene } from "babylonjs/scene";
  42003. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42004. import { Engine } from "babylonjs/Engines/engine";
  42005. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42006. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42008. import { Effect } from "babylonjs/Materials/effect";
  42009. /**
  42010. * Options to create the null engine
  42011. */
  42012. export class NullEngineOptions {
  42013. /**
  42014. * Render width (Default: 512)
  42015. */
  42016. renderWidth: number;
  42017. /**
  42018. * Render height (Default: 256)
  42019. */
  42020. renderHeight: number;
  42021. /**
  42022. * Texture size (Default: 512)
  42023. */
  42024. textureSize: number;
  42025. /**
  42026. * If delta time between frames should be constant
  42027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42028. */
  42029. deterministicLockstep: boolean;
  42030. /**
  42031. * Maximum about of steps between frames (Default: 4)
  42032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42033. */
  42034. lockstepMaxSteps: number;
  42035. }
  42036. /**
  42037. * The null engine class provides support for headless version of babylon.js.
  42038. * This can be used in server side scenario or for testing purposes
  42039. */
  42040. export class NullEngine extends Engine {
  42041. private _options;
  42042. /**
  42043. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42044. */
  42045. isDeterministicLockStep(): boolean;
  42046. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42047. getLockstepMaxSteps(): number;
  42048. /**
  42049. * Sets hardware scaling, used to save performance if needed
  42050. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42051. */
  42052. getHardwareScalingLevel(): number;
  42053. constructor(options?: NullEngineOptions);
  42054. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42055. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42056. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42057. getRenderWidth(useScreen?: boolean): number;
  42058. getRenderHeight(useScreen?: boolean): number;
  42059. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42060. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42061. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42062. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42063. bindSamplers(effect: Effect): void;
  42064. enableEffect(effect: Effect): void;
  42065. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42066. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42067. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42068. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42069. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42070. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42071. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42072. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42073. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42074. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42075. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42076. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42077. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42078. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42079. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42080. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42081. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42082. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42083. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42084. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42085. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42086. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42087. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42088. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42089. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42090. bindBuffers(vertexBuffers: {
  42091. [key: string]: VertexBuffer;
  42092. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42093. wipeCaches(bruteForce?: boolean): void;
  42094. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42095. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42096. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42097. /** @hidden */
  42098. _createTexture(): WebGLTexture;
  42099. /** @hidden */
  42100. _releaseTexture(texture: InternalTexture): void;
  42101. 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;
  42102. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42103. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42104. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42105. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42106. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42108. areAllEffectsReady(): boolean;
  42109. /**
  42110. * @hidden
  42111. * Get the current error code of the webGL context
  42112. * @returns the error code
  42113. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42114. */
  42115. getError(): number;
  42116. /** @hidden */
  42117. _getUnpackAlignement(): number;
  42118. /** @hidden */
  42119. _unpackFlipY(value: boolean): void;
  42120. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42121. /**
  42122. * Updates a dynamic vertex buffer.
  42123. * @param vertexBuffer the vertex buffer to update
  42124. * @param data the data used to update the vertex buffer
  42125. * @param byteOffset the byte offset of the data (optional)
  42126. * @param byteLength the byte length of the data (optional)
  42127. */
  42128. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42129. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42130. /** @hidden */
  42131. _bindTexture(channel: number, texture: InternalTexture): void;
  42132. /** @hidden */
  42133. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42134. releaseEffects(): void;
  42135. displayLoadingUI(): void;
  42136. hideLoadingUI(): void;
  42137. /** @hidden */
  42138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42139. /** @hidden */
  42140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42141. /** @hidden */
  42142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42143. /** @hidden */
  42144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42145. }
  42146. }
  42147. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42148. import { Nullable, int } from "babylonjs/types";
  42149. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42150. /** @hidden */
  42151. export class _OcclusionDataStorage {
  42152. /** @hidden */
  42153. occlusionInternalRetryCounter: number;
  42154. /** @hidden */
  42155. isOcclusionQueryInProgress: boolean;
  42156. /** @hidden */
  42157. isOccluded: boolean;
  42158. /** @hidden */
  42159. occlusionRetryCount: number;
  42160. /** @hidden */
  42161. occlusionType: number;
  42162. /** @hidden */
  42163. occlusionQueryAlgorithmType: number;
  42164. }
  42165. module "babylonjs/Engines/engine" {
  42166. interface Engine {
  42167. /**
  42168. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42169. * @return the new query
  42170. */
  42171. createQuery(): WebGLQuery;
  42172. /**
  42173. * Delete and release a webGL query
  42174. * @param query defines the query to delete
  42175. * @return the current engine
  42176. */
  42177. deleteQuery(query: WebGLQuery): Engine;
  42178. /**
  42179. * Check if a given query has resolved and got its value
  42180. * @param query defines the query to check
  42181. * @returns true if the query got its value
  42182. */
  42183. isQueryResultAvailable(query: WebGLQuery): boolean;
  42184. /**
  42185. * Gets the value of a given query
  42186. * @param query defines the query to check
  42187. * @returns the value of the query
  42188. */
  42189. getQueryResult(query: WebGLQuery): number;
  42190. /**
  42191. * Initiates an occlusion query
  42192. * @param algorithmType defines the algorithm to use
  42193. * @param query defines the query to use
  42194. * @returns the current engine
  42195. * @see http://doc.babylonjs.com/features/occlusionquery
  42196. */
  42197. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42198. /**
  42199. * Ends an occlusion query
  42200. * @see http://doc.babylonjs.com/features/occlusionquery
  42201. * @param algorithmType defines the algorithm to use
  42202. * @returns the current engine
  42203. */
  42204. endOcclusionQuery(algorithmType: number): Engine;
  42205. /**
  42206. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42207. * Please note that only one query can be issued at a time
  42208. * @returns a time token used to track the time span
  42209. */
  42210. startTimeQuery(): Nullable<_TimeToken>;
  42211. /**
  42212. * Ends a time query
  42213. * @param token defines the token used to measure the time span
  42214. * @returns the time spent (in ns)
  42215. */
  42216. endTimeQuery(token: _TimeToken): int;
  42217. /** @hidden */
  42218. _currentNonTimestampToken: Nullable<_TimeToken>;
  42219. /** @hidden */
  42220. _createTimeQuery(): WebGLQuery;
  42221. /** @hidden */
  42222. _deleteTimeQuery(query: WebGLQuery): void;
  42223. /** @hidden */
  42224. _getGlAlgorithmType(algorithmType: number): number;
  42225. /** @hidden */
  42226. _getTimeQueryResult(query: WebGLQuery): any;
  42227. /** @hidden */
  42228. _getTimeQueryAvailability(query: WebGLQuery): any;
  42229. }
  42230. }
  42231. module "babylonjs/Meshes/abstractMesh" {
  42232. interface AbstractMesh {
  42233. /**
  42234. * Backing filed
  42235. * @hidden
  42236. */
  42237. __occlusionDataStorage: _OcclusionDataStorage;
  42238. /**
  42239. * Access property
  42240. * @hidden
  42241. */
  42242. _occlusionDataStorage: _OcclusionDataStorage;
  42243. /**
  42244. * 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.
  42245. * The default value is -1 which means don't break the query and wait till the result
  42246. * @see http://doc.babylonjs.com/features/occlusionquery
  42247. */
  42248. occlusionRetryCount: number;
  42249. /**
  42250. * 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:
  42251. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42252. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42253. * * 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.
  42254. * @see http://doc.babylonjs.com/features/occlusionquery
  42255. */
  42256. occlusionType: number;
  42257. /**
  42258. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42259. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42260. * * 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.
  42261. * @see http://doc.babylonjs.com/features/occlusionquery
  42262. */
  42263. occlusionQueryAlgorithmType: number;
  42264. /**
  42265. * 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
  42266. * @see http://doc.babylonjs.com/features/occlusionquery
  42267. */
  42268. isOccluded: boolean;
  42269. /**
  42270. * Flag to check the progress status of the query
  42271. * @see http://doc.babylonjs.com/features/occlusionquery
  42272. */
  42273. isOcclusionQueryInProgress: boolean;
  42274. }
  42275. }
  42276. }
  42277. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42278. import { Nullable } from "babylonjs/types";
  42279. /** @hidden */
  42280. export var _forceTransformFeedbackToBundle: boolean;
  42281. module "babylonjs/Engines/engine" {
  42282. interface Engine {
  42283. /**
  42284. * Creates a webGL transform feedback object
  42285. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42286. * @returns the webGL transform feedback object
  42287. */
  42288. createTransformFeedback(): WebGLTransformFeedback;
  42289. /**
  42290. * Delete a webGL transform feedback object
  42291. * @param value defines the webGL transform feedback object to delete
  42292. */
  42293. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42294. /**
  42295. * Bind a webGL transform feedback object to the webgl context
  42296. * @param value defines the webGL transform feedback object to bind
  42297. */
  42298. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42299. /**
  42300. * Begins a transform feedback operation
  42301. * @param usePoints defines if points or triangles must be used
  42302. */
  42303. beginTransformFeedback(usePoints: boolean): void;
  42304. /**
  42305. * Ends a transform feedback operation
  42306. */
  42307. endTransformFeedback(): void;
  42308. /**
  42309. * Specify the varyings to use with transform feedback
  42310. * @param program defines the associated webGL program
  42311. * @param value defines the list of strings representing the varying names
  42312. */
  42313. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42314. /**
  42315. * Bind a webGL buffer for a transform feedback operation
  42316. * @param value defines the webGL buffer to bind
  42317. */
  42318. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42319. }
  42320. }
  42321. }
  42322. declare module "babylonjs/Engines/Extensions/index" {
  42323. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42324. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42325. }
  42326. declare module "babylonjs/Engines/index" {
  42327. export * from "babylonjs/Engines/constants";
  42328. export * from "babylonjs/Engines/engine";
  42329. export * from "babylonjs/Engines/engineStore";
  42330. export * from "babylonjs/Engines/nullEngine";
  42331. export * from "babylonjs/Engines/Extensions/index";
  42332. }
  42333. declare module "babylonjs/Events/clipboardEvents" {
  42334. /**
  42335. * Gather the list of clipboard event types as constants.
  42336. */
  42337. export class ClipboardEventTypes {
  42338. /**
  42339. * The clipboard event is fired when a copy command is active (pressed).
  42340. */
  42341. static readonly COPY: number;
  42342. /**
  42343. * The clipboard event is fired when a cut command is active (pressed).
  42344. */
  42345. static readonly CUT: number;
  42346. /**
  42347. * The clipboard event is fired when a paste command is active (pressed).
  42348. */
  42349. static readonly PASTE: number;
  42350. }
  42351. /**
  42352. * This class is used to store clipboard related info for the onClipboardObservable event.
  42353. */
  42354. export class ClipboardInfo {
  42355. /**
  42356. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42357. */
  42358. type: number;
  42359. /**
  42360. * Defines the related dom event
  42361. */
  42362. event: ClipboardEvent;
  42363. /**
  42364. *Creates an instance of ClipboardInfo.
  42365. * @param {number} type
  42366. * @param {ClipboardEvent} event
  42367. */
  42368. constructor(
  42369. /**
  42370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42371. */
  42372. type: number,
  42373. /**
  42374. * Defines the related dom event
  42375. */
  42376. event: ClipboardEvent);
  42377. /**
  42378. * Get the clipboard event's type from the keycode.
  42379. * @param keyCode Defines the keyCode for the current keyboard event.
  42380. * @return {number}
  42381. */
  42382. static GetTypeFromCharacter(keyCode: number): number;
  42383. }
  42384. }
  42385. declare module "babylonjs/Events/index" {
  42386. export * from "babylonjs/Events/keyboardEvents";
  42387. export * from "babylonjs/Events/pointerEvents";
  42388. export * from "babylonjs/Events/clipboardEvents";
  42389. }
  42390. declare module "babylonjs/Loading/sceneLoader" {
  42391. import { Observable } from "babylonjs/Misc/observable";
  42392. import { Nullable } from "babylonjs/types";
  42393. import { Scene } from "babylonjs/scene";
  42394. import { Engine } from "babylonjs/Engines/engine";
  42395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42396. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42397. import { AssetContainer } from "babylonjs/assetContainer";
  42398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42399. import { Skeleton } from "babylonjs/Bones/skeleton";
  42400. /**
  42401. * Class used to represent data loading progression
  42402. */
  42403. export class SceneLoaderProgressEvent {
  42404. /** defines if data length to load can be evaluated */
  42405. readonly lengthComputable: boolean;
  42406. /** defines the loaded data length */
  42407. readonly loaded: number;
  42408. /** defines the data length to load */
  42409. readonly total: number;
  42410. /**
  42411. * Create a new progress event
  42412. * @param lengthComputable defines if data length to load can be evaluated
  42413. * @param loaded defines the loaded data length
  42414. * @param total defines the data length to load
  42415. */
  42416. constructor(
  42417. /** defines if data length to load can be evaluated */
  42418. lengthComputable: boolean,
  42419. /** defines the loaded data length */
  42420. loaded: number,
  42421. /** defines the data length to load */
  42422. total: number);
  42423. /**
  42424. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42425. * @param event defines the source event
  42426. * @returns a new SceneLoaderProgressEvent
  42427. */
  42428. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42429. }
  42430. /**
  42431. * Interface used by SceneLoader plugins to define supported file extensions
  42432. */
  42433. export interface ISceneLoaderPluginExtensions {
  42434. /**
  42435. * Defines the list of supported extensions
  42436. */
  42437. [extension: string]: {
  42438. isBinary: boolean;
  42439. };
  42440. }
  42441. /**
  42442. * Interface used by SceneLoader plugin factory
  42443. */
  42444. export interface ISceneLoaderPluginFactory {
  42445. /**
  42446. * Defines the name of the factory
  42447. */
  42448. name: string;
  42449. /**
  42450. * Function called to create a new plugin
  42451. * @return the new plugin
  42452. */
  42453. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42454. /**
  42455. * Boolean indicating if the plugin can direct load specific data
  42456. */
  42457. canDirectLoad?: (data: string) => boolean;
  42458. }
  42459. /**
  42460. * Interface used to define a SceneLoader plugin
  42461. */
  42462. export interface ISceneLoaderPlugin {
  42463. /**
  42464. * The friendly name of this plugin.
  42465. */
  42466. name: string;
  42467. /**
  42468. * The file extensions supported by this plugin.
  42469. */
  42470. extensions: string | ISceneLoaderPluginExtensions;
  42471. /**
  42472. * Import meshes into a scene.
  42473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42474. * @param scene The scene to import into
  42475. * @param data The data to import
  42476. * @param rootUrl The root url for scene and resources
  42477. * @param meshes The meshes array to import into
  42478. * @param particleSystems The particle systems array to import into
  42479. * @param skeletons The skeletons array to import into
  42480. * @param onError The callback when import fails
  42481. * @returns True if successful or false otherwise
  42482. */
  42483. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42484. /**
  42485. * Load into a scene.
  42486. * @param scene The scene to load into
  42487. * @param data The data to import
  42488. * @param rootUrl The root url for scene and resources
  42489. * @param onError The callback when import fails
  42490. * @returns true if successful or false otherwise
  42491. */
  42492. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42493. /**
  42494. * The callback that returns true if the data can be directly loaded.
  42495. */
  42496. canDirectLoad?: (data: string) => boolean;
  42497. /**
  42498. * The callback that allows custom handling of the root url based on the response url.
  42499. */
  42500. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42501. /**
  42502. * Load into an asset container.
  42503. * @param scene The scene to load into
  42504. * @param data The data to import
  42505. * @param rootUrl The root url for scene and resources
  42506. * @param onError The callback when import fails
  42507. * @returns The loaded asset container
  42508. */
  42509. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42510. }
  42511. /**
  42512. * Interface used to define an async SceneLoader plugin
  42513. */
  42514. export interface ISceneLoaderPluginAsync {
  42515. /**
  42516. * The friendly name of this plugin.
  42517. */
  42518. name: string;
  42519. /**
  42520. * The file extensions supported by this plugin.
  42521. */
  42522. extensions: string | ISceneLoaderPluginExtensions;
  42523. /**
  42524. * Import meshes into a scene.
  42525. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42526. * @param scene The scene to import into
  42527. * @param data The data to import
  42528. * @param rootUrl The root url for scene and resources
  42529. * @param onProgress The callback when the load progresses
  42530. * @param fileName Defines the name of the file to load
  42531. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42532. */
  42533. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42534. meshes: AbstractMesh[];
  42535. particleSystems: IParticleSystem[];
  42536. skeletons: Skeleton[];
  42537. animationGroups: AnimationGroup[];
  42538. }>;
  42539. /**
  42540. * Load into a scene.
  42541. * @param scene The scene to load into
  42542. * @param data The data to import
  42543. * @param rootUrl The root url for scene and resources
  42544. * @param onProgress The callback when the load progresses
  42545. * @param fileName Defines the name of the file to load
  42546. * @returns Nothing
  42547. */
  42548. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42549. /**
  42550. * The callback that returns true if the data can be directly loaded.
  42551. */
  42552. canDirectLoad?: (data: string) => boolean;
  42553. /**
  42554. * The callback that allows custom handling of the root url based on the response url.
  42555. */
  42556. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42557. /**
  42558. * Load into an asset container.
  42559. * @param scene The scene to load into
  42560. * @param data The data to import
  42561. * @param rootUrl The root url for scene and resources
  42562. * @param onProgress The callback when the load progresses
  42563. * @param fileName Defines the name of the file to load
  42564. * @returns The loaded asset container
  42565. */
  42566. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42567. }
  42568. /**
  42569. * Class used to load scene from various file formats using registered plugins
  42570. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42571. */
  42572. export class SceneLoader {
  42573. /**
  42574. * No logging while loading
  42575. */
  42576. static readonly NO_LOGGING: number;
  42577. /**
  42578. * Minimal logging while loading
  42579. */
  42580. static readonly MINIMAL_LOGGING: number;
  42581. /**
  42582. * Summary logging while loading
  42583. */
  42584. static readonly SUMMARY_LOGGING: number;
  42585. /**
  42586. * Detailled logging while loading
  42587. */
  42588. static readonly DETAILED_LOGGING: number;
  42589. /**
  42590. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42591. */
  42592. static ForceFullSceneLoadingForIncremental: boolean;
  42593. /**
  42594. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42595. */
  42596. static ShowLoadingScreen: boolean;
  42597. /**
  42598. * Defines the current logging level (while loading the scene)
  42599. * @ignorenaming
  42600. */
  42601. static loggingLevel: number;
  42602. /**
  42603. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42604. */
  42605. static CleanBoneMatrixWeights: boolean;
  42606. /**
  42607. * Event raised when a plugin is used to load a scene
  42608. */
  42609. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42610. private static _registeredPlugins;
  42611. private static _getDefaultPlugin;
  42612. private static _getPluginForExtension;
  42613. private static _getPluginForDirectLoad;
  42614. private static _getPluginForFilename;
  42615. private static _getDirectLoad;
  42616. private static _loadData;
  42617. private static _getFileInfo;
  42618. /**
  42619. * Gets a plugin that can load the given extension
  42620. * @param extension defines the extension to load
  42621. * @returns a plugin or null if none works
  42622. */
  42623. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42624. /**
  42625. * Gets a boolean indicating that the given extension can be loaded
  42626. * @param extension defines the extension to load
  42627. * @returns true if the extension is supported
  42628. */
  42629. static IsPluginForExtensionAvailable(extension: string): boolean;
  42630. /**
  42631. * Adds a new plugin to the list of registered plugins
  42632. * @param plugin defines the plugin to add
  42633. */
  42634. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42635. /**
  42636. * Import meshes into a scene
  42637. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42638. * @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)
  42639. * @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)
  42640. * @param scene the instance of BABYLON.Scene to append to
  42641. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42642. * @param onProgress a callback with a progress event for each file being loaded
  42643. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42644. * @param pluginExtension the extension used to determine the plugin
  42645. * @returns The loaded plugin
  42646. */
  42647. 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>;
  42648. /**
  42649. * Import meshes into a scene
  42650. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42651. * @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)
  42652. * @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)
  42653. * @param scene the instance of BABYLON.Scene to append to
  42654. * @param onProgress a callback with a progress event for each file being loaded
  42655. * @param pluginExtension the extension used to determine the plugin
  42656. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42657. */
  42658. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42659. meshes: AbstractMesh[];
  42660. particleSystems: IParticleSystem[];
  42661. skeletons: Skeleton[];
  42662. animationGroups: AnimationGroup[];
  42663. }>;
  42664. /**
  42665. * Load a scene
  42666. * @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)
  42667. * @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)
  42668. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42669. * @param onSuccess a callback with the scene when import succeeds
  42670. * @param onProgress a callback with a progress event for each file being loaded
  42671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42672. * @param pluginExtension the extension used to determine the plugin
  42673. * @returns The loaded plugin
  42674. */
  42675. 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>;
  42676. /**
  42677. * Load a scene
  42678. * @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)
  42679. * @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)
  42680. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42681. * @param onProgress a callback with a progress event for each file being loaded
  42682. * @param pluginExtension the extension used to determine the plugin
  42683. * @returns The loaded scene
  42684. */
  42685. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42686. /**
  42687. * Append a scene
  42688. * @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)
  42689. * @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)
  42690. * @param scene is the instance of BABYLON.Scene to append to
  42691. * @param onSuccess a callback with the scene when import succeeds
  42692. * @param onProgress a callback with a progress event for each file being loaded
  42693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42694. * @param pluginExtension the extension used to determine the plugin
  42695. * @returns The loaded plugin
  42696. */
  42697. 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>;
  42698. /**
  42699. * Append a scene
  42700. * @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)
  42701. * @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)
  42702. * @param scene is the instance of BABYLON.Scene to append to
  42703. * @param onProgress a callback with a progress event for each file being loaded
  42704. * @param pluginExtension the extension used to determine the plugin
  42705. * @returns The given scene
  42706. */
  42707. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42708. /**
  42709. * Load a scene into an asset container
  42710. * @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)
  42711. * @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)
  42712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42713. * @param onSuccess a callback with the scene when import succeeds
  42714. * @param onProgress a callback with a progress event for each file being loaded
  42715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42716. * @param pluginExtension the extension used to determine the plugin
  42717. * @returns The loaded plugin
  42718. */
  42719. 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>;
  42720. /**
  42721. * Load a scene into an asset container
  42722. * @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)
  42723. * @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)
  42724. * @param scene is the instance of Scene to append to
  42725. * @param onProgress a callback with a progress event for each file being loaded
  42726. * @param pluginExtension the extension used to determine the plugin
  42727. * @returns The loaded asset container
  42728. */
  42729. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42730. }
  42731. }
  42732. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42733. import { Scene } from "babylonjs/scene";
  42734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42735. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42736. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42737. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42738. /**
  42739. * Google Daydream controller
  42740. */
  42741. export class DaydreamController extends WebVRController {
  42742. /**
  42743. * Base Url for the controller model.
  42744. */
  42745. static MODEL_BASE_URL: string;
  42746. /**
  42747. * File name for the controller model.
  42748. */
  42749. static MODEL_FILENAME: string;
  42750. /**
  42751. * Gamepad Id prefix used to identify Daydream Controller.
  42752. */
  42753. static readonly GAMEPAD_ID_PREFIX: string;
  42754. /**
  42755. * Creates a new DaydreamController from a gamepad
  42756. * @param vrGamepad the gamepad that the controller should be created from
  42757. */
  42758. constructor(vrGamepad: any);
  42759. /**
  42760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42761. * @param scene scene in which to add meshes
  42762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42763. */
  42764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42765. /**
  42766. * Called once for each button that changed state since the last frame
  42767. * @param buttonIdx Which button index changed
  42768. * @param state New state of the button
  42769. * @param changes Which properties on the state changed since last frame
  42770. */
  42771. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42772. }
  42773. }
  42774. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42775. import { Scene } from "babylonjs/scene";
  42776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42777. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42780. /**
  42781. * Gear VR Controller
  42782. */
  42783. export class GearVRController extends WebVRController {
  42784. /**
  42785. * Base Url for the controller model.
  42786. */
  42787. static MODEL_BASE_URL: string;
  42788. /**
  42789. * File name for the controller model.
  42790. */
  42791. static MODEL_FILENAME: string;
  42792. /**
  42793. * Gamepad Id prefix used to identify this controller.
  42794. */
  42795. static readonly GAMEPAD_ID_PREFIX: string;
  42796. private readonly _buttonIndexToObservableNameMap;
  42797. /**
  42798. * Creates a new GearVRController from a gamepad
  42799. * @param vrGamepad the gamepad that the controller should be created from
  42800. */
  42801. constructor(vrGamepad: any);
  42802. /**
  42803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42804. * @param scene scene in which to add meshes
  42805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42806. */
  42807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42808. /**
  42809. * Called once for each button that changed state since the last frame
  42810. * @param buttonIdx Which button index changed
  42811. * @param state New state of the button
  42812. * @param changes Which properties on the state changed since last frame
  42813. */
  42814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42815. }
  42816. }
  42817. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42818. import { Scene } from "babylonjs/scene";
  42819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42820. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42821. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42822. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42823. /**
  42824. * Generic Controller
  42825. */
  42826. export class GenericController extends WebVRController {
  42827. /**
  42828. * Base Url for the controller model.
  42829. */
  42830. static readonly MODEL_BASE_URL: string;
  42831. /**
  42832. * File name for the controller model.
  42833. */
  42834. static readonly MODEL_FILENAME: string;
  42835. /**
  42836. * Creates a new GenericController from a gamepad
  42837. * @param vrGamepad the gamepad that the controller should be created from
  42838. */
  42839. constructor(vrGamepad: any);
  42840. /**
  42841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42842. * @param scene scene in which to add meshes
  42843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42844. */
  42845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): 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. }
  42855. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42856. import { Observable } from "babylonjs/Misc/observable";
  42857. import { Scene } from "babylonjs/scene";
  42858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42859. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42860. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42861. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42862. /**
  42863. * Oculus Touch Controller
  42864. */
  42865. export class OculusTouchController extends WebVRController {
  42866. /**
  42867. * Base Url for the controller model.
  42868. */
  42869. static MODEL_BASE_URL: string;
  42870. /**
  42871. * File name for the left controller model.
  42872. */
  42873. static MODEL_LEFT_FILENAME: string;
  42874. /**
  42875. * File name for the right controller model.
  42876. */
  42877. static MODEL_RIGHT_FILENAME: string;
  42878. /**
  42879. * Fired when the secondary trigger on this controller is modified
  42880. */
  42881. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42882. /**
  42883. * Fired when the thumb rest on this controller is modified
  42884. */
  42885. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42886. /**
  42887. * Creates a new OculusTouchController from a gamepad
  42888. * @param vrGamepad the gamepad that the controller should be created from
  42889. */
  42890. constructor(vrGamepad: any);
  42891. /**
  42892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42893. * @param scene scene in which to add meshes
  42894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42895. */
  42896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42897. /**
  42898. * Fired when the A button on this controller is modified
  42899. */
  42900. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42901. /**
  42902. * Fired when the B button on this controller is modified
  42903. */
  42904. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42905. /**
  42906. * Fired when the X button on this controller is modified
  42907. */
  42908. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42909. /**
  42910. * Fired when the Y button on this controller is modified
  42911. */
  42912. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42913. /**
  42914. * Called once for each button that changed state since the last frame
  42915. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42916. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42917. * 2) secondary trigger (same)
  42918. * 3) A (right) X (left), touch, pressed = value
  42919. * 4) B / Y
  42920. * 5) thumb rest
  42921. * @param buttonIdx Which button index changed
  42922. * @param state New state of the button
  42923. * @param changes Which properties on the state changed since last frame
  42924. */
  42925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42926. }
  42927. }
  42928. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42929. import { Scene } from "babylonjs/scene";
  42930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42931. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42932. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42933. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42934. import { Observable } from "babylonjs/Misc/observable";
  42935. /**
  42936. * Vive Controller
  42937. */
  42938. export class ViveController extends WebVRController {
  42939. /**
  42940. * Base Url for the controller model.
  42941. */
  42942. static MODEL_BASE_URL: string;
  42943. /**
  42944. * File name for the controller model.
  42945. */
  42946. static MODEL_FILENAME: string;
  42947. /**
  42948. * Creates a new ViveController from a gamepad
  42949. * @param vrGamepad the gamepad that the controller should be created from
  42950. */
  42951. constructor(vrGamepad: any);
  42952. /**
  42953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42954. * @param scene scene in which to add meshes
  42955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42956. */
  42957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42958. /**
  42959. * Fired when the left button on this controller is modified
  42960. */
  42961. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42962. /**
  42963. * Fired when the right button on this controller is modified
  42964. */
  42965. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42966. /**
  42967. * Fired when the menu button on this controller is modified
  42968. */
  42969. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42970. /**
  42971. * Called once for each button that changed state since the last frame
  42972. * Vive mapping:
  42973. * 0: touchpad
  42974. * 1: trigger
  42975. * 2: left AND right buttons
  42976. * 3: menu button
  42977. * @param buttonIdx Which button index changed
  42978. * @param state New state of the button
  42979. * @param changes Which properties on the state changed since last frame
  42980. */
  42981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42982. }
  42983. }
  42984. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42985. import { Observable } from "babylonjs/Misc/observable";
  42986. import { Scene } from "babylonjs/scene";
  42987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42988. import { Ray } from "babylonjs/Culling/ray";
  42989. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42990. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42991. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42992. /**
  42993. * Defines the WindowsMotionController object that the state of the windows motion controller
  42994. */
  42995. export class WindowsMotionController extends WebVRController {
  42996. /**
  42997. * The base url used to load the left and right controller models
  42998. */
  42999. static MODEL_BASE_URL: string;
  43000. /**
  43001. * The name of the left controller model file
  43002. */
  43003. static MODEL_LEFT_FILENAME: string;
  43004. /**
  43005. * The name of the right controller model file
  43006. */
  43007. static MODEL_RIGHT_FILENAME: string;
  43008. /**
  43009. * The controller name prefix for this controller type
  43010. */
  43011. static readonly GAMEPAD_ID_PREFIX: string;
  43012. /**
  43013. * The controller id pattern for this controller type
  43014. */
  43015. private static readonly GAMEPAD_ID_PATTERN;
  43016. private _loadedMeshInfo;
  43017. private readonly _mapping;
  43018. /**
  43019. * Fired when the trackpad on this controller is clicked
  43020. */
  43021. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43022. /**
  43023. * Fired when the trackpad on this controller is modified
  43024. */
  43025. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43026. /**
  43027. * The current x and y values of this controller's trackpad
  43028. */
  43029. trackpad: StickValues;
  43030. /**
  43031. * Creates a new WindowsMotionController from a gamepad
  43032. * @param vrGamepad the gamepad that the controller should be created from
  43033. */
  43034. constructor(vrGamepad: any);
  43035. /**
  43036. * Fired when the trigger on this controller is modified
  43037. */
  43038. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43039. /**
  43040. * Fired when the menu button on this controller is modified
  43041. */
  43042. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43043. /**
  43044. * Fired when the grip button on this controller is modified
  43045. */
  43046. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43047. /**
  43048. * Fired when the thumbstick button on this controller is modified
  43049. */
  43050. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43051. /**
  43052. * Fired when the touchpad button on this controller is modified
  43053. */
  43054. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43055. /**
  43056. * Fired when the touchpad values on this controller are modified
  43057. */
  43058. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43059. private _updateTrackpad;
  43060. /**
  43061. * Called once per frame by the engine.
  43062. */
  43063. update(): void;
  43064. /**
  43065. * Called once for each button that changed state since the last frame
  43066. * @param buttonIdx Which button index changed
  43067. * @param state New state of the button
  43068. * @param changes Which properties on the state changed since last frame
  43069. */
  43070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43071. /**
  43072. * Moves the buttons on the controller mesh based on their current state
  43073. * @param buttonName the name of the button to move
  43074. * @param buttonValue the value of the button which determines the buttons new position
  43075. */
  43076. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43077. /**
  43078. * Moves the axis on the controller mesh based on its current state
  43079. * @param axis the index of the axis
  43080. * @param axisValue the value of the axis which determines the meshes new position
  43081. * @hidden
  43082. */
  43083. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43084. /**
  43085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43086. * @param scene scene in which to add meshes
  43087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43088. */
  43089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43090. /**
  43091. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43092. * can be transformed by button presses and axes values, based on this._mapping.
  43093. *
  43094. * @param scene scene in which the meshes exist
  43095. * @param meshes list of meshes that make up the controller model to process
  43096. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43097. */
  43098. private processModel;
  43099. private createMeshInfo;
  43100. /**
  43101. * Gets the ray of the controller in the direction the controller is pointing
  43102. * @param length the length the resulting ray should be
  43103. * @returns a ray in the direction the controller is pointing
  43104. */
  43105. getForwardRay(length?: number): Ray;
  43106. /**
  43107. * Disposes of the controller
  43108. */
  43109. dispose(): void;
  43110. }
  43111. }
  43112. declare module "babylonjs/Gamepads/Controllers/index" {
  43113. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43114. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43115. export * from "babylonjs/Gamepads/Controllers/genericController";
  43116. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43117. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43118. export * from "babylonjs/Gamepads/Controllers/viveController";
  43119. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43120. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43121. }
  43122. declare module "babylonjs/Gamepads/gamepadManager" {
  43123. import { Observable } from "babylonjs/Misc/observable";
  43124. import { Nullable } from "babylonjs/types";
  43125. import { Scene } from "babylonjs/scene";
  43126. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43127. /**
  43128. * Manager for handling gamepads
  43129. */
  43130. export class GamepadManager {
  43131. private _scene?;
  43132. private _babylonGamepads;
  43133. private _oneGamepadConnected;
  43134. /** @hidden */
  43135. _isMonitoring: boolean;
  43136. private _gamepadEventSupported;
  43137. private _gamepadSupport;
  43138. /**
  43139. * observable to be triggered when the gamepad controller has been connected
  43140. */
  43141. onGamepadConnectedObservable: Observable<Gamepad>;
  43142. /**
  43143. * observable to be triggered when the gamepad controller has been disconnected
  43144. */
  43145. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43146. private _onGamepadConnectedEvent;
  43147. private _onGamepadDisconnectedEvent;
  43148. /**
  43149. * Initializes the gamepad manager
  43150. * @param _scene BabylonJS scene
  43151. */
  43152. constructor(_scene?: Scene | undefined);
  43153. /**
  43154. * The gamepads in the game pad manager
  43155. */
  43156. readonly gamepads: Gamepad[];
  43157. /**
  43158. * Get the gamepad controllers based on type
  43159. * @param type The type of gamepad controller
  43160. * @returns Nullable gamepad
  43161. */
  43162. getGamepadByType(type?: number): Nullable<Gamepad>;
  43163. /**
  43164. * Disposes the gamepad manager
  43165. */
  43166. dispose(): void;
  43167. private _addNewGamepad;
  43168. private _startMonitoringGamepads;
  43169. private _stopMonitoringGamepads;
  43170. /** @hidden */
  43171. _checkGamepadsStatus(): void;
  43172. private _updateGamepadObjects;
  43173. }
  43174. }
  43175. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43176. import { Nullable } from "babylonjs/types";
  43177. import { Scene } from "babylonjs/scene";
  43178. import { ISceneComponent } from "babylonjs/sceneComponent";
  43179. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43180. module "babylonjs/scene" {
  43181. interface Scene {
  43182. /** @hidden */
  43183. _gamepadManager: Nullable<GamepadManager>;
  43184. /**
  43185. * Gets the gamepad manager associated with the scene
  43186. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43187. */
  43188. gamepadManager: GamepadManager;
  43189. }
  43190. }
  43191. module "babylonjs/Cameras/freeCameraInputsManager" {
  43192. /**
  43193. * Interface representing a free camera inputs manager
  43194. */
  43195. interface FreeCameraInputsManager {
  43196. /**
  43197. * Adds gamepad input support to the FreeCameraInputsManager.
  43198. * @returns the FreeCameraInputsManager
  43199. */
  43200. addGamepad(): FreeCameraInputsManager;
  43201. }
  43202. }
  43203. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43204. /**
  43205. * Interface representing an arc rotate camera inputs manager
  43206. */
  43207. interface ArcRotateCameraInputsManager {
  43208. /**
  43209. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43210. * @returns the camera inputs manager
  43211. */
  43212. addGamepad(): ArcRotateCameraInputsManager;
  43213. }
  43214. }
  43215. /**
  43216. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43217. */
  43218. export class GamepadSystemSceneComponent implements ISceneComponent {
  43219. /**
  43220. * The component name helpfull to identify the component in the list of scene components.
  43221. */
  43222. readonly name: string;
  43223. /**
  43224. * The scene the component belongs to.
  43225. */
  43226. scene: Scene;
  43227. /**
  43228. * Creates a new instance of the component for the given scene
  43229. * @param scene Defines the scene to register the component in
  43230. */
  43231. constructor(scene: Scene);
  43232. /**
  43233. * Registers the component in a given scene
  43234. */
  43235. register(): void;
  43236. /**
  43237. * Rebuilds the elements related to this component in case of
  43238. * context lost for instance.
  43239. */
  43240. rebuild(): void;
  43241. /**
  43242. * Disposes the component and the associated ressources
  43243. */
  43244. dispose(): void;
  43245. private _beforeCameraUpdate;
  43246. }
  43247. }
  43248. declare module "babylonjs/Gamepads/index" {
  43249. export * from "babylonjs/Gamepads/Controllers/index";
  43250. export * from "babylonjs/Gamepads/gamepad";
  43251. export * from "babylonjs/Gamepads/gamepadManager";
  43252. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43253. export * from "babylonjs/Gamepads/xboxGamepad";
  43254. }
  43255. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43256. import { Observable } from "babylonjs/Misc/observable";
  43257. import { Nullable } from "babylonjs/types";
  43258. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43260. import { Mesh } from "babylonjs/Meshes/mesh";
  43261. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43262. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43263. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43264. /**
  43265. * Single axis scale gizmo
  43266. */
  43267. export class AxisScaleGizmo extends Gizmo {
  43268. private _coloredMaterial;
  43269. /**
  43270. * Drag behavior responsible for the gizmos dragging interactions
  43271. */
  43272. dragBehavior: PointerDragBehavior;
  43273. private _pointerObserver;
  43274. /**
  43275. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43276. */
  43277. snapDistance: number;
  43278. /**
  43279. * Event that fires each time the gizmo snaps to a new location.
  43280. * * snapDistance is the the change in distance
  43281. */
  43282. onSnapObservable: Observable<{
  43283. snapDistance: number;
  43284. }>;
  43285. /**
  43286. * If the scaling operation should be done on all axis (default: false)
  43287. */
  43288. uniformScaling: boolean;
  43289. /**
  43290. * Creates an AxisScaleGizmo
  43291. * @param gizmoLayer The utility layer the gizmo will be added to
  43292. * @param dragAxis The axis which the gizmo will be able to scale on
  43293. * @param color The color of the gizmo
  43294. */
  43295. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43296. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43297. /**
  43298. * Disposes of the gizmo
  43299. */
  43300. dispose(): void;
  43301. /**
  43302. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43303. * @param mesh The mesh to replace the default mesh of the gizmo
  43304. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43305. */
  43306. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43307. }
  43308. }
  43309. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43310. import { Observable } from "babylonjs/Misc/observable";
  43311. import { Nullable } from "babylonjs/types";
  43312. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43314. import { Mesh } from "babylonjs/Meshes/mesh";
  43315. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43316. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43317. /**
  43318. * Bounding box gizmo
  43319. */
  43320. export class BoundingBoxGizmo extends Gizmo {
  43321. private _lineBoundingBox;
  43322. private _rotateSpheresParent;
  43323. private _scaleBoxesParent;
  43324. private _boundingDimensions;
  43325. private _renderObserver;
  43326. private _pointerObserver;
  43327. private _scaleDragSpeed;
  43328. private _tmpQuaternion;
  43329. private _tmpVector;
  43330. private _tmpRotationMatrix;
  43331. /**
  43332. * 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)
  43333. */
  43334. ignoreChildren: boolean;
  43335. /**
  43336. * 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)
  43337. */
  43338. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43339. /**
  43340. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43341. */
  43342. rotationSphereSize: number;
  43343. /**
  43344. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43345. */
  43346. scaleBoxSize: number;
  43347. /**
  43348. * 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)
  43349. */
  43350. fixedDragMeshScreenSize: boolean;
  43351. /**
  43352. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43353. */
  43354. fixedDragMeshScreenSizeDistanceFactor: number;
  43355. /**
  43356. * Fired when a rotation sphere or scale box is dragged
  43357. */
  43358. onDragStartObservable: Observable<{}>;
  43359. /**
  43360. * Fired when a scale box is dragged
  43361. */
  43362. onScaleBoxDragObservable: Observable<{}>;
  43363. /**
  43364. * Fired when a scale box drag is ended
  43365. */
  43366. onScaleBoxDragEndObservable: Observable<{}>;
  43367. /**
  43368. * Fired when a rotation sphere is dragged
  43369. */
  43370. onRotationSphereDragObservable: Observable<{}>;
  43371. /**
  43372. * Fired when a rotation sphere drag is ended
  43373. */
  43374. onRotationSphereDragEndObservable: Observable<{}>;
  43375. /**
  43376. * 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)
  43377. */
  43378. scalePivot: Nullable<Vector3>;
  43379. private _anchorMesh;
  43380. private _existingMeshScale;
  43381. private _dragMesh;
  43382. private pointerDragBehavior;
  43383. /**
  43384. * Creates an BoundingBoxGizmo
  43385. * @param gizmoLayer The utility layer the gizmo will be added to
  43386. * @param color The color of the gizmo
  43387. */
  43388. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43389. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43390. private _selectNode;
  43391. /**
  43392. * Updates the bounding box information for the Gizmo
  43393. */
  43394. updateBoundingBox(): void;
  43395. private _updateRotationSpheres;
  43396. private _updateScaleBoxes;
  43397. /**
  43398. * Enables rotation on the specified axis and disables rotation on the others
  43399. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43400. */
  43401. setEnabledRotationAxis(axis: string): void;
  43402. /**
  43403. * Enables/disables scaling
  43404. * @param enable if scaling should be enabled
  43405. */
  43406. setEnabledScaling(enable: boolean): void;
  43407. private _updateDummy;
  43408. /**
  43409. * Enables a pointer drag behavior on the bounding box of the gizmo
  43410. */
  43411. enableDragBehavior(): void;
  43412. /**
  43413. * Disposes of the gizmo
  43414. */
  43415. dispose(): void;
  43416. /**
  43417. * 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)
  43418. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43419. * @returns the bounding box mesh with the passed in mesh as a child
  43420. */
  43421. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43422. /**
  43423. * CustomMeshes are not supported by this gizmo
  43424. * @param mesh The mesh to replace the default mesh of the gizmo
  43425. */
  43426. setCustomMesh(mesh: Mesh): void;
  43427. }
  43428. }
  43429. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43430. import { Observable } from "babylonjs/Misc/observable";
  43431. import { Nullable } from "babylonjs/types";
  43432. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43434. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43435. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43436. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43437. /**
  43438. * Single plane rotation gizmo
  43439. */
  43440. export class PlaneRotationGizmo extends Gizmo {
  43441. /**
  43442. * Drag behavior responsible for the gizmos dragging interactions
  43443. */
  43444. dragBehavior: PointerDragBehavior;
  43445. private _pointerObserver;
  43446. /**
  43447. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43448. */
  43449. snapDistance: number;
  43450. /**
  43451. * Event that fires each time the gizmo snaps to a new location.
  43452. * * snapDistance is the the change in distance
  43453. */
  43454. onSnapObservable: Observable<{
  43455. snapDistance: number;
  43456. }>;
  43457. /**
  43458. * Creates a PlaneRotationGizmo
  43459. * @param gizmoLayer The utility layer the gizmo will be added to
  43460. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43461. * @param color The color of the gizmo
  43462. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43463. */
  43464. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43466. /**
  43467. * Disposes of the gizmo
  43468. */
  43469. dispose(): void;
  43470. }
  43471. }
  43472. declare module "babylonjs/Gizmos/rotationGizmo" {
  43473. import { Observable } from "babylonjs/Misc/observable";
  43474. import { Nullable } from "babylonjs/types";
  43475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43476. import { Mesh } from "babylonjs/Meshes/mesh";
  43477. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43478. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43479. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43480. /**
  43481. * Gizmo that enables rotating a mesh along 3 axis
  43482. */
  43483. export class RotationGizmo extends Gizmo {
  43484. /**
  43485. * Internal gizmo used for interactions on the x axis
  43486. */
  43487. xGizmo: PlaneRotationGizmo;
  43488. /**
  43489. * Internal gizmo used for interactions on the y axis
  43490. */
  43491. yGizmo: PlaneRotationGizmo;
  43492. /**
  43493. * Internal gizmo used for interactions on the z axis
  43494. */
  43495. zGizmo: PlaneRotationGizmo;
  43496. /** Fires an event when any of it's sub gizmos are dragged */
  43497. onDragStartObservable: Observable<{}>;
  43498. /** Fires an event when any of it's sub gizmos are released from dragging */
  43499. onDragEndObservable: Observable<{}>;
  43500. attachedMesh: Nullable<AbstractMesh>;
  43501. /**
  43502. * Creates a RotationGizmo
  43503. * @param gizmoLayer The utility layer the gizmo will be added to
  43504. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43505. */
  43506. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43507. updateGizmoRotationToMatchAttachedMesh: boolean;
  43508. /**
  43509. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43510. */
  43511. snapDistance: number;
  43512. /**
  43513. * Ratio for the scale of the gizmo (Default: 1)
  43514. */
  43515. scaleRatio: number;
  43516. /**
  43517. * Disposes of the gizmo
  43518. */
  43519. dispose(): void;
  43520. /**
  43521. * CustomMeshes are not supported by this gizmo
  43522. * @param mesh The mesh to replace the default mesh of the gizmo
  43523. */
  43524. setCustomMesh(mesh: Mesh): void;
  43525. }
  43526. }
  43527. declare module "babylonjs/Gizmos/positionGizmo" {
  43528. import { Observable } from "babylonjs/Misc/observable";
  43529. import { Nullable } from "babylonjs/types";
  43530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43531. import { Mesh } from "babylonjs/Meshes/mesh";
  43532. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43533. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43534. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43535. /**
  43536. * Gizmo that enables dragging a mesh along 3 axis
  43537. */
  43538. export class PositionGizmo extends Gizmo {
  43539. /**
  43540. * Internal gizmo used for interactions on the x axis
  43541. */
  43542. xGizmo: AxisDragGizmo;
  43543. /**
  43544. * Internal gizmo used for interactions on the y axis
  43545. */
  43546. yGizmo: AxisDragGizmo;
  43547. /**
  43548. * Internal gizmo used for interactions on the z axis
  43549. */
  43550. zGizmo: AxisDragGizmo;
  43551. /** Fires an event when any of it's sub gizmos are dragged */
  43552. onDragStartObservable: Observable<{}>;
  43553. /** Fires an event when any of it's sub gizmos are released from dragging */
  43554. onDragEndObservable: Observable<{}>;
  43555. attachedMesh: Nullable<AbstractMesh>;
  43556. /**
  43557. * Creates a PositionGizmo
  43558. * @param gizmoLayer The utility layer the gizmo will be added to
  43559. */
  43560. constructor(gizmoLayer?: UtilityLayerRenderer);
  43561. updateGizmoRotationToMatchAttachedMesh: boolean;
  43562. /**
  43563. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43564. */
  43565. snapDistance: number;
  43566. /**
  43567. * Ratio for the scale of the gizmo (Default: 1)
  43568. */
  43569. scaleRatio: number;
  43570. /**
  43571. * Disposes of the gizmo
  43572. */
  43573. dispose(): void;
  43574. /**
  43575. * CustomMeshes are not supported by this gizmo
  43576. * @param mesh The mesh to replace the default mesh of the gizmo
  43577. */
  43578. setCustomMesh(mesh: Mesh): void;
  43579. }
  43580. }
  43581. declare module "babylonjs/Gizmos/scaleGizmo" {
  43582. import { Observable } from "babylonjs/Misc/observable";
  43583. import { Nullable } from "babylonjs/types";
  43584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43585. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43586. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43587. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43588. /**
  43589. * Gizmo that enables scaling a mesh along 3 axis
  43590. */
  43591. export class ScaleGizmo extends Gizmo {
  43592. /**
  43593. * Internal gizmo used for interactions on the x axis
  43594. */
  43595. xGizmo: AxisScaleGizmo;
  43596. /**
  43597. * Internal gizmo used for interactions on the y axis
  43598. */
  43599. yGizmo: AxisScaleGizmo;
  43600. /**
  43601. * Internal gizmo used for interactions on the z axis
  43602. */
  43603. zGizmo: AxisScaleGizmo;
  43604. /**
  43605. * Internal gizmo used to scale all axis equally
  43606. */
  43607. uniformScaleGizmo: AxisScaleGizmo;
  43608. /** Fires an event when any of it's sub gizmos are dragged */
  43609. onDragStartObservable: Observable<{}>;
  43610. /** Fires an event when any of it's sub gizmos are released from dragging */
  43611. onDragEndObservable: Observable<{}>;
  43612. attachedMesh: Nullable<AbstractMesh>;
  43613. /**
  43614. * Creates a ScaleGizmo
  43615. * @param gizmoLayer The utility layer the gizmo will be added to
  43616. */
  43617. constructor(gizmoLayer?: UtilityLayerRenderer);
  43618. updateGizmoRotationToMatchAttachedMesh: boolean;
  43619. /**
  43620. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43621. */
  43622. snapDistance: number;
  43623. /**
  43624. * Ratio for the scale of the gizmo (Default: 1)
  43625. */
  43626. scaleRatio: number;
  43627. /**
  43628. * Disposes of the gizmo
  43629. */
  43630. dispose(): void;
  43631. }
  43632. }
  43633. declare module "babylonjs/Gizmos/gizmoManager" {
  43634. import { Observable } from "babylonjs/Misc/observable";
  43635. import { Nullable } from "babylonjs/types";
  43636. import { Scene, IDisposable } from "babylonjs/scene";
  43637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43638. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43639. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43640. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43641. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43642. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43643. /**
  43644. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43645. */
  43646. export class GizmoManager implements IDisposable {
  43647. private scene;
  43648. /**
  43649. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43650. */
  43651. gizmos: {
  43652. positionGizmo: Nullable<PositionGizmo>;
  43653. rotationGizmo: Nullable<RotationGizmo>;
  43654. scaleGizmo: Nullable<ScaleGizmo>;
  43655. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43656. };
  43657. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43658. clearGizmoOnEmptyPointerEvent: boolean;
  43659. /** Fires an event when the manager is attached to a mesh */
  43660. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43661. private _gizmosEnabled;
  43662. private _pointerObserver;
  43663. private _attachedMesh;
  43664. private _boundingBoxColor;
  43665. private _defaultUtilityLayer;
  43666. private _defaultKeepDepthUtilityLayer;
  43667. /**
  43668. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43669. */
  43670. boundingBoxDragBehavior: SixDofDragBehavior;
  43671. /**
  43672. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43673. */
  43674. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43675. /**
  43676. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43677. */
  43678. usePointerToAttachGizmos: boolean;
  43679. /**
  43680. * Instatiates a gizmo manager
  43681. * @param scene the scene to overlay the gizmos on top of
  43682. */
  43683. constructor(scene: Scene);
  43684. /**
  43685. * Attaches a set of gizmos to the specified mesh
  43686. * @param mesh The mesh the gizmo's should be attached to
  43687. */
  43688. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43689. /**
  43690. * If the position gizmo is enabled
  43691. */
  43692. positionGizmoEnabled: boolean;
  43693. /**
  43694. * If the rotation gizmo is enabled
  43695. */
  43696. rotationGizmoEnabled: boolean;
  43697. /**
  43698. * If the scale gizmo is enabled
  43699. */
  43700. scaleGizmoEnabled: boolean;
  43701. /**
  43702. * If the boundingBox gizmo is enabled
  43703. */
  43704. boundingBoxGizmoEnabled: boolean;
  43705. /**
  43706. * Disposes of the gizmo manager
  43707. */
  43708. dispose(): void;
  43709. }
  43710. }
  43711. declare module "babylonjs/Gizmos/index" {
  43712. export * from "babylonjs/Gizmos/axisDragGizmo";
  43713. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43714. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43715. export * from "babylonjs/Gizmos/gizmo";
  43716. export * from "babylonjs/Gizmos/gizmoManager";
  43717. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43718. export * from "babylonjs/Gizmos/positionGizmo";
  43719. export * from "babylonjs/Gizmos/rotationGizmo";
  43720. export * from "babylonjs/Gizmos/scaleGizmo";
  43721. }
  43722. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43723. /** @hidden */
  43724. export var backgroundFragmentDeclaration: {
  43725. name: string;
  43726. shader: string;
  43727. };
  43728. }
  43729. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43730. /** @hidden */
  43731. export var backgroundUboDeclaration: {
  43732. name: string;
  43733. shader: string;
  43734. };
  43735. }
  43736. declare module "babylonjs/Shaders/background.fragment" {
  43737. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43738. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43739. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43740. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43741. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43742. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43744. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43745. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43746. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43747. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43748. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43749. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43750. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43751. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43752. /** @hidden */
  43753. export var backgroundPixelShader: {
  43754. name: string;
  43755. shader: string;
  43756. };
  43757. }
  43758. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43759. /** @hidden */
  43760. export var backgroundVertexDeclaration: {
  43761. name: string;
  43762. shader: string;
  43763. };
  43764. }
  43765. declare module "babylonjs/Shaders/background.vertex" {
  43766. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43767. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43769. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43770. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43772. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43773. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43774. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43775. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43776. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43777. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43778. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43779. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43780. /** @hidden */
  43781. export var backgroundVertexShader: {
  43782. name: string;
  43783. shader: string;
  43784. };
  43785. }
  43786. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43787. import { Nullable, int, float } from "babylonjs/types";
  43788. import { Scene } from "babylonjs/scene";
  43789. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43792. import { Mesh } from "babylonjs/Meshes/mesh";
  43793. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43794. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43795. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43797. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43798. import "babylonjs/Shaders/background.fragment";
  43799. import "babylonjs/Shaders/background.vertex";
  43800. /**
  43801. * Background material used to create an efficient environement around your scene.
  43802. */
  43803. export class BackgroundMaterial extends PushMaterial {
  43804. /**
  43805. * Standard reflectance value at parallel view angle.
  43806. */
  43807. static StandardReflectance0: number;
  43808. /**
  43809. * Standard reflectance value at grazing angle.
  43810. */
  43811. static StandardReflectance90: number;
  43812. protected _primaryColor: Color3;
  43813. /**
  43814. * Key light Color (multiply against the environement texture)
  43815. */
  43816. primaryColor: Color3;
  43817. protected __perceptualColor: Nullable<Color3>;
  43818. /**
  43819. * Experimental Internal Use Only.
  43820. *
  43821. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43822. * This acts as a helper to set the primary color to a more "human friendly" value.
  43823. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43824. * output color as close as possible from the chosen value.
  43825. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43826. * part of lighting setup.)
  43827. */
  43828. _perceptualColor: Nullable<Color3>;
  43829. protected _primaryColorShadowLevel: float;
  43830. /**
  43831. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43832. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43833. */
  43834. primaryColorShadowLevel: float;
  43835. protected _primaryColorHighlightLevel: float;
  43836. /**
  43837. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43838. * The primary color is used at the level chosen to define what the white area would look.
  43839. */
  43840. primaryColorHighlightLevel: float;
  43841. protected _reflectionTexture: Nullable<BaseTexture>;
  43842. /**
  43843. * Reflection Texture used in the material.
  43844. * Should be author in a specific way for the best result (refer to the documentation).
  43845. */
  43846. reflectionTexture: Nullable<BaseTexture>;
  43847. protected _reflectionBlur: float;
  43848. /**
  43849. * Reflection Texture level of blur.
  43850. *
  43851. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43852. * texture twice.
  43853. */
  43854. reflectionBlur: float;
  43855. protected _diffuseTexture: Nullable<BaseTexture>;
  43856. /**
  43857. * Diffuse Texture used in the material.
  43858. * Should be author in a specific way for the best result (refer to the documentation).
  43859. */
  43860. diffuseTexture: Nullable<BaseTexture>;
  43861. protected _shadowLights: Nullable<IShadowLight[]>;
  43862. /**
  43863. * Specify the list of lights casting shadow on the material.
  43864. * All scene shadow lights will be included if null.
  43865. */
  43866. shadowLights: Nullable<IShadowLight[]>;
  43867. protected _shadowLevel: float;
  43868. /**
  43869. * Helps adjusting the shadow to a softer level if required.
  43870. * 0 means black shadows and 1 means no shadows.
  43871. */
  43872. shadowLevel: float;
  43873. protected _sceneCenter: Vector3;
  43874. /**
  43875. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43876. * It is usually zero but might be interesting to modify according to your setup.
  43877. */
  43878. sceneCenter: Vector3;
  43879. protected _opacityFresnel: boolean;
  43880. /**
  43881. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43882. * This helps ensuring a nice transition when the camera goes under the ground.
  43883. */
  43884. opacityFresnel: boolean;
  43885. protected _reflectionFresnel: boolean;
  43886. /**
  43887. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43888. * This helps adding a mirror texture on the ground.
  43889. */
  43890. reflectionFresnel: boolean;
  43891. protected _reflectionFalloffDistance: number;
  43892. /**
  43893. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43894. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43895. */
  43896. reflectionFalloffDistance: number;
  43897. protected _reflectionAmount: number;
  43898. /**
  43899. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43900. */
  43901. reflectionAmount: number;
  43902. protected _reflectionReflectance0: number;
  43903. /**
  43904. * This specifies the weight of the reflection at grazing angle.
  43905. */
  43906. reflectionReflectance0: number;
  43907. protected _reflectionReflectance90: number;
  43908. /**
  43909. * This specifies the weight of the reflection at a perpendicular point of view.
  43910. */
  43911. reflectionReflectance90: number;
  43912. /**
  43913. * Sets the reflection reflectance fresnel values according to the default standard
  43914. * empirically know to work well :-)
  43915. */
  43916. reflectionStandardFresnelWeight: number;
  43917. protected _useRGBColor: boolean;
  43918. /**
  43919. * Helps to directly use the maps channels instead of their level.
  43920. */
  43921. useRGBColor: boolean;
  43922. protected _enableNoise: boolean;
  43923. /**
  43924. * This helps reducing the banding effect that could occur on the background.
  43925. */
  43926. enableNoise: boolean;
  43927. /**
  43928. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43929. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43930. * Recommended to be keep at 1.0 except for special cases.
  43931. */
  43932. fovMultiplier: number;
  43933. private _fovMultiplier;
  43934. /**
  43935. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43936. */
  43937. useEquirectangularFOV: boolean;
  43938. private _maxSimultaneousLights;
  43939. /**
  43940. * Number of Simultaneous lights allowed on the material.
  43941. */
  43942. maxSimultaneousLights: int;
  43943. /**
  43944. * Default configuration related to image processing available in the Background Material.
  43945. */
  43946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43947. /**
  43948. * Keep track of the image processing observer to allow dispose and replace.
  43949. */
  43950. private _imageProcessingObserver;
  43951. /**
  43952. * Attaches a new image processing configuration to the PBR Material.
  43953. * @param configuration (if null the scene configuration will be use)
  43954. */
  43955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43956. /**
  43957. * Gets the image processing configuration used either in this material.
  43958. */
  43959. /**
  43960. * Sets the Default image processing configuration used either in the this material.
  43961. *
  43962. * If sets to null, the scene one is in use.
  43963. */
  43964. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43965. /**
  43966. * Gets wether the color curves effect is enabled.
  43967. */
  43968. /**
  43969. * Sets wether the color curves effect is enabled.
  43970. */
  43971. cameraColorCurvesEnabled: boolean;
  43972. /**
  43973. * Gets wether the color grading effect is enabled.
  43974. */
  43975. /**
  43976. * Gets wether the color grading effect is enabled.
  43977. */
  43978. cameraColorGradingEnabled: boolean;
  43979. /**
  43980. * Gets wether tonemapping is enabled or not.
  43981. */
  43982. /**
  43983. * Sets wether tonemapping is enabled or not
  43984. */
  43985. cameraToneMappingEnabled: boolean;
  43986. /**
  43987. * The camera exposure used on this material.
  43988. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43989. * This corresponds to a photographic exposure.
  43990. */
  43991. /**
  43992. * The camera exposure used on this material.
  43993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43994. * This corresponds to a photographic exposure.
  43995. */
  43996. cameraExposure: float;
  43997. /**
  43998. * Gets The camera contrast used on this material.
  43999. */
  44000. /**
  44001. * Sets The camera contrast used on this material.
  44002. */
  44003. cameraContrast: float;
  44004. /**
  44005. * Gets the Color Grading 2D Lookup Texture.
  44006. */
  44007. /**
  44008. * Sets the Color Grading 2D Lookup Texture.
  44009. */
  44010. cameraColorGradingTexture: Nullable<BaseTexture>;
  44011. /**
  44012. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44013. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44014. * 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;
  44015. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44016. */
  44017. /**
  44018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44020. * 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;
  44021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44022. */
  44023. cameraColorCurves: Nullable<ColorCurves>;
  44024. /**
  44025. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44026. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44027. */
  44028. switchToBGR: boolean;
  44029. private _renderTargets;
  44030. private _reflectionControls;
  44031. private _white;
  44032. private _primaryShadowColor;
  44033. private _primaryHighlightColor;
  44034. /**
  44035. * Instantiates a Background Material in the given scene
  44036. * @param name The friendly name of the material
  44037. * @param scene The scene to add the material to
  44038. */
  44039. constructor(name: string, scene: Scene);
  44040. /**
  44041. * Gets a boolean indicating that current material needs to register RTT
  44042. */
  44043. readonly hasRenderTargetTextures: boolean;
  44044. /**
  44045. * The entire material has been created in order to prevent overdraw.
  44046. * @returns false
  44047. */
  44048. needAlphaTesting(): boolean;
  44049. /**
  44050. * The entire material has been created in order to prevent overdraw.
  44051. * @returns true if blending is enable
  44052. */
  44053. needAlphaBlending(): boolean;
  44054. /**
  44055. * Checks wether the material is ready to be rendered for a given mesh.
  44056. * @param mesh The mesh to render
  44057. * @param subMesh The submesh to check against
  44058. * @param useInstances Specify wether or not the material is used with instances
  44059. * @returns true if all the dependencies are ready (Textures, Effects...)
  44060. */
  44061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44062. /**
  44063. * Compute the primary color according to the chosen perceptual color.
  44064. */
  44065. private _computePrimaryColorFromPerceptualColor;
  44066. /**
  44067. * Compute the highlights and shadow colors according to their chosen levels.
  44068. */
  44069. private _computePrimaryColors;
  44070. /**
  44071. * Build the uniform buffer used in the material.
  44072. */
  44073. buildUniformLayout(): void;
  44074. /**
  44075. * Unbind the material.
  44076. */
  44077. unbind(): void;
  44078. /**
  44079. * Bind only the world matrix to the material.
  44080. * @param world The world matrix to bind.
  44081. */
  44082. bindOnlyWorldMatrix(world: Matrix): void;
  44083. /**
  44084. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44085. * @param world The world matrix to bind.
  44086. * @param subMesh The submesh to bind for.
  44087. */
  44088. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44089. /**
  44090. * Dispose the material.
  44091. * @param forceDisposeEffect Force disposal of the associated effect.
  44092. * @param forceDisposeTextures Force disposal of the associated textures.
  44093. */
  44094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44095. /**
  44096. * Clones the material.
  44097. * @param name The cloned name.
  44098. * @returns The cloned material.
  44099. */
  44100. clone(name: string): BackgroundMaterial;
  44101. /**
  44102. * Serializes the current material to its JSON representation.
  44103. * @returns The JSON representation.
  44104. */
  44105. serialize(): any;
  44106. /**
  44107. * Gets the class name of the material
  44108. * @returns "BackgroundMaterial"
  44109. */
  44110. getClassName(): string;
  44111. /**
  44112. * Parse a JSON input to create back a background material.
  44113. * @param source The JSON data to parse
  44114. * @param scene The scene to create the parsed material in
  44115. * @param rootUrl The root url of the assets the material depends upon
  44116. * @returns the instantiated BackgroundMaterial.
  44117. */
  44118. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44119. }
  44120. }
  44121. declare module "babylonjs/Helpers/environmentHelper" {
  44122. import { Observable } from "babylonjs/Misc/observable";
  44123. import { Nullable } from "babylonjs/types";
  44124. import { Scene } from "babylonjs/scene";
  44125. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44127. import { Mesh } from "babylonjs/Meshes/mesh";
  44128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44129. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44130. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44131. /**
  44132. * Represents the different options available during the creation of
  44133. * a Environment helper.
  44134. *
  44135. * This can control the default ground, skybox and image processing setup of your scene.
  44136. */
  44137. export interface IEnvironmentHelperOptions {
  44138. /**
  44139. * Specifies wether or not to create a ground.
  44140. * True by default.
  44141. */
  44142. createGround: boolean;
  44143. /**
  44144. * Specifies the ground size.
  44145. * 15 by default.
  44146. */
  44147. groundSize: number;
  44148. /**
  44149. * The texture used on the ground for the main color.
  44150. * Comes from the BabylonJS CDN by default.
  44151. *
  44152. * Remarks: Can be either a texture or a url.
  44153. */
  44154. groundTexture: string | BaseTexture;
  44155. /**
  44156. * The color mixed in the ground texture by default.
  44157. * BabylonJS clearColor by default.
  44158. */
  44159. groundColor: Color3;
  44160. /**
  44161. * Specifies the ground opacity.
  44162. * 1 by default.
  44163. */
  44164. groundOpacity: number;
  44165. /**
  44166. * Enables the ground to receive shadows.
  44167. * True by default.
  44168. */
  44169. enableGroundShadow: boolean;
  44170. /**
  44171. * Helps preventing the shadow to be fully black on the ground.
  44172. * 0.5 by default.
  44173. */
  44174. groundShadowLevel: number;
  44175. /**
  44176. * Creates a mirror texture attach to the ground.
  44177. * false by default.
  44178. */
  44179. enableGroundMirror: boolean;
  44180. /**
  44181. * Specifies the ground mirror size ratio.
  44182. * 0.3 by default as the default kernel is 64.
  44183. */
  44184. groundMirrorSizeRatio: number;
  44185. /**
  44186. * Specifies the ground mirror blur kernel size.
  44187. * 64 by default.
  44188. */
  44189. groundMirrorBlurKernel: number;
  44190. /**
  44191. * Specifies the ground mirror visibility amount.
  44192. * 1 by default
  44193. */
  44194. groundMirrorAmount: number;
  44195. /**
  44196. * Specifies the ground mirror reflectance weight.
  44197. * This uses the standard weight of the background material to setup the fresnel effect
  44198. * of the mirror.
  44199. * 1 by default.
  44200. */
  44201. groundMirrorFresnelWeight: number;
  44202. /**
  44203. * Specifies the ground mirror Falloff distance.
  44204. * This can helps reducing the size of the reflection.
  44205. * 0 by Default.
  44206. */
  44207. groundMirrorFallOffDistance: number;
  44208. /**
  44209. * Specifies the ground mirror texture type.
  44210. * Unsigned Int by Default.
  44211. */
  44212. groundMirrorTextureType: number;
  44213. /**
  44214. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44215. * the shown objects.
  44216. */
  44217. groundYBias: number;
  44218. /**
  44219. * Specifies wether or not to create a skybox.
  44220. * True by default.
  44221. */
  44222. createSkybox: boolean;
  44223. /**
  44224. * Specifies the skybox size.
  44225. * 20 by default.
  44226. */
  44227. skyboxSize: number;
  44228. /**
  44229. * The texture used on the skybox for the main color.
  44230. * Comes from the BabylonJS CDN by default.
  44231. *
  44232. * Remarks: Can be either a texture or a url.
  44233. */
  44234. skyboxTexture: string | BaseTexture;
  44235. /**
  44236. * The color mixed in the skybox texture by default.
  44237. * BabylonJS clearColor by default.
  44238. */
  44239. skyboxColor: Color3;
  44240. /**
  44241. * The background rotation around the Y axis of the scene.
  44242. * This helps aligning the key lights of your scene with the background.
  44243. * 0 by default.
  44244. */
  44245. backgroundYRotation: number;
  44246. /**
  44247. * Compute automatically the size of the elements to best fit with the scene.
  44248. */
  44249. sizeAuto: boolean;
  44250. /**
  44251. * Default position of the rootMesh if autoSize is not true.
  44252. */
  44253. rootPosition: Vector3;
  44254. /**
  44255. * Sets up the image processing in the scene.
  44256. * true by default.
  44257. */
  44258. setupImageProcessing: boolean;
  44259. /**
  44260. * The texture used as your environment texture in the scene.
  44261. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44262. *
  44263. * Remarks: Can be either a texture or a url.
  44264. */
  44265. environmentTexture: string | BaseTexture;
  44266. /**
  44267. * The value of the exposure to apply to the scene.
  44268. * 0.6 by default if setupImageProcessing is true.
  44269. */
  44270. cameraExposure: number;
  44271. /**
  44272. * The value of the contrast to apply to the scene.
  44273. * 1.6 by default if setupImageProcessing is true.
  44274. */
  44275. cameraContrast: number;
  44276. /**
  44277. * Specifies wether or not tonemapping should be enabled in the scene.
  44278. * true by default if setupImageProcessing is true.
  44279. */
  44280. toneMappingEnabled: boolean;
  44281. }
  44282. /**
  44283. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44284. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44285. * It also helps with the default setup of your imageProcessing configuration.
  44286. */
  44287. export class EnvironmentHelper {
  44288. /**
  44289. * Default ground texture URL.
  44290. */
  44291. private static _groundTextureCDNUrl;
  44292. /**
  44293. * Default skybox texture URL.
  44294. */
  44295. private static _skyboxTextureCDNUrl;
  44296. /**
  44297. * Default environment texture URL.
  44298. */
  44299. private static _environmentTextureCDNUrl;
  44300. /**
  44301. * Creates the default options for the helper.
  44302. */
  44303. private static _getDefaultOptions;
  44304. private _rootMesh;
  44305. /**
  44306. * Gets the root mesh created by the helper.
  44307. */
  44308. readonly rootMesh: Mesh;
  44309. private _skybox;
  44310. /**
  44311. * Gets the skybox created by the helper.
  44312. */
  44313. readonly skybox: Nullable<Mesh>;
  44314. private _skyboxTexture;
  44315. /**
  44316. * Gets the skybox texture created by the helper.
  44317. */
  44318. readonly skyboxTexture: Nullable<BaseTexture>;
  44319. private _skyboxMaterial;
  44320. /**
  44321. * Gets the skybox material created by the helper.
  44322. */
  44323. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44324. private _ground;
  44325. /**
  44326. * Gets the ground mesh created by the helper.
  44327. */
  44328. readonly ground: Nullable<Mesh>;
  44329. private _groundTexture;
  44330. /**
  44331. * Gets the ground texture created by the helper.
  44332. */
  44333. readonly groundTexture: Nullable<BaseTexture>;
  44334. private _groundMirror;
  44335. /**
  44336. * Gets the ground mirror created by the helper.
  44337. */
  44338. readonly groundMirror: Nullable<MirrorTexture>;
  44339. /**
  44340. * Gets the ground mirror render list to helps pushing the meshes
  44341. * you wish in the ground reflection.
  44342. */
  44343. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44344. private _groundMaterial;
  44345. /**
  44346. * Gets the ground material created by the helper.
  44347. */
  44348. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44349. /**
  44350. * Stores the creation options.
  44351. */
  44352. private readonly _scene;
  44353. private _options;
  44354. /**
  44355. * This observable will be notified with any error during the creation of the environment,
  44356. * mainly texture creation errors.
  44357. */
  44358. onErrorObservable: Observable<{
  44359. message?: string;
  44360. exception?: any;
  44361. }>;
  44362. /**
  44363. * constructor
  44364. * @param options
  44365. * @param scene The scene to add the material to
  44366. */
  44367. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44368. /**
  44369. * Updates the background according to the new options
  44370. * @param options
  44371. */
  44372. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44373. /**
  44374. * Sets the primary color of all the available elements.
  44375. * @param color the main color to affect to the ground and the background
  44376. */
  44377. setMainColor(color: Color3): void;
  44378. /**
  44379. * Setup the image processing according to the specified options.
  44380. */
  44381. private _setupImageProcessing;
  44382. /**
  44383. * Setup the environment texture according to the specified options.
  44384. */
  44385. private _setupEnvironmentTexture;
  44386. /**
  44387. * Setup the background according to the specified options.
  44388. */
  44389. private _setupBackground;
  44390. /**
  44391. * Get the scene sizes according to the setup.
  44392. */
  44393. private _getSceneSize;
  44394. /**
  44395. * Setup the ground according to the specified options.
  44396. */
  44397. private _setupGround;
  44398. /**
  44399. * Setup the ground material according to the specified options.
  44400. */
  44401. private _setupGroundMaterial;
  44402. /**
  44403. * Setup the ground diffuse texture according to the specified options.
  44404. */
  44405. private _setupGroundDiffuseTexture;
  44406. /**
  44407. * Setup the ground mirror texture according to the specified options.
  44408. */
  44409. private _setupGroundMirrorTexture;
  44410. /**
  44411. * Setup the ground to receive the mirror texture.
  44412. */
  44413. private _setupMirrorInGroundMaterial;
  44414. /**
  44415. * Setup the skybox according to the specified options.
  44416. */
  44417. private _setupSkybox;
  44418. /**
  44419. * Setup the skybox material according to the specified options.
  44420. */
  44421. private _setupSkyboxMaterial;
  44422. /**
  44423. * Setup the skybox reflection texture according to the specified options.
  44424. */
  44425. private _setupSkyboxReflectionTexture;
  44426. private _errorHandler;
  44427. /**
  44428. * Dispose all the elements created by the Helper.
  44429. */
  44430. dispose(): void;
  44431. }
  44432. }
  44433. declare module "babylonjs/Helpers/photoDome" {
  44434. import { Observable } from "babylonjs/Misc/observable";
  44435. import { Nullable } from "babylonjs/types";
  44436. import { Scene } from "babylonjs/scene";
  44437. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44438. import { Mesh } from "babylonjs/Meshes/mesh";
  44439. import { Texture } from "babylonjs/Materials/Textures/texture";
  44440. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44441. import "babylonjs/Meshes/meshBuilder";
  44442. /**
  44443. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44444. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44445. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44446. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44447. */
  44448. export class PhotoDome extends TransformNode {
  44449. private _useDirectMapping;
  44450. /**
  44451. * The texture being displayed on the sphere
  44452. */
  44453. protected _photoTexture: Texture;
  44454. /**
  44455. * Gets or sets the texture being displayed on the sphere
  44456. */
  44457. photoTexture: Texture;
  44458. /**
  44459. * Observable raised when an error occured while loading the 360 image
  44460. */
  44461. onLoadErrorObservable: Observable<string>;
  44462. /**
  44463. * The skybox material
  44464. */
  44465. protected _material: BackgroundMaterial;
  44466. /**
  44467. * The surface used for the skybox
  44468. */
  44469. protected _mesh: Mesh;
  44470. /**
  44471. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44472. * Also see the options.resolution property.
  44473. */
  44474. fovMultiplier: number;
  44475. /**
  44476. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44477. * @param name Element's name, child elements will append suffixes for their own names.
  44478. * @param urlsOfPhoto defines the url of the photo to display
  44479. * @param options defines an object containing optional or exposed sub element properties
  44480. * @param onError defines a callback called when an error occured while loading the texture
  44481. */
  44482. constructor(name: string, urlOfPhoto: string, options: {
  44483. resolution?: number;
  44484. size?: number;
  44485. useDirectMapping?: boolean;
  44486. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44487. /**
  44488. * Releases resources associated with this node.
  44489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44491. */
  44492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44493. }
  44494. }
  44495. declare module "babylonjs/Misc/textureTools" {
  44496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44497. import { Texture } from "babylonjs/Materials/Textures/texture";
  44498. import { Scene } from "babylonjs/scene";
  44499. /**
  44500. * Class used to host texture specific utilities
  44501. */
  44502. export class TextureTools {
  44503. /**
  44504. * Uses the GPU to create a copy texture rescaled at a given size
  44505. * @param texture Texture to copy from
  44506. * @param width defines the desired width
  44507. * @param height defines the desired height
  44508. * @param useBilinearMode defines if bilinear mode has to be used
  44509. * @return the generated texture
  44510. */
  44511. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44512. /**
  44513. * Gets an environment BRDF texture for a given scene
  44514. * @param scene defines the hosting scene
  44515. * @returns the environment BRDF texture
  44516. */
  44517. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44518. private static _environmentBRDFBase64Texture;
  44519. }
  44520. }
  44521. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44522. /** @hidden */
  44523. export var pbrFragmentDeclaration: {
  44524. name: string;
  44525. shader: string;
  44526. };
  44527. }
  44528. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44529. /** @hidden */
  44530. export var pbrUboDeclaration: {
  44531. name: string;
  44532. shader: string;
  44533. };
  44534. }
  44535. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44536. /** @hidden */
  44537. export var pbrFunctions: {
  44538. name: string;
  44539. shader: string;
  44540. };
  44541. }
  44542. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44543. /** @hidden */
  44544. export var harmonicsFunctions: {
  44545. name: string;
  44546. shader: string;
  44547. };
  44548. }
  44549. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  44550. /** @hidden */
  44551. export var pbrLightFunctions: {
  44552. name: string;
  44553. shader: string;
  44554. };
  44555. }
  44556. declare module "babylonjs/Shaders/pbr.fragment" {
  44557. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44558. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44559. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44560. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44561. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44562. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44563. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44564. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44565. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44566. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44567. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44568. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  44569. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44570. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44571. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44572. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44573. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44574. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44575. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44576. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44577. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44578. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44579. /** @hidden */
  44580. export var pbrPixelShader: {
  44581. name: string;
  44582. shader: string;
  44583. };
  44584. }
  44585. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44586. /** @hidden */
  44587. export var pbrVertexDeclaration: {
  44588. name: string;
  44589. shader: string;
  44590. };
  44591. }
  44592. declare module "babylonjs/Shaders/pbr.vertex" {
  44593. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44594. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44595. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44596. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44597. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44598. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44599. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44600. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44601. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44602. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44603. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44604. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44605. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44606. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44607. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44608. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44609. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44610. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44611. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44612. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44613. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44614. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44615. /** @hidden */
  44616. export var pbrVertexShader: {
  44617. name: string;
  44618. shader: string;
  44619. };
  44620. }
  44621. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44622. import { IAnimatable } from "babylonjs/Misc/tools";
  44623. import { Nullable } from "babylonjs/types";
  44624. import { Scene } from "babylonjs/scene";
  44625. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44626. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44628. import { Mesh } from "babylonjs/Meshes/mesh";
  44629. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44630. import { Material } from "babylonjs/Materials/material";
  44631. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44633. import "babylonjs/Shaders/pbr.fragment";
  44634. import "babylonjs/Shaders/pbr.vertex";
  44635. /**
  44636. * The Physically based material base class of BJS.
  44637. *
  44638. * This offers the main features of a standard PBR material.
  44639. * For more information, please refer to the documentation :
  44640. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44641. */
  44642. export abstract class PBRBaseMaterial extends PushMaterial {
  44643. /**
  44644. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44645. */
  44646. static readonly PBRMATERIAL_OPAQUE: number;
  44647. /**
  44648. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44649. */
  44650. static readonly PBRMATERIAL_ALPHATEST: number;
  44651. /**
  44652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44653. */
  44654. static readonly PBRMATERIAL_ALPHABLEND: number;
  44655. /**
  44656. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44657. * They are also discarded below the alpha cutoff threshold to improve performances.
  44658. */
  44659. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44660. /**
  44661. * Defines the default value of how much AO map is occluding the analytical lights
  44662. * (point spot...).
  44663. */
  44664. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44665. /**
  44666. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44667. */
  44668. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44669. /**
  44670. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44671. * to enhance interoperability with other engines.
  44672. */
  44673. static readonly LIGHTFALLOFF_GLTF: number;
  44674. /**
  44675. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44676. * to enhance interoperability with other materials.
  44677. */
  44678. static readonly LIGHTFALLOFF_STANDARD: number;
  44679. /**
  44680. * Intensity of the direct lights e.g. the four lights available in your scene.
  44681. * This impacts both the direct diffuse and specular highlights.
  44682. */
  44683. protected _directIntensity: number;
  44684. /**
  44685. * Intensity of the emissive part of the material.
  44686. * This helps controlling the emissive effect without modifying the emissive color.
  44687. */
  44688. protected _emissiveIntensity: number;
  44689. /**
  44690. * Intensity of the environment e.g. how much the environment will light the object
  44691. * either through harmonics for rough material or through the refelction for shiny ones.
  44692. */
  44693. protected _environmentIntensity: number;
  44694. /**
  44695. * This is a special control allowing the reduction of the specular highlights coming from the
  44696. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44697. */
  44698. protected _specularIntensity: number;
  44699. /**
  44700. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44701. */
  44702. private _lightingInfos;
  44703. /**
  44704. * Debug Control allowing disabling the bump map on this material.
  44705. */
  44706. protected _disableBumpMap: boolean;
  44707. /**
  44708. * AKA Diffuse Texture in standard nomenclature.
  44709. */
  44710. protected _albedoTexture: BaseTexture;
  44711. /**
  44712. * AKA Occlusion Texture in other nomenclature.
  44713. */
  44714. protected _ambientTexture: BaseTexture;
  44715. /**
  44716. * AKA Occlusion Texture Intensity in other nomenclature.
  44717. */
  44718. protected _ambientTextureStrength: number;
  44719. /**
  44720. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44721. * 1 means it completely occludes it
  44722. * 0 mean it has no impact
  44723. */
  44724. protected _ambientTextureImpactOnAnalyticalLights: number;
  44725. /**
  44726. * Stores the alpha values in a texture.
  44727. */
  44728. protected _opacityTexture: BaseTexture;
  44729. /**
  44730. * Stores the reflection values in a texture.
  44731. */
  44732. protected _reflectionTexture: BaseTexture;
  44733. /**
  44734. * Stores the refraction values in a texture.
  44735. */
  44736. protected _refractionTexture: BaseTexture;
  44737. /**
  44738. * Stores the emissive values in a texture.
  44739. */
  44740. protected _emissiveTexture: BaseTexture;
  44741. /**
  44742. * AKA Specular texture in other nomenclature.
  44743. */
  44744. protected _reflectivityTexture: BaseTexture;
  44745. /**
  44746. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44747. */
  44748. protected _metallicTexture: BaseTexture;
  44749. /**
  44750. * Specifies the metallic scalar of the metallic/roughness workflow.
  44751. * Can also be used to scale the metalness values of the metallic texture.
  44752. */
  44753. protected _metallic: Nullable<number>;
  44754. /**
  44755. * Specifies the roughness scalar of the metallic/roughness workflow.
  44756. * Can also be used to scale the roughness values of the metallic texture.
  44757. */
  44758. protected _roughness: Nullable<number>;
  44759. /**
  44760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44762. */
  44763. protected _microSurfaceTexture: BaseTexture;
  44764. /**
  44765. * Stores surface normal data used to displace a mesh in a texture.
  44766. */
  44767. protected _bumpTexture: BaseTexture;
  44768. /**
  44769. * Stores the pre-calculated light information of a mesh in a texture.
  44770. */
  44771. protected _lightmapTexture: BaseTexture;
  44772. /**
  44773. * The color of a material in ambient lighting.
  44774. */
  44775. protected _ambientColor: Color3;
  44776. /**
  44777. * AKA Diffuse Color in other nomenclature.
  44778. */
  44779. protected _albedoColor: Color3;
  44780. /**
  44781. * AKA Specular Color in other nomenclature.
  44782. */
  44783. protected _reflectivityColor: Color3;
  44784. /**
  44785. * The color applied when light is reflected from a material.
  44786. */
  44787. protected _reflectionColor: Color3;
  44788. /**
  44789. * The color applied when light is emitted from a material.
  44790. */
  44791. protected _emissiveColor: Color3;
  44792. /**
  44793. * AKA Glossiness in other nomenclature.
  44794. */
  44795. protected _microSurface: number;
  44796. /**
  44797. * source material index of refraction (IOR)' / 'destination material IOR.
  44798. */
  44799. protected _indexOfRefraction: number;
  44800. /**
  44801. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44802. */
  44803. protected _invertRefractionY: boolean;
  44804. /**
  44805. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44806. * Materials half opaque for instance using refraction could benefit from this control.
  44807. */
  44808. protected _linkRefractionWithTransparency: boolean;
  44809. /**
  44810. * Specifies that the material will use the light map as a show map.
  44811. */
  44812. protected _useLightmapAsShadowmap: boolean;
  44813. /**
  44814. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44815. * makes the reflect vector face the model (under horizon).
  44816. */
  44817. protected _useHorizonOcclusion: boolean;
  44818. /**
  44819. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44820. * too much the area relying on ambient texture to define their ambient occlusion.
  44821. */
  44822. protected _useRadianceOcclusion: boolean;
  44823. /**
  44824. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44825. */
  44826. protected _useAlphaFromAlbedoTexture: boolean;
  44827. /**
  44828. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44829. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44830. */
  44831. protected _useSpecularOverAlpha: boolean;
  44832. /**
  44833. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44834. */
  44835. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44836. /**
  44837. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44838. */
  44839. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44840. /**
  44841. * Specifies if the metallic texture contains the roughness information in its green channel.
  44842. */
  44843. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44844. /**
  44845. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44846. */
  44847. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44848. /**
  44849. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44850. */
  44851. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44852. /**
  44853. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44854. */
  44855. protected _useAmbientInGrayScale: boolean;
  44856. /**
  44857. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44858. * The material will try to infer what glossiness each pixel should be.
  44859. */
  44860. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44861. /**
  44862. * Defines the falloff type used in this material.
  44863. * It by default is Physical.
  44864. */
  44865. protected _lightFalloff: number;
  44866. /**
  44867. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44868. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44869. */
  44870. protected _useRadianceOverAlpha: boolean;
  44871. /**
  44872. * Allows using an object space normal map (instead of tangent space).
  44873. */
  44874. protected _useObjectSpaceNormalMap: boolean;
  44875. /**
  44876. * Allows using the bump map in parallax mode.
  44877. */
  44878. protected _useParallax: boolean;
  44879. /**
  44880. * Allows using the bump map in parallax occlusion mode.
  44881. */
  44882. protected _useParallaxOcclusion: boolean;
  44883. /**
  44884. * Controls the scale bias of the parallax mode.
  44885. */
  44886. protected _parallaxScaleBias: number;
  44887. /**
  44888. * If sets to true, disables all the lights affecting the material.
  44889. */
  44890. protected _disableLighting: boolean;
  44891. /**
  44892. * Number of Simultaneous lights allowed on the material.
  44893. */
  44894. protected _maxSimultaneousLights: number;
  44895. /**
  44896. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44897. */
  44898. protected _invertNormalMapX: boolean;
  44899. /**
  44900. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44901. */
  44902. protected _invertNormalMapY: boolean;
  44903. /**
  44904. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44905. */
  44906. protected _twoSidedLighting: boolean;
  44907. /**
  44908. * Defines the alpha limits in alpha test mode.
  44909. */
  44910. protected _alphaCutOff: number;
  44911. /**
  44912. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44913. */
  44914. protected _forceAlphaTest: boolean;
  44915. /**
  44916. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44917. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44918. */
  44919. protected _useAlphaFresnel: boolean;
  44920. /**
  44921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44922. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44923. */
  44924. protected _useLinearAlphaFresnel: boolean;
  44925. /**
  44926. * The transparency mode of the material.
  44927. */
  44928. protected _transparencyMode: Nullable<number>;
  44929. /**
  44930. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44931. * from cos thetav and roughness:
  44932. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44933. */
  44934. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44935. /**
  44936. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44937. */
  44938. protected _forceIrradianceInFragment: boolean;
  44939. /**
  44940. * Force normal to face away from face.
  44941. */
  44942. protected _forceNormalForward: boolean;
  44943. /**
  44944. * Enables specular anti aliasing in the PBR shader.
  44945. * It will both interacts on the Geometry for analytical and IBL lighting.
  44946. * It also prefilter the roughness map based on the bump values.
  44947. */
  44948. protected _enableSpecularAntiAliasing: boolean;
  44949. /**
  44950. * Default configuration related to image processing available in the PBR Material.
  44951. */
  44952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44953. /**
  44954. * Keep track of the image processing observer to allow dispose and replace.
  44955. */
  44956. private _imageProcessingObserver;
  44957. /**
  44958. * Attaches a new image processing configuration to the PBR Material.
  44959. * @param configuration
  44960. */
  44961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44962. /**
  44963. * Stores the available render targets.
  44964. */
  44965. private _renderTargets;
  44966. /**
  44967. * Sets the global ambient color for the material used in lighting calculations.
  44968. */
  44969. private _globalAmbientColor;
  44970. /**
  44971. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44972. */
  44973. private _useLogarithmicDepth;
  44974. /**
  44975. * If set to true, no lighting calculations will be applied.
  44976. */
  44977. private _unlit;
  44978. /**
  44979. * Instantiates a new PBRMaterial instance.
  44980. *
  44981. * @param name The material name
  44982. * @param scene The scene the material will be use in.
  44983. */
  44984. constructor(name: string, scene: Scene);
  44985. /**
  44986. * Gets a boolean indicating that current material needs to register RTT
  44987. */
  44988. readonly hasRenderTargetTextures: boolean;
  44989. /**
  44990. * Gets the name of the material class.
  44991. */
  44992. getClassName(): string;
  44993. /**
  44994. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44995. */
  44996. /**
  44997. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44998. */
  44999. useLogarithmicDepth: boolean;
  45000. /**
  45001. * Gets the current transparency mode.
  45002. */
  45003. /**
  45004. * Sets the transparency mode of the material.
  45005. *
  45006. * | Value | Type | Description |
  45007. * | ----- | ----------------------------------- | ----------- |
  45008. * | 0 | OPAQUE | |
  45009. * | 1 | ALPHATEST | |
  45010. * | 2 | ALPHABLEND | |
  45011. * | 3 | ALPHATESTANDBLEND | |
  45012. *
  45013. */
  45014. transparencyMode: Nullable<number>;
  45015. /**
  45016. * Returns true if alpha blending should be disabled.
  45017. */
  45018. private readonly _disableAlphaBlending;
  45019. /**
  45020. * Specifies whether or not this material should be rendered in alpha blend mode.
  45021. */
  45022. needAlphaBlending(): boolean;
  45023. /**
  45024. * Specifies if the mesh will require alpha blending.
  45025. * @param mesh - BJS mesh.
  45026. */
  45027. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45028. /**
  45029. * Specifies whether or not this material should be rendered in alpha test mode.
  45030. */
  45031. needAlphaTesting(): boolean;
  45032. /**
  45033. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45034. */
  45035. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45036. /**
  45037. * Gets the texture used for the alpha test.
  45038. */
  45039. getAlphaTestTexture(): BaseTexture;
  45040. /**
  45041. * Specifies that the submesh is ready to be used.
  45042. * @param mesh - BJS mesh.
  45043. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45044. * @param useInstances - Specifies that instances should be used.
  45045. * @returns - boolean indicating that the submesh is ready or not.
  45046. */
  45047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45048. /**
  45049. * Specifies if the material uses metallic roughness workflow.
  45050. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45051. */
  45052. isMetallicWorkflow(): boolean;
  45053. private _prepareEffect;
  45054. private _prepareDefines;
  45055. /**
  45056. * Force shader compilation
  45057. */
  45058. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45059. clipPlane: boolean;
  45060. }>): void;
  45061. /**
  45062. * Initializes the uniform buffer layout for the shader.
  45063. */
  45064. buildUniformLayout(): void;
  45065. /**
  45066. * Unbinds the textures.
  45067. */
  45068. unbind(): void;
  45069. /**
  45070. * Binds the submesh data.
  45071. * @param world - The world matrix.
  45072. * @param mesh - The BJS mesh.
  45073. * @param subMesh - A submesh of the BJS mesh.
  45074. */
  45075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45076. /**
  45077. * Returns the animatable textures.
  45078. * @returns - Array of animatable textures.
  45079. */
  45080. getAnimatables(): IAnimatable[];
  45081. /**
  45082. * Returns the texture used for reflections.
  45083. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45084. */
  45085. private _getReflectionTexture;
  45086. /**
  45087. * Returns the texture used for refraction or null if none is used.
  45088. * @returns - Refection texture if present. If no refraction texture and refraction
  45089. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45090. */
  45091. private _getRefractionTexture;
  45092. /**
  45093. * Disposes the resources of the material.
  45094. * @param forceDisposeEffect - Forces the disposal of effects.
  45095. * @param forceDisposeTextures - Forces the disposal of all textures.
  45096. */
  45097. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45098. }
  45099. }
  45100. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45101. import { Nullable } from "babylonjs/types";
  45102. import { Scene } from "babylonjs/scene";
  45103. import { Color3 } from "babylonjs/Maths/math";
  45104. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45105. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45107. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45108. /**
  45109. * The Physically based material of BJS.
  45110. *
  45111. * This offers the main features of a standard PBR material.
  45112. * For more information, please refer to the documentation :
  45113. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45114. */
  45115. export class PBRMaterial extends PBRBaseMaterial {
  45116. /**
  45117. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45118. */
  45119. static readonly PBRMATERIAL_OPAQUE: number;
  45120. /**
  45121. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45122. */
  45123. static readonly PBRMATERIAL_ALPHATEST: number;
  45124. /**
  45125. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45126. */
  45127. static readonly PBRMATERIAL_ALPHABLEND: number;
  45128. /**
  45129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45130. * They are also discarded below the alpha cutoff threshold to improve performances.
  45131. */
  45132. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45133. /**
  45134. * Defines the default value of how much AO map is occluding the analytical lights
  45135. * (point spot...).
  45136. */
  45137. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45138. /**
  45139. * Intensity of the direct lights e.g. the four lights available in your scene.
  45140. * This impacts both the direct diffuse and specular highlights.
  45141. */
  45142. directIntensity: number;
  45143. /**
  45144. * Intensity of the emissive part of the material.
  45145. * This helps controlling the emissive effect without modifying the emissive color.
  45146. */
  45147. emissiveIntensity: number;
  45148. /**
  45149. * Intensity of the environment e.g. how much the environment will light the object
  45150. * either through harmonics for rough material or through the refelction for shiny ones.
  45151. */
  45152. environmentIntensity: number;
  45153. /**
  45154. * This is a special control allowing the reduction of the specular highlights coming from the
  45155. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45156. */
  45157. specularIntensity: number;
  45158. /**
  45159. * Debug Control allowing disabling the bump map on this material.
  45160. */
  45161. disableBumpMap: boolean;
  45162. /**
  45163. * AKA Diffuse Texture in standard nomenclature.
  45164. */
  45165. albedoTexture: BaseTexture;
  45166. /**
  45167. * AKA Occlusion Texture in other nomenclature.
  45168. */
  45169. ambientTexture: BaseTexture;
  45170. /**
  45171. * AKA Occlusion Texture Intensity in other nomenclature.
  45172. */
  45173. ambientTextureStrength: number;
  45174. /**
  45175. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45176. * 1 means it completely occludes it
  45177. * 0 mean it has no impact
  45178. */
  45179. ambientTextureImpactOnAnalyticalLights: number;
  45180. /**
  45181. * Stores the alpha values in a texture.
  45182. */
  45183. opacityTexture: BaseTexture;
  45184. /**
  45185. * Stores the reflection values in a texture.
  45186. */
  45187. reflectionTexture: Nullable<BaseTexture>;
  45188. /**
  45189. * Stores the emissive values in a texture.
  45190. */
  45191. emissiveTexture: BaseTexture;
  45192. /**
  45193. * AKA Specular texture in other nomenclature.
  45194. */
  45195. reflectivityTexture: BaseTexture;
  45196. /**
  45197. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45198. */
  45199. metallicTexture: BaseTexture;
  45200. /**
  45201. * Specifies the metallic scalar of the metallic/roughness workflow.
  45202. * Can also be used to scale the metalness values of the metallic texture.
  45203. */
  45204. metallic: Nullable<number>;
  45205. /**
  45206. * Specifies the roughness scalar of the metallic/roughness workflow.
  45207. * Can also be used to scale the roughness values of the metallic texture.
  45208. */
  45209. roughness: Nullable<number>;
  45210. /**
  45211. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45212. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45213. */
  45214. microSurfaceTexture: BaseTexture;
  45215. /**
  45216. * Stores surface normal data used to displace a mesh in a texture.
  45217. */
  45218. bumpTexture: BaseTexture;
  45219. /**
  45220. * Stores the pre-calculated light information of a mesh in a texture.
  45221. */
  45222. lightmapTexture: BaseTexture;
  45223. /**
  45224. * Stores the refracted light information in a texture.
  45225. */
  45226. refractionTexture: BaseTexture;
  45227. /**
  45228. * The color of a material in ambient lighting.
  45229. */
  45230. ambientColor: Color3;
  45231. /**
  45232. * AKA Diffuse Color in other nomenclature.
  45233. */
  45234. albedoColor: Color3;
  45235. /**
  45236. * AKA Specular Color in other nomenclature.
  45237. */
  45238. reflectivityColor: Color3;
  45239. /**
  45240. * The color reflected from the material.
  45241. */
  45242. reflectionColor: Color3;
  45243. /**
  45244. * The color emitted from the material.
  45245. */
  45246. emissiveColor: Color3;
  45247. /**
  45248. * AKA Glossiness in other nomenclature.
  45249. */
  45250. microSurface: number;
  45251. /**
  45252. * source material index of refraction (IOR)' / 'destination material IOR.
  45253. */
  45254. indexOfRefraction: number;
  45255. /**
  45256. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45257. */
  45258. invertRefractionY: boolean;
  45259. /**
  45260. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45261. * Materials half opaque for instance using refraction could benefit from this control.
  45262. */
  45263. linkRefractionWithTransparency: boolean;
  45264. /**
  45265. * If true, the light map contains occlusion information instead of lighting info.
  45266. */
  45267. useLightmapAsShadowmap: boolean;
  45268. /**
  45269. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45270. */
  45271. useAlphaFromAlbedoTexture: boolean;
  45272. /**
  45273. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45274. */
  45275. forceAlphaTest: boolean;
  45276. /**
  45277. * Defines the alpha limits in alpha test mode.
  45278. */
  45279. alphaCutOff: number;
  45280. /**
  45281. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45282. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45283. */
  45284. useSpecularOverAlpha: boolean;
  45285. /**
  45286. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45287. */
  45288. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45289. /**
  45290. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45291. */
  45292. useRoughnessFromMetallicTextureAlpha: boolean;
  45293. /**
  45294. * Specifies if the metallic texture contains the roughness information in its green channel.
  45295. */
  45296. useRoughnessFromMetallicTextureGreen: boolean;
  45297. /**
  45298. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45299. */
  45300. useMetallnessFromMetallicTextureBlue: boolean;
  45301. /**
  45302. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45303. */
  45304. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45305. /**
  45306. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45307. */
  45308. useAmbientInGrayScale: boolean;
  45309. /**
  45310. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45311. * The material will try to infer what glossiness each pixel should be.
  45312. */
  45313. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45314. /**
  45315. * BJS is using an harcoded light falloff based on a manually sets up range.
  45316. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45317. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45318. */
  45319. /**
  45320. * BJS is using an harcoded light falloff based on a manually sets up range.
  45321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45323. */
  45324. usePhysicalLightFalloff: boolean;
  45325. /**
  45326. * In order to support the falloff compatibility with gltf, a special mode has been added
  45327. * to reproduce the gltf light falloff.
  45328. */
  45329. /**
  45330. * In order to support the falloff compatibility with gltf, a special mode has been added
  45331. * to reproduce the gltf light falloff.
  45332. */
  45333. useGLTFLightFalloff: boolean;
  45334. /**
  45335. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45336. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45337. */
  45338. useRadianceOverAlpha: boolean;
  45339. /**
  45340. * Allows using an object space normal map (instead of tangent space).
  45341. */
  45342. useObjectSpaceNormalMap: boolean;
  45343. /**
  45344. * Allows using the bump map in parallax mode.
  45345. */
  45346. useParallax: boolean;
  45347. /**
  45348. * Allows using the bump map in parallax occlusion mode.
  45349. */
  45350. useParallaxOcclusion: boolean;
  45351. /**
  45352. * Controls the scale bias of the parallax mode.
  45353. */
  45354. parallaxScaleBias: number;
  45355. /**
  45356. * If sets to true, disables all the lights affecting the material.
  45357. */
  45358. disableLighting: boolean;
  45359. /**
  45360. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45361. */
  45362. forceIrradianceInFragment: boolean;
  45363. /**
  45364. * Number of Simultaneous lights allowed on the material.
  45365. */
  45366. maxSimultaneousLights: number;
  45367. /**
  45368. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45369. */
  45370. invertNormalMapX: boolean;
  45371. /**
  45372. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45373. */
  45374. invertNormalMapY: boolean;
  45375. /**
  45376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45377. */
  45378. twoSidedLighting: boolean;
  45379. /**
  45380. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45381. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45382. */
  45383. useAlphaFresnel: boolean;
  45384. /**
  45385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45386. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45387. */
  45388. useLinearAlphaFresnel: boolean;
  45389. /**
  45390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45391. * And/Or occlude the blended part.
  45392. */
  45393. environmentBRDFTexture: Nullable<BaseTexture>;
  45394. /**
  45395. * Force normal to face away from face.
  45396. */
  45397. forceNormalForward: boolean;
  45398. /**
  45399. * Enables specular anti aliasing in the PBR shader.
  45400. * It will both interacts on the Geometry for analytical and IBL lighting.
  45401. * It also prefilter the roughness map based on the bump values.
  45402. */
  45403. enableSpecularAntiAliasing: boolean;
  45404. /**
  45405. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45406. * makes the reflect vector face the model (under horizon).
  45407. */
  45408. useHorizonOcclusion: boolean;
  45409. /**
  45410. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45411. * too much the area relying on ambient texture to define their ambient occlusion.
  45412. */
  45413. useRadianceOcclusion: boolean;
  45414. /**
  45415. * If set to true, no lighting calculations will be applied.
  45416. */
  45417. unlit: boolean;
  45418. /**
  45419. * Gets the image processing configuration used either in this material.
  45420. */
  45421. /**
  45422. * Sets the Default image processing configuration used either in the this material.
  45423. *
  45424. * If sets to null, the scene one is in use.
  45425. */
  45426. imageProcessingConfiguration: ImageProcessingConfiguration;
  45427. /**
  45428. * Gets wether the color curves effect is enabled.
  45429. */
  45430. /**
  45431. * Sets wether the color curves effect is enabled.
  45432. */
  45433. cameraColorCurvesEnabled: boolean;
  45434. /**
  45435. * Gets wether the color grading effect is enabled.
  45436. */
  45437. /**
  45438. * Gets wether the color grading effect is enabled.
  45439. */
  45440. cameraColorGradingEnabled: boolean;
  45441. /**
  45442. * Gets wether tonemapping is enabled or not.
  45443. */
  45444. /**
  45445. * Sets wether tonemapping is enabled or not
  45446. */
  45447. cameraToneMappingEnabled: boolean;
  45448. /**
  45449. * The camera exposure used on this material.
  45450. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45451. * This corresponds to a photographic exposure.
  45452. */
  45453. /**
  45454. * The camera exposure used on this material.
  45455. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45456. * This corresponds to a photographic exposure.
  45457. */
  45458. cameraExposure: number;
  45459. /**
  45460. * Gets The camera contrast used on this material.
  45461. */
  45462. /**
  45463. * Sets The camera contrast used on this material.
  45464. */
  45465. cameraContrast: number;
  45466. /**
  45467. * Gets the Color Grading 2D Lookup Texture.
  45468. */
  45469. /**
  45470. * Sets the Color Grading 2D Lookup Texture.
  45471. */
  45472. cameraColorGradingTexture: Nullable<BaseTexture>;
  45473. /**
  45474. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45475. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45476. * 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;
  45477. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45478. */
  45479. /**
  45480. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45481. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45482. * 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;
  45483. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45484. */
  45485. cameraColorCurves: Nullable<ColorCurves>;
  45486. /**
  45487. * Instantiates a new PBRMaterial instance.
  45488. *
  45489. * @param name The material name
  45490. * @param scene The scene the material will be use in.
  45491. */
  45492. constructor(name: string, scene: Scene);
  45493. /**
  45494. * Returns the name of this material class.
  45495. */
  45496. getClassName(): string;
  45497. /**
  45498. * Returns an array of the actively used textures.
  45499. * @returns - Array of BaseTextures
  45500. */
  45501. getActiveTextures(): BaseTexture[];
  45502. /**
  45503. * Checks to see if a texture is used in the material.
  45504. * @param texture - Base texture to use.
  45505. * @returns - Boolean specifying if a texture is used in the material.
  45506. */
  45507. hasTexture(texture: BaseTexture): boolean;
  45508. /**
  45509. * Makes a duplicate of the current material.
  45510. * @param name - name to use for the new material.
  45511. */
  45512. clone(name: string): PBRMaterial;
  45513. /**
  45514. * Serializes this PBR Material.
  45515. * @returns - An object with the serialized material.
  45516. */
  45517. serialize(): any;
  45518. /**
  45519. * Parses a PBR Material from a serialized object.
  45520. * @param source - Serialized object.
  45521. * @param scene - BJS scene instance.
  45522. * @param rootUrl - url for the scene object
  45523. * @returns - PBRMaterial
  45524. */
  45525. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45526. }
  45527. }
  45528. declare module "babylonjs/Helpers/sceneHelpers" {
  45529. import { Nullable } from "babylonjs/types";
  45530. import { Mesh } from "babylonjs/Meshes/mesh";
  45531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45532. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45533. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45534. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45535. import "babylonjs/Meshes/meshBuilder";
  45536. /** @hidden */
  45537. export var _forceSceneHelpersToBundle: boolean;
  45538. module "babylonjs/scene" {
  45539. interface Scene {
  45540. /**
  45541. * Creates a default light for the scene.
  45542. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45543. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45544. */
  45545. createDefaultLight(replace?: boolean): void;
  45546. /**
  45547. * Creates a default camera for the scene.
  45548. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45549. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45550. * @param replace has default false, when true replaces the active camera in the scene
  45551. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45552. */
  45553. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45554. /**
  45555. * Creates a default camera and a default light.
  45556. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45557. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45558. * @param replace has the default false, when true replaces the active camera/light in the scene
  45559. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45560. */
  45561. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45562. /**
  45563. * Creates a new sky box
  45564. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45565. * @param environmentTexture defines the texture to use as environment texture
  45566. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45567. * @param scale defines the overall scale of the skybox
  45568. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45569. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45570. * @returns a new mesh holding the sky box
  45571. */
  45572. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45573. /**
  45574. * Creates a new environment
  45575. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45576. * @param options defines the options you can use to configure the environment
  45577. * @returns the new EnvironmentHelper
  45578. */
  45579. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45580. /**
  45581. * Creates a new VREXperienceHelper
  45582. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45583. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45584. * @returns a new VREXperienceHelper
  45585. */
  45586. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45587. /**
  45588. * Creates a new XREXperienceHelper
  45589. * @see http://doc.babylonjs.com/how_to/webxr
  45590. * @returns a promise for a new XREXperienceHelper
  45591. */
  45592. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45593. }
  45594. }
  45595. }
  45596. declare module "babylonjs/Helpers/videoDome" {
  45597. import { Scene } from "babylonjs/scene";
  45598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45599. import { Mesh } from "babylonjs/Meshes/mesh";
  45600. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45601. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45602. import "babylonjs/Meshes/meshBuilder";
  45603. /**
  45604. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45605. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45606. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45607. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45608. */
  45609. export class VideoDome extends TransformNode {
  45610. private _useDirectMapping;
  45611. /**
  45612. * The video texture being displayed on the sphere
  45613. */
  45614. protected _videoTexture: VideoTexture;
  45615. /**
  45616. * Gets the video texture being displayed on the sphere
  45617. */
  45618. readonly videoTexture: VideoTexture;
  45619. /**
  45620. * The skybox material
  45621. */
  45622. protected _material: BackgroundMaterial;
  45623. /**
  45624. * The surface used for the skybox
  45625. */
  45626. protected _mesh: Mesh;
  45627. /**
  45628. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45629. * Also see the options.resolution property.
  45630. */
  45631. fovMultiplier: number;
  45632. /**
  45633. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45634. * @param name Element's name, child elements will append suffixes for their own names.
  45635. * @param urlsOrVideo defines the url(s) or the video element to use
  45636. * @param options An object containing optional or exposed sub element properties
  45637. */
  45638. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45639. resolution?: number;
  45640. clickToPlay?: boolean;
  45641. autoPlay?: boolean;
  45642. loop?: boolean;
  45643. size?: number;
  45644. poster?: string;
  45645. useDirectMapping?: boolean;
  45646. }, scene: Scene);
  45647. /**
  45648. * Releases resources associated with this node.
  45649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45651. */
  45652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45653. }
  45654. }
  45655. declare module "babylonjs/Helpers/index" {
  45656. export * from "babylonjs/Helpers/environmentHelper";
  45657. export * from "babylonjs/Helpers/photoDome";
  45658. export * from "babylonjs/Helpers/sceneHelpers";
  45659. export * from "babylonjs/Helpers/videoDome";
  45660. }
  45661. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45662. import { PerfCounter } from "babylonjs/Misc/tools";
  45663. import { IDisposable } from "babylonjs/scene";
  45664. import { Engine } from "babylonjs/Engines/engine";
  45665. /**
  45666. * This class can be used to get instrumentation data from a Babylon engine
  45667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45668. */
  45669. export class EngineInstrumentation implements IDisposable {
  45670. /**
  45671. * Define the instrumented engine.
  45672. */
  45673. engine: Engine;
  45674. private _captureGPUFrameTime;
  45675. private _gpuFrameTimeToken;
  45676. private _gpuFrameTime;
  45677. private _captureShaderCompilationTime;
  45678. private _shaderCompilationTime;
  45679. private _onBeginFrameObserver;
  45680. private _onEndFrameObserver;
  45681. private _onBeforeShaderCompilationObserver;
  45682. private _onAfterShaderCompilationObserver;
  45683. /**
  45684. * Gets the perf counter used for GPU frame time
  45685. */
  45686. readonly gpuFrameTimeCounter: PerfCounter;
  45687. /**
  45688. * Gets the GPU frame time capture status
  45689. */
  45690. /**
  45691. * Enable or disable the GPU frame time capture
  45692. */
  45693. captureGPUFrameTime: boolean;
  45694. /**
  45695. * Gets the perf counter used for shader compilation time
  45696. */
  45697. readonly shaderCompilationTimeCounter: PerfCounter;
  45698. /**
  45699. * Gets the shader compilation time capture status
  45700. */
  45701. /**
  45702. * Enable or disable the shader compilation time capture
  45703. */
  45704. captureShaderCompilationTime: boolean;
  45705. /**
  45706. * Instantiates a new engine instrumentation.
  45707. * This class can be used to get instrumentation data from a Babylon engine
  45708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45709. * @param engine Defines the engine to instrument
  45710. */
  45711. constructor(
  45712. /**
  45713. * Define the instrumented engine.
  45714. */
  45715. engine: Engine);
  45716. /**
  45717. * Dispose and release associated resources.
  45718. */
  45719. dispose(): void;
  45720. }
  45721. }
  45722. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45723. import { PerfCounter } from "babylonjs/Misc/tools";
  45724. import { Scene, IDisposable } from "babylonjs/scene";
  45725. /**
  45726. * This class can be used to get instrumentation data from a Babylon engine
  45727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45728. */
  45729. export class SceneInstrumentation implements IDisposable {
  45730. /**
  45731. * Defines the scene to instrument
  45732. */
  45733. scene: Scene;
  45734. private _captureActiveMeshesEvaluationTime;
  45735. private _activeMeshesEvaluationTime;
  45736. private _captureRenderTargetsRenderTime;
  45737. private _renderTargetsRenderTime;
  45738. private _captureFrameTime;
  45739. private _frameTime;
  45740. private _captureRenderTime;
  45741. private _renderTime;
  45742. private _captureInterFrameTime;
  45743. private _interFrameTime;
  45744. private _captureParticlesRenderTime;
  45745. private _particlesRenderTime;
  45746. private _captureSpritesRenderTime;
  45747. private _spritesRenderTime;
  45748. private _capturePhysicsTime;
  45749. private _physicsTime;
  45750. private _captureAnimationsTime;
  45751. private _animationsTime;
  45752. private _captureCameraRenderTime;
  45753. private _cameraRenderTime;
  45754. private _onBeforeActiveMeshesEvaluationObserver;
  45755. private _onAfterActiveMeshesEvaluationObserver;
  45756. private _onBeforeRenderTargetsRenderObserver;
  45757. private _onAfterRenderTargetsRenderObserver;
  45758. private _onAfterRenderObserver;
  45759. private _onBeforeDrawPhaseObserver;
  45760. private _onAfterDrawPhaseObserver;
  45761. private _onBeforeAnimationsObserver;
  45762. private _onBeforeParticlesRenderingObserver;
  45763. private _onAfterParticlesRenderingObserver;
  45764. private _onBeforeSpritesRenderingObserver;
  45765. private _onAfterSpritesRenderingObserver;
  45766. private _onBeforePhysicsObserver;
  45767. private _onAfterPhysicsObserver;
  45768. private _onAfterAnimationsObserver;
  45769. private _onBeforeCameraRenderObserver;
  45770. private _onAfterCameraRenderObserver;
  45771. /**
  45772. * Gets the perf counter used for active meshes evaluation time
  45773. */
  45774. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45775. /**
  45776. * Gets the active meshes evaluation time capture status
  45777. */
  45778. /**
  45779. * Enable or disable the active meshes evaluation time capture
  45780. */
  45781. captureActiveMeshesEvaluationTime: boolean;
  45782. /**
  45783. * Gets the perf counter used for render targets render time
  45784. */
  45785. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45786. /**
  45787. * Gets the render targets render time capture status
  45788. */
  45789. /**
  45790. * Enable or disable the render targets render time capture
  45791. */
  45792. captureRenderTargetsRenderTime: boolean;
  45793. /**
  45794. * Gets the perf counter used for particles render time
  45795. */
  45796. readonly particlesRenderTimeCounter: PerfCounter;
  45797. /**
  45798. * Gets the particles render time capture status
  45799. */
  45800. /**
  45801. * Enable or disable the particles render time capture
  45802. */
  45803. captureParticlesRenderTime: boolean;
  45804. /**
  45805. * Gets the perf counter used for sprites render time
  45806. */
  45807. readonly spritesRenderTimeCounter: PerfCounter;
  45808. /**
  45809. * Gets the sprites render time capture status
  45810. */
  45811. /**
  45812. * Enable or disable the sprites render time capture
  45813. */
  45814. captureSpritesRenderTime: boolean;
  45815. /**
  45816. * Gets the perf counter used for physics time
  45817. */
  45818. readonly physicsTimeCounter: PerfCounter;
  45819. /**
  45820. * Gets the physics time capture status
  45821. */
  45822. /**
  45823. * Enable or disable the physics time capture
  45824. */
  45825. capturePhysicsTime: boolean;
  45826. /**
  45827. * Gets the perf counter used for animations time
  45828. */
  45829. readonly animationsTimeCounter: PerfCounter;
  45830. /**
  45831. * Gets the animations time capture status
  45832. */
  45833. /**
  45834. * Enable or disable the animations time capture
  45835. */
  45836. captureAnimationsTime: boolean;
  45837. /**
  45838. * Gets the perf counter used for frame time capture
  45839. */
  45840. readonly frameTimeCounter: PerfCounter;
  45841. /**
  45842. * Gets the frame time capture status
  45843. */
  45844. /**
  45845. * Enable or disable the frame time capture
  45846. */
  45847. captureFrameTime: boolean;
  45848. /**
  45849. * Gets the perf counter used for inter-frames time capture
  45850. */
  45851. readonly interFrameTimeCounter: PerfCounter;
  45852. /**
  45853. * Gets the inter-frames time capture status
  45854. */
  45855. /**
  45856. * Enable or disable the inter-frames time capture
  45857. */
  45858. captureInterFrameTime: boolean;
  45859. /**
  45860. * Gets the perf counter used for render time capture
  45861. */
  45862. readonly renderTimeCounter: PerfCounter;
  45863. /**
  45864. * Gets the render time capture status
  45865. */
  45866. /**
  45867. * Enable or disable the render time capture
  45868. */
  45869. captureRenderTime: boolean;
  45870. /**
  45871. * Gets the perf counter used for camera render time capture
  45872. */
  45873. readonly cameraRenderTimeCounter: PerfCounter;
  45874. /**
  45875. * Gets the camera render time capture status
  45876. */
  45877. /**
  45878. * Enable or disable the camera render time capture
  45879. */
  45880. captureCameraRenderTime: boolean;
  45881. /**
  45882. * Gets the perf counter used for draw calls
  45883. */
  45884. readonly drawCallsCounter: PerfCounter;
  45885. /**
  45886. * Gets the perf counter used for texture collisions
  45887. */
  45888. readonly textureCollisionsCounter: PerfCounter;
  45889. /**
  45890. * Instantiates a new scene instrumentation.
  45891. * This class can be used to get instrumentation data from a Babylon engine
  45892. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45893. * @param scene Defines the scene to instrument
  45894. */
  45895. constructor(
  45896. /**
  45897. * Defines the scene to instrument
  45898. */
  45899. scene: Scene);
  45900. /**
  45901. * Dispose and release associated resources.
  45902. */
  45903. dispose(): void;
  45904. }
  45905. }
  45906. declare module "babylonjs/Instrumentation/index" {
  45907. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45908. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45909. export * from "babylonjs/Instrumentation/timeToken";
  45910. }
  45911. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45912. /** @hidden */
  45913. export var glowMapGenerationPixelShader: {
  45914. name: string;
  45915. shader: string;
  45916. };
  45917. }
  45918. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45919. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45922. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45924. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45925. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45926. /** @hidden */
  45927. export var glowMapGenerationVertexShader: {
  45928. name: string;
  45929. shader: string;
  45930. };
  45931. }
  45932. declare module "babylonjs/Layers/effectLayer" {
  45933. import { Observable } from "babylonjs/Misc/observable";
  45934. import { Nullable } from "babylonjs/types";
  45935. import { Camera } from "babylonjs/Cameras/camera";
  45936. import { Scene } from "babylonjs/scene";
  45937. import { Color4, ISize } from "babylonjs/Maths/math";
  45938. import { Engine } from "babylonjs/Engines/engine";
  45939. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45941. import { Mesh } from "babylonjs/Meshes/mesh";
  45942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45944. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45945. import { Effect } from "babylonjs/Materials/effect";
  45946. import { Material } from "babylonjs/Materials/material";
  45947. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45948. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45949. /**
  45950. * Effect layer options. This helps customizing the behaviour
  45951. * of the effect layer.
  45952. */
  45953. export interface IEffectLayerOptions {
  45954. /**
  45955. * Multiplication factor apply to the canvas size to compute the render target size
  45956. * used to generated the objects (the smaller the faster).
  45957. */
  45958. mainTextureRatio: number;
  45959. /**
  45960. * Enforces a fixed size texture to ensure effect stability across devices.
  45961. */
  45962. mainTextureFixedSize?: number;
  45963. /**
  45964. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45965. */
  45966. alphaBlendingMode: number;
  45967. /**
  45968. * The camera attached to the layer.
  45969. */
  45970. camera: Nullable<Camera>;
  45971. /**
  45972. * The rendering group to draw the layer in.
  45973. */
  45974. renderingGroupId: number;
  45975. }
  45976. /**
  45977. * The effect layer Helps adding post process effect blended with the main pass.
  45978. *
  45979. * This can be for instance use to generate glow or higlight effects on the scene.
  45980. *
  45981. * The effect layer class can not be used directly and is intented to inherited from to be
  45982. * customized per effects.
  45983. */
  45984. export abstract class EffectLayer {
  45985. private _vertexBuffers;
  45986. private _indexBuffer;
  45987. private _cachedDefines;
  45988. private _effectLayerMapGenerationEffect;
  45989. private _effectLayerOptions;
  45990. private _mergeEffect;
  45991. protected _scene: Scene;
  45992. protected _engine: Engine;
  45993. protected _maxSize: number;
  45994. protected _mainTextureDesiredSize: ISize;
  45995. protected _mainTexture: RenderTargetTexture;
  45996. protected _shouldRender: boolean;
  45997. protected _postProcesses: PostProcess[];
  45998. protected _textures: BaseTexture[];
  45999. protected _emissiveTextureAndColor: {
  46000. texture: Nullable<BaseTexture>;
  46001. color: Color4;
  46002. };
  46003. /**
  46004. * The name of the layer
  46005. */
  46006. name: string;
  46007. /**
  46008. * The clear color of the texture used to generate the glow map.
  46009. */
  46010. neutralColor: Color4;
  46011. /**
  46012. * Specifies wether the highlight layer is enabled or not.
  46013. */
  46014. isEnabled: boolean;
  46015. /**
  46016. * Gets the camera attached to the layer.
  46017. */
  46018. readonly camera: Nullable<Camera>;
  46019. /**
  46020. * Gets the rendering group id the layer should render in.
  46021. */
  46022. readonly renderingGroupId: number;
  46023. /**
  46024. * An event triggered when the effect layer has been disposed.
  46025. */
  46026. onDisposeObservable: Observable<EffectLayer>;
  46027. /**
  46028. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46029. */
  46030. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46031. /**
  46032. * An event triggered when the generated texture is being merged in the scene.
  46033. */
  46034. onBeforeComposeObservable: Observable<EffectLayer>;
  46035. /**
  46036. * An event triggered when the generated texture has been merged in the scene.
  46037. */
  46038. onAfterComposeObservable: Observable<EffectLayer>;
  46039. /**
  46040. * An event triggered when the efffect layer changes its size.
  46041. */
  46042. onSizeChangedObservable: Observable<EffectLayer>;
  46043. /** @hidden */
  46044. static _SceneComponentInitialization: (scene: Scene) => void;
  46045. /**
  46046. * Instantiates a new effect Layer and references it in the scene.
  46047. * @param name The name of the layer
  46048. * @param scene The scene to use the layer in
  46049. */
  46050. constructor(
  46051. /** The Friendly of the effect in the scene */
  46052. name: string, scene: Scene);
  46053. /**
  46054. * Get the effect name of the layer.
  46055. * @return The effect name
  46056. */
  46057. abstract getEffectName(): string;
  46058. /**
  46059. * Checks for the readiness of the element composing the layer.
  46060. * @param subMesh the mesh to check for
  46061. * @param useInstances specify wether or not to use instances to render the mesh
  46062. * @return true if ready otherwise, false
  46063. */
  46064. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46065. /**
  46066. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46067. * @returns true if the effect requires stencil during the main canvas render pass.
  46068. */
  46069. abstract needStencil(): boolean;
  46070. /**
  46071. * Create the merge effect. This is the shader use to blit the information back
  46072. * to the main canvas at the end of the scene rendering.
  46073. * @returns The effect containing the shader used to merge the effect on the main canvas
  46074. */
  46075. protected abstract _createMergeEffect(): Effect;
  46076. /**
  46077. * Creates the render target textures and post processes used in the effect layer.
  46078. */
  46079. protected abstract _createTextureAndPostProcesses(): void;
  46080. /**
  46081. * Implementation specific of rendering the generating effect on the main canvas.
  46082. * @param effect The effect used to render through
  46083. */
  46084. protected abstract _internalRender(effect: Effect): void;
  46085. /**
  46086. * Sets the required values for both the emissive texture and and the main color.
  46087. */
  46088. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46089. /**
  46090. * Free any resources and references associated to a mesh.
  46091. * Internal use
  46092. * @param mesh The mesh to free.
  46093. */
  46094. abstract _disposeMesh(mesh: Mesh): void;
  46095. /**
  46096. * Serializes this layer (Glow or Highlight for example)
  46097. * @returns a serialized layer object
  46098. */
  46099. abstract serialize?(): any;
  46100. /**
  46101. * Initializes the effect layer with the required options.
  46102. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46103. */
  46104. protected _init(options: Partial<IEffectLayerOptions>): void;
  46105. /**
  46106. * Generates the index buffer of the full screen quad blending to the main canvas.
  46107. */
  46108. private _generateIndexBuffer;
  46109. /**
  46110. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46111. */
  46112. private _genrateVertexBuffer;
  46113. /**
  46114. * Sets the main texture desired size which is the closest power of two
  46115. * of the engine canvas size.
  46116. */
  46117. private _setMainTextureSize;
  46118. /**
  46119. * Creates the main texture for the effect layer.
  46120. */
  46121. protected _createMainTexture(): void;
  46122. /**
  46123. * Adds specific effects defines.
  46124. * @param defines The defines to add specifics to.
  46125. */
  46126. protected _addCustomEffectDefines(defines: string[]): void;
  46127. /**
  46128. * Checks for the readiness of the element composing the layer.
  46129. * @param subMesh the mesh to check for
  46130. * @param useInstances specify wether or not to use instances to render the mesh
  46131. * @param emissiveTexture the associated emissive texture used to generate the glow
  46132. * @return true if ready otherwise, false
  46133. */
  46134. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46135. /**
  46136. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46137. */
  46138. render(): void;
  46139. /**
  46140. * Determine if a given mesh will be used in the current effect.
  46141. * @param mesh mesh to test
  46142. * @returns true if the mesh will be used
  46143. */
  46144. hasMesh(mesh: AbstractMesh): boolean;
  46145. /**
  46146. * Returns true if the layer contains information to display, otherwise false.
  46147. * @returns true if the glow layer should be rendered
  46148. */
  46149. shouldRender(): boolean;
  46150. /**
  46151. * Returns true if the mesh should render, otherwise false.
  46152. * @param mesh The mesh to render
  46153. * @returns true if it should render otherwise false
  46154. */
  46155. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46156. /**
  46157. * Returns true if the mesh can be rendered, otherwise false.
  46158. * @param mesh The mesh to render
  46159. * @param material The material used on the mesh
  46160. * @returns true if it can be rendered otherwise false
  46161. */
  46162. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46163. /**
  46164. * Returns true if the mesh should render, otherwise false.
  46165. * @param mesh The mesh to render
  46166. * @returns true if it should render otherwise false
  46167. */
  46168. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46169. /**
  46170. * Renders the submesh passed in parameter to the generation map.
  46171. */
  46172. protected _renderSubMesh(subMesh: SubMesh): void;
  46173. /**
  46174. * Rebuild the required buffers.
  46175. * @hidden Internal use only.
  46176. */
  46177. _rebuild(): void;
  46178. /**
  46179. * Dispose only the render target textures and post process.
  46180. */
  46181. private _disposeTextureAndPostProcesses;
  46182. /**
  46183. * Dispose the highlight layer and free resources.
  46184. */
  46185. dispose(): void;
  46186. /**
  46187. * Gets the class name of the effect layer
  46188. * @returns the string with the class name of the effect layer
  46189. */
  46190. getClassName(): string;
  46191. /**
  46192. * Creates an effect layer from parsed effect layer data
  46193. * @param parsedEffectLayer defines effect layer data
  46194. * @param scene defines the current scene
  46195. * @param rootUrl defines the root URL containing the effect layer information
  46196. * @returns a parsed effect Layer
  46197. */
  46198. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46199. }
  46200. }
  46201. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46202. import { Scene } from "babylonjs/scene";
  46203. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46204. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46205. import { AbstractScene } from "babylonjs/abstractScene";
  46206. module "babylonjs/abstractScene" {
  46207. interface AbstractScene {
  46208. /**
  46209. * The list of effect layers (highlights/glow) added to the scene
  46210. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46211. * @see http://doc.babylonjs.com/how_to/glow_layer
  46212. */
  46213. effectLayers: Array<EffectLayer>;
  46214. /**
  46215. * Removes the given effect layer from this scene.
  46216. * @param toRemove defines the effect layer to remove
  46217. * @returns the index of the removed effect layer
  46218. */
  46219. removeEffectLayer(toRemove: EffectLayer): number;
  46220. /**
  46221. * Adds the given effect layer to this scene
  46222. * @param newEffectLayer defines the effect layer to add
  46223. */
  46224. addEffectLayer(newEffectLayer: EffectLayer): void;
  46225. }
  46226. }
  46227. /**
  46228. * Defines the layer scene component responsible to manage any effect layers
  46229. * in a given scene.
  46230. */
  46231. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46232. /**
  46233. * The component name helpfull to identify the component in the list of scene components.
  46234. */
  46235. readonly name: string;
  46236. /**
  46237. * The scene the component belongs to.
  46238. */
  46239. scene: Scene;
  46240. private _engine;
  46241. private _renderEffects;
  46242. private _needStencil;
  46243. private _previousStencilState;
  46244. /**
  46245. * Creates a new instance of the component for the given scene
  46246. * @param scene Defines the scene to register the component in
  46247. */
  46248. constructor(scene: Scene);
  46249. /**
  46250. * Registers the component in a given scene
  46251. */
  46252. register(): void;
  46253. /**
  46254. * Rebuilds the elements related to this component in case of
  46255. * context lost for instance.
  46256. */
  46257. rebuild(): void;
  46258. /**
  46259. * Serializes the component data to the specified json object
  46260. * @param serializationObject The object to serialize to
  46261. */
  46262. serialize(serializationObject: any): void;
  46263. /**
  46264. * Adds all the element from the container to the scene
  46265. * @param container the container holding the elements
  46266. */
  46267. addFromContainer(container: AbstractScene): void;
  46268. /**
  46269. * Removes all the elements in the container from the scene
  46270. * @param container contains the elements to remove
  46271. */
  46272. removeFromContainer(container: AbstractScene): void;
  46273. /**
  46274. * Disposes the component and the associated ressources.
  46275. */
  46276. dispose(): void;
  46277. private _isReadyForMesh;
  46278. private _renderMainTexture;
  46279. private _setStencil;
  46280. private _setStencilBack;
  46281. private _draw;
  46282. private _drawCamera;
  46283. private _drawRenderingGroup;
  46284. }
  46285. }
  46286. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46287. /** @hidden */
  46288. export var glowMapMergePixelShader: {
  46289. name: string;
  46290. shader: string;
  46291. };
  46292. }
  46293. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46294. /** @hidden */
  46295. export var glowMapMergeVertexShader: {
  46296. name: string;
  46297. shader: string;
  46298. };
  46299. }
  46300. declare module "babylonjs/Layers/glowLayer" {
  46301. import { Nullable } from "babylonjs/types";
  46302. import { Camera } from "babylonjs/Cameras/camera";
  46303. import { Scene } from "babylonjs/scene";
  46304. import { Color4 } from "babylonjs/Maths/math";
  46305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46307. import { Mesh } from "babylonjs/Meshes/mesh";
  46308. import { Texture } from "babylonjs/Materials/Textures/texture";
  46309. import { Effect } from "babylonjs/Materials/effect";
  46310. import { Material } from "babylonjs/Materials/material";
  46311. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46312. import "babylonjs/Shaders/glowMapMerge.fragment";
  46313. import "babylonjs/Shaders/glowMapMerge.vertex";
  46314. module "babylonjs/abstractScene" {
  46315. interface AbstractScene {
  46316. /**
  46317. * Return a the first highlight layer of the scene with a given name.
  46318. * @param name The name of the highlight layer to look for.
  46319. * @return The highlight layer if found otherwise null.
  46320. */
  46321. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46322. }
  46323. }
  46324. /**
  46325. * Glow layer options. This helps customizing the behaviour
  46326. * of the glow layer.
  46327. */
  46328. export interface IGlowLayerOptions {
  46329. /**
  46330. * Multiplication factor apply to the canvas size to compute the render target size
  46331. * used to generated the glowing objects (the smaller the faster).
  46332. */
  46333. mainTextureRatio: number;
  46334. /**
  46335. * Enforces a fixed size texture to ensure resize independant blur.
  46336. */
  46337. mainTextureFixedSize?: number;
  46338. /**
  46339. * How big is the kernel of the blur texture.
  46340. */
  46341. blurKernelSize: number;
  46342. /**
  46343. * The camera attached to the layer.
  46344. */
  46345. camera: Nullable<Camera>;
  46346. /**
  46347. * Enable MSAA by chosing the number of samples.
  46348. */
  46349. mainTextureSamples?: number;
  46350. /**
  46351. * The rendering group to draw the layer in.
  46352. */
  46353. renderingGroupId: number;
  46354. }
  46355. /**
  46356. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46357. *
  46358. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46359. * glowy meshes to your scene.
  46360. *
  46361. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46362. */
  46363. export class GlowLayer extends EffectLayer {
  46364. /**
  46365. * Effect Name of the layer.
  46366. */
  46367. static readonly EffectName: string;
  46368. /**
  46369. * The default blur kernel size used for the glow.
  46370. */
  46371. static DefaultBlurKernelSize: number;
  46372. /**
  46373. * The default texture size ratio used for the glow.
  46374. */
  46375. static DefaultTextureRatio: number;
  46376. /**
  46377. * Sets the kernel size of the blur.
  46378. */
  46379. /**
  46380. * Gets the kernel size of the blur.
  46381. */
  46382. blurKernelSize: number;
  46383. /**
  46384. * Sets the glow intensity.
  46385. */
  46386. /**
  46387. * Gets the glow intensity.
  46388. */
  46389. intensity: number;
  46390. private _options;
  46391. private _intensity;
  46392. private _horizontalBlurPostprocess1;
  46393. private _verticalBlurPostprocess1;
  46394. private _horizontalBlurPostprocess2;
  46395. private _verticalBlurPostprocess2;
  46396. private _blurTexture1;
  46397. private _blurTexture2;
  46398. private _postProcesses1;
  46399. private _postProcesses2;
  46400. private _includedOnlyMeshes;
  46401. private _excludedMeshes;
  46402. /**
  46403. * Callback used to let the user override the color selection on a per mesh basis
  46404. */
  46405. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46406. /**
  46407. * Callback used to let the user override the texture selection on a per mesh basis
  46408. */
  46409. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46410. /**
  46411. * Instantiates a new glow Layer and references it to the scene.
  46412. * @param name The name of the layer
  46413. * @param scene The scene to use the layer in
  46414. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46415. */
  46416. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46417. /**
  46418. * Get the effect name of the layer.
  46419. * @return The effect name
  46420. */
  46421. getEffectName(): string;
  46422. /**
  46423. * Create the merge effect. This is the shader use to blit the information back
  46424. * to the main canvas at the end of the scene rendering.
  46425. */
  46426. protected _createMergeEffect(): Effect;
  46427. /**
  46428. * Creates the render target textures and post processes used in the glow layer.
  46429. */
  46430. protected _createTextureAndPostProcesses(): void;
  46431. /**
  46432. * Checks for the readiness of the element composing the layer.
  46433. * @param subMesh the mesh to check for
  46434. * @param useInstances specify wether or not to use instances to render the mesh
  46435. * @param emissiveTexture the associated emissive texture used to generate the glow
  46436. * @return true if ready otherwise, false
  46437. */
  46438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46439. /**
  46440. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46441. */
  46442. needStencil(): boolean;
  46443. /**
  46444. * Returns true if the mesh can be rendered, otherwise false.
  46445. * @param mesh The mesh to render
  46446. * @param material The material used on the mesh
  46447. * @returns true if it can be rendered otherwise false
  46448. */
  46449. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46450. /**
  46451. * Implementation specific of rendering the generating effect on the main canvas.
  46452. * @param effect The effect used to render through
  46453. */
  46454. protected _internalRender(effect: Effect): void;
  46455. /**
  46456. * Sets the required values for both the emissive texture and and the main color.
  46457. */
  46458. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46459. /**
  46460. * Returns true if the mesh should render, otherwise false.
  46461. * @param mesh The mesh to render
  46462. * @returns true if it should render otherwise false
  46463. */
  46464. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46465. /**
  46466. * Adds specific effects defines.
  46467. * @param defines The defines to add specifics to.
  46468. */
  46469. protected _addCustomEffectDefines(defines: string[]): void;
  46470. /**
  46471. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46472. * @param mesh The mesh to exclude from the glow layer
  46473. */
  46474. addExcludedMesh(mesh: Mesh): void;
  46475. /**
  46476. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46477. * @param mesh The mesh to remove
  46478. */
  46479. removeExcludedMesh(mesh: Mesh): void;
  46480. /**
  46481. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46482. * @param mesh The mesh to include in the glow layer
  46483. */
  46484. addIncludedOnlyMesh(mesh: Mesh): void;
  46485. /**
  46486. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46487. * @param mesh The mesh to remove
  46488. */
  46489. removeIncludedOnlyMesh(mesh: Mesh): void;
  46490. /**
  46491. * Determine if a given mesh will be used in the glow layer
  46492. * @param mesh The mesh to test
  46493. * @returns true if the mesh will be highlighted by the current glow layer
  46494. */
  46495. hasMesh(mesh: AbstractMesh): boolean;
  46496. /**
  46497. * Free any resources and references associated to a mesh.
  46498. * Internal use
  46499. * @param mesh The mesh to free.
  46500. * @hidden
  46501. */
  46502. _disposeMesh(mesh: Mesh): void;
  46503. /**
  46504. * Gets the class name of the effect layer
  46505. * @returns the string with the class name of the effect layer
  46506. */
  46507. getClassName(): string;
  46508. /**
  46509. * Serializes this glow layer
  46510. * @returns a serialized glow layer object
  46511. */
  46512. serialize(): any;
  46513. /**
  46514. * Creates a Glow Layer from parsed glow layer data
  46515. * @param parsedGlowLayer defines glow layer data
  46516. * @param scene defines the current scene
  46517. * @param rootUrl defines the root URL containing the glow layer information
  46518. * @returns a parsed Glow Layer
  46519. */
  46520. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46521. }
  46522. }
  46523. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46524. /** @hidden */
  46525. export var glowBlurPostProcessPixelShader: {
  46526. name: string;
  46527. shader: string;
  46528. };
  46529. }
  46530. declare module "babylonjs/Layers/highlightLayer" {
  46531. import { Observable } from "babylonjs/Misc/observable";
  46532. import { Nullable } from "babylonjs/types";
  46533. import { Camera } from "babylonjs/Cameras/camera";
  46534. import { Scene } from "babylonjs/scene";
  46535. import { Color3, Color4 } from "babylonjs/Maths/math";
  46536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46538. import { Mesh } from "babylonjs/Meshes/mesh";
  46539. import { Effect } from "babylonjs/Materials/effect";
  46540. import { Material } from "babylonjs/Materials/material";
  46541. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46542. import "babylonjs/Shaders/glowMapMerge.fragment";
  46543. import "babylonjs/Shaders/glowMapMerge.vertex";
  46544. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46545. module "babylonjs/abstractScene" {
  46546. interface AbstractScene {
  46547. /**
  46548. * Return a the first highlight layer of the scene with a given name.
  46549. * @param name The name of the highlight layer to look for.
  46550. * @return The highlight layer if found otherwise null.
  46551. */
  46552. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46553. }
  46554. }
  46555. /**
  46556. * Highlight layer options. This helps customizing the behaviour
  46557. * of the highlight layer.
  46558. */
  46559. export interface IHighlightLayerOptions {
  46560. /**
  46561. * Multiplication factor apply to the canvas size to compute the render target size
  46562. * used to generated the glowing objects (the smaller the faster).
  46563. */
  46564. mainTextureRatio: number;
  46565. /**
  46566. * Enforces a fixed size texture to ensure resize independant blur.
  46567. */
  46568. mainTextureFixedSize?: number;
  46569. /**
  46570. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46571. * of the picture to blur (the smaller the faster).
  46572. */
  46573. blurTextureSizeRatio: number;
  46574. /**
  46575. * How big in texel of the blur texture is the vertical blur.
  46576. */
  46577. blurVerticalSize: number;
  46578. /**
  46579. * How big in texel of the blur texture is the horizontal blur.
  46580. */
  46581. blurHorizontalSize: number;
  46582. /**
  46583. * Alpha blending mode used to apply the blur. Default is combine.
  46584. */
  46585. alphaBlendingMode: number;
  46586. /**
  46587. * The camera attached to the layer.
  46588. */
  46589. camera: Nullable<Camera>;
  46590. /**
  46591. * Should we display highlight as a solid stroke?
  46592. */
  46593. isStroke?: boolean;
  46594. /**
  46595. * The rendering group to draw the layer in.
  46596. */
  46597. renderingGroupId: number;
  46598. }
  46599. /**
  46600. * The highlight layer Helps adding a glow effect around a mesh.
  46601. *
  46602. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46603. * glowy meshes to your scene.
  46604. *
  46605. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46606. */
  46607. export class HighlightLayer extends EffectLayer {
  46608. name: string;
  46609. /**
  46610. * Effect Name of the highlight layer.
  46611. */
  46612. static readonly EffectName: string;
  46613. /**
  46614. * The neutral color used during the preparation of the glow effect.
  46615. * This is black by default as the blend operation is a blend operation.
  46616. */
  46617. static NeutralColor: Color4;
  46618. /**
  46619. * Stencil value used for glowing meshes.
  46620. */
  46621. static GlowingMeshStencilReference: number;
  46622. /**
  46623. * Stencil value used for the other meshes in the scene.
  46624. */
  46625. static NormalMeshStencilReference: number;
  46626. /**
  46627. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46628. */
  46629. innerGlow: boolean;
  46630. /**
  46631. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46632. */
  46633. outerGlow: boolean;
  46634. /**
  46635. * Specifies the horizontal size of the blur.
  46636. */
  46637. /**
  46638. * Gets the horizontal size of the blur.
  46639. */
  46640. blurHorizontalSize: number;
  46641. /**
  46642. * Specifies the vertical size of the blur.
  46643. */
  46644. /**
  46645. * Gets the vertical size of the blur.
  46646. */
  46647. blurVerticalSize: number;
  46648. /**
  46649. * An event triggered when the highlight layer is being blurred.
  46650. */
  46651. onBeforeBlurObservable: Observable<HighlightLayer>;
  46652. /**
  46653. * An event triggered when the highlight layer has been blurred.
  46654. */
  46655. onAfterBlurObservable: Observable<HighlightLayer>;
  46656. private _instanceGlowingMeshStencilReference;
  46657. private _options;
  46658. private _downSamplePostprocess;
  46659. private _horizontalBlurPostprocess;
  46660. private _verticalBlurPostprocess;
  46661. private _blurTexture;
  46662. private _meshes;
  46663. private _excludedMeshes;
  46664. /**
  46665. * Instantiates a new highlight Layer and references it to the scene..
  46666. * @param name The name of the layer
  46667. * @param scene The scene to use the layer in
  46668. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46669. */
  46670. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46671. /**
  46672. * Get the effect name of the layer.
  46673. * @return The effect name
  46674. */
  46675. getEffectName(): string;
  46676. /**
  46677. * Create the merge effect. This is the shader use to blit the information back
  46678. * to the main canvas at the end of the scene rendering.
  46679. */
  46680. protected _createMergeEffect(): Effect;
  46681. /**
  46682. * Creates the render target textures and post processes used in the highlight layer.
  46683. */
  46684. protected _createTextureAndPostProcesses(): void;
  46685. /**
  46686. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46687. */
  46688. needStencil(): boolean;
  46689. /**
  46690. * Checks for the readiness of the element composing the layer.
  46691. * @param subMesh the mesh to check for
  46692. * @param useInstances specify wether or not to use instances to render the mesh
  46693. * @param emissiveTexture the associated emissive texture used to generate the glow
  46694. * @return true if ready otherwise, false
  46695. */
  46696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46697. /**
  46698. * Implementation specific of rendering the generating effect on the main canvas.
  46699. * @param effect The effect used to render through
  46700. */
  46701. protected _internalRender(effect: Effect): void;
  46702. /**
  46703. * Returns true if the layer contains information to display, otherwise false.
  46704. */
  46705. shouldRender(): boolean;
  46706. /**
  46707. * Returns true if the mesh should render, otherwise false.
  46708. * @param mesh The mesh to render
  46709. * @returns true if it should render otherwise false
  46710. */
  46711. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46712. /**
  46713. * Sets the required values for both the emissive texture and and the main color.
  46714. */
  46715. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46716. /**
  46717. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46718. * @param mesh The mesh to exclude from the highlight layer
  46719. */
  46720. addExcludedMesh(mesh: Mesh): void;
  46721. /**
  46722. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46723. * @param mesh The mesh to highlight
  46724. */
  46725. removeExcludedMesh(mesh: Mesh): void;
  46726. /**
  46727. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46728. * @param mesh mesh to test
  46729. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46730. */
  46731. hasMesh(mesh: AbstractMesh): boolean;
  46732. /**
  46733. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46734. * @param mesh The mesh to highlight
  46735. * @param color The color of the highlight
  46736. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46737. */
  46738. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46739. /**
  46740. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46741. * @param mesh The mesh to highlight
  46742. */
  46743. removeMesh(mesh: Mesh): void;
  46744. /**
  46745. * Force the stencil to the normal expected value for none glowing parts
  46746. */
  46747. private _defaultStencilReference;
  46748. /**
  46749. * Free any resources and references associated to a mesh.
  46750. * Internal use
  46751. * @param mesh The mesh to free.
  46752. * @hidden
  46753. */
  46754. _disposeMesh(mesh: Mesh): void;
  46755. /**
  46756. * Dispose the highlight layer and free resources.
  46757. */
  46758. dispose(): void;
  46759. /**
  46760. * Gets the class name of the effect layer
  46761. * @returns the string with the class name of the effect layer
  46762. */
  46763. getClassName(): string;
  46764. /**
  46765. * Serializes this Highlight layer
  46766. * @returns a serialized Highlight layer object
  46767. */
  46768. serialize(): any;
  46769. /**
  46770. * Creates a Highlight layer from parsed Highlight layer data
  46771. * @param parsedHightlightLayer defines the Highlight layer data
  46772. * @param scene defines the current scene
  46773. * @param rootUrl defines the root URL containing the Highlight layer information
  46774. * @returns a parsed Highlight layer
  46775. */
  46776. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46777. }
  46778. }
  46779. declare module "babylonjs/Layers/index" {
  46780. export * from "babylonjs/Layers/effectLayer";
  46781. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46782. export * from "babylonjs/Layers/glowLayer";
  46783. export * from "babylonjs/Layers/highlightLayer";
  46784. export * from "babylonjs/Layers/layer";
  46785. export * from "babylonjs/Layers/layerSceneComponent";
  46786. }
  46787. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46788. /** @hidden */
  46789. export var lensFlarePixelShader: {
  46790. name: string;
  46791. shader: string;
  46792. };
  46793. }
  46794. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46795. /** @hidden */
  46796. export var lensFlareVertexShader: {
  46797. name: string;
  46798. shader: string;
  46799. };
  46800. }
  46801. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46802. import { Scene } from "babylonjs/scene";
  46803. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46805. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46806. import "babylonjs/Shaders/lensFlare.fragment";
  46807. import "babylonjs/Shaders/lensFlare.vertex";
  46808. /**
  46809. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46810. * It is usually composed of several `lensFlare`.
  46811. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46812. */
  46813. export class LensFlareSystem {
  46814. /**
  46815. * Define the name of the lens flare system
  46816. */
  46817. name: string;
  46818. /**
  46819. * List of lens flares used in this system.
  46820. */
  46821. lensFlares: LensFlare[];
  46822. /**
  46823. * Define a limit from the border the lens flare can be visible.
  46824. */
  46825. borderLimit: number;
  46826. /**
  46827. * Define a viewport border we do not want to see the lens flare in.
  46828. */
  46829. viewportBorder: number;
  46830. /**
  46831. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46832. */
  46833. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46834. /**
  46835. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46836. */
  46837. layerMask: number;
  46838. /**
  46839. * Define the id of the lens flare system in the scene.
  46840. * (equal to name by default)
  46841. */
  46842. id: string;
  46843. private _scene;
  46844. private _emitter;
  46845. private _vertexBuffers;
  46846. private _indexBuffer;
  46847. private _effect;
  46848. private _positionX;
  46849. private _positionY;
  46850. private _isEnabled;
  46851. /** @hidden */
  46852. static _SceneComponentInitialization: (scene: Scene) => void;
  46853. /**
  46854. * Instantiates a lens flare system.
  46855. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46856. * It is usually composed of several `lensFlare`.
  46857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46858. * @param name Define the name of the lens flare system in the scene
  46859. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46860. * @param scene Define the scene the lens flare system belongs to
  46861. */
  46862. constructor(
  46863. /**
  46864. * Define the name of the lens flare system
  46865. */
  46866. name: string, emitter: any, scene: Scene);
  46867. /**
  46868. * Define if the lens flare system is enabled.
  46869. */
  46870. isEnabled: boolean;
  46871. /**
  46872. * Get the scene the effects belongs to.
  46873. * @returns the scene holding the lens flare system
  46874. */
  46875. getScene(): Scene;
  46876. /**
  46877. * Get the emitter of the lens flare system.
  46878. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46879. * @returns the emitter of the lens flare system
  46880. */
  46881. getEmitter(): any;
  46882. /**
  46883. * Set the emitter of the lens flare system.
  46884. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46885. * @param newEmitter Define the new emitter of the system
  46886. */
  46887. setEmitter(newEmitter: any): void;
  46888. /**
  46889. * Get the lens flare system emitter position.
  46890. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46891. * @returns the position
  46892. */
  46893. getEmitterPosition(): Vector3;
  46894. /**
  46895. * @hidden
  46896. */
  46897. computeEffectivePosition(globalViewport: Viewport): boolean;
  46898. /** @hidden */
  46899. _isVisible(): boolean;
  46900. /**
  46901. * @hidden
  46902. */
  46903. render(): boolean;
  46904. /**
  46905. * Dispose and release the lens flare with its associated resources.
  46906. */
  46907. dispose(): void;
  46908. /**
  46909. * Parse a lens flare system from a JSON repressentation
  46910. * @param parsedLensFlareSystem Define the JSON to parse
  46911. * @param scene Define the scene the parsed system should be instantiated in
  46912. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46913. * @returns the parsed system
  46914. */
  46915. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46916. /**
  46917. * Serialize the current Lens Flare System into a JSON representation.
  46918. * @returns the serialized JSON
  46919. */
  46920. serialize(): any;
  46921. }
  46922. }
  46923. declare module "babylonjs/LensFlares/lensFlare" {
  46924. import { Nullable } from "babylonjs/types";
  46925. import { Color3 } from "babylonjs/Maths/math";
  46926. import { Texture } from "babylonjs/Materials/Textures/texture";
  46927. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46928. /**
  46929. * This represents one of the lens effect in a `lensFlareSystem`.
  46930. * It controls one of the indiviual texture used in the effect.
  46931. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46932. */
  46933. export class LensFlare {
  46934. /**
  46935. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46936. */
  46937. size: number;
  46938. /**
  46939. * 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.
  46940. */
  46941. position: number;
  46942. /**
  46943. * Define the lens color.
  46944. */
  46945. color: Color3;
  46946. /**
  46947. * Define the lens texture.
  46948. */
  46949. texture: Nullable<Texture>;
  46950. /**
  46951. * Define the alpha mode to render this particular lens.
  46952. */
  46953. alphaMode: number;
  46954. private _system;
  46955. /**
  46956. * Creates a new Lens Flare.
  46957. * This represents one of the lens effect in a `lensFlareSystem`.
  46958. * It controls one of the indiviual texture used in the effect.
  46959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46960. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46961. * @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.
  46962. * @param color Define the lens color
  46963. * @param imgUrl Define the lens texture url
  46964. * @param system Define the `lensFlareSystem` this flare is part of
  46965. * @returns The newly created Lens Flare
  46966. */
  46967. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46968. /**
  46969. * Instantiates a new Lens Flare.
  46970. * This represents one of the lens effect in a `lensFlareSystem`.
  46971. * It controls one of the indiviual texture used in the effect.
  46972. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46973. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46974. * @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.
  46975. * @param color Define the lens color
  46976. * @param imgUrl Define the lens texture url
  46977. * @param system Define the `lensFlareSystem` this flare is part of
  46978. */
  46979. constructor(
  46980. /**
  46981. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46982. */
  46983. size: number,
  46984. /**
  46985. * 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.
  46986. */
  46987. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46988. /**
  46989. * Dispose and release the lens flare with its associated resources.
  46990. */
  46991. dispose(): void;
  46992. }
  46993. }
  46994. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46995. import { Nullable } from "babylonjs/types";
  46996. import { Scene } from "babylonjs/scene";
  46997. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46998. import { AbstractScene } from "babylonjs/abstractScene";
  46999. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47000. module "babylonjs/abstractScene" {
  47001. interface AbstractScene {
  47002. /**
  47003. * The list of lens flare system added to the scene
  47004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47005. */
  47006. lensFlareSystems: Array<LensFlareSystem>;
  47007. /**
  47008. * Removes the given lens flare system from this scene.
  47009. * @param toRemove The lens flare system to remove
  47010. * @returns The index of the removed lens flare system
  47011. */
  47012. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47013. /**
  47014. * Adds the given lens flare system to this scene
  47015. * @param newLensFlareSystem The lens flare system to add
  47016. */
  47017. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47018. /**
  47019. * Gets a lens flare system using its name
  47020. * @param name defines the name to look for
  47021. * @returns the lens flare system or null if not found
  47022. */
  47023. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47024. /**
  47025. * Gets a lens flare system using its id
  47026. * @param id defines the id to look for
  47027. * @returns the lens flare system or null if not found
  47028. */
  47029. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47030. }
  47031. }
  47032. /**
  47033. * Defines the lens flare scene component responsible to manage any lens flares
  47034. * in a given scene.
  47035. */
  47036. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47037. /**
  47038. * The component name helpfull to identify the component in the list of scene components.
  47039. */
  47040. readonly name: string;
  47041. /**
  47042. * The scene the component belongs to.
  47043. */
  47044. scene: Scene;
  47045. /**
  47046. * Creates a new instance of the component for the given scene
  47047. * @param scene Defines the scene to register the component in
  47048. */
  47049. constructor(scene: Scene);
  47050. /**
  47051. * Registers the component in a given scene
  47052. */
  47053. register(): void;
  47054. /**
  47055. * Rebuilds the elements related to this component in case of
  47056. * context lost for instance.
  47057. */
  47058. rebuild(): void;
  47059. /**
  47060. * Adds all the element from the container to the scene
  47061. * @param container the container holding the elements
  47062. */
  47063. addFromContainer(container: AbstractScene): void;
  47064. /**
  47065. * Removes all the elements in the container from the scene
  47066. * @param container contains the elements to remove
  47067. */
  47068. removeFromContainer(container: AbstractScene): void;
  47069. /**
  47070. * Serializes the component data to the specified json object
  47071. * @param serializationObject The object to serialize to
  47072. */
  47073. serialize(serializationObject: any): void;
  47074. /**
  47075. * Disposes the component and the associated ressources.
  47076. */
  47077. dispose(): void;
  47078. private _draw;
  47079. }
  47080. }
  47081. declare module "babylonjs/LensFlares/index" {
  47082. export * from "babylonjs/LensFlares/lensFlare";
  47083. export * from "babylonjs/LensFlares/lensFlareSystem";
  47084. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47085. }
  47086. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47087. import { Scene } from "babylonjs/scene";
  47088. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47089. import { AbstractScene } from "babylonjs/abstractScene";
  47090. /**
  47091. * Defines the shadow generator component responsible to manage any shadow generators
  47092. * in a given scene.
  47093. */
  47094. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47095. /**
  47096. * The component name helpfull to identify the component in the list of scene components.
  47097. */
  47098. readonly name: string;
  47099. /**
  47100. * The scene the component belongs to.
  47101. */
  47102. scene: Scene;
  47103. /**
  47104. * Creates a new instance of the component for the given scene
  47105. * @param scene Defines the scene to register the component in
  47106. */
  47107. constructor(scene: Scene);
  47108. /**
  47109. * Registers the component in a given scene
  47110. */
  47111. register(): void;
  47112. /**
  47113. * Rebuilds the elements related to this component in case of
  47114. * context lost for instance.
  47115. */
  47116. rebuild(): void;
  47117. /**
  47118. * Serializes the component data to the specified json object
  47119. * @param serializationObject The object to serialize to
  47120. */
  47121. serialize(serializationObject: any): void;
  47122. /**
  47123. * Adds all the element from the container to the scene
  47124. * @param container the container holding the elements
  47125. */
  47126. addFromContainer(container: AbstractScene): void;
  47127. /**
  47128. * Removes all the elements in the container from the scene
  47129. * @param container contains the elements to remove
  47130. */
  47131. removeFromContainer(container: AbstractScene): void;
  47132. /**
  47133. * Rebuilds the elements related to this component in case of
  47134. * context lost for instance.
  47135. */
  47136. dispose(): void;
  47137. private _gatherRenderTargets;
  47138. }
  47139. }
  47140. declare module "babylonjs/Lights/Shadows/index" {
  47141. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47142. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47143. }
  47144. declare module "babylonjs/Lights/directionalLight" {
  47145. import { Camera } from "babylonjs/Cameras/camera";
  47146. import { Scene } from "babylonjs/scene";
  47147. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47149. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47150. import { Effect } from "babylonjs/Materials/effect";
  47151. /**
  47152. * A directional light is defined by a direction (what a surprise!).
  47153. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47154. * 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.
  47155. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47156. */
  47157. export class DirectionalLight extends ShadowLight {
  47158. private _shadowFrustumSize;
  47159. /**
  47160. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47161. */
  47162. /**
  47163. * Specifies a fix frustum size for the shadow generation.
  47164. */
  47165. shadowFrustumSize: number;
  47166. private _shadowOrthoScale;
  47167. /**
  47168. * Gets the shadow projection scale against the optimal computed one.
  47169. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47170. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47171. */
  47172. /**
  47173. * Sets the shadow projection scale against the optimal computed one.
  47174. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47175. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47176. */
  47177. shadowOrthoScale: number;
  47178. /**
  47179. * Automatically compute the projection matrix to best fit (including all the casters)
  47180. * on each frame.
  47181. */
  47182. autoUpdateExtends: boolean;
  47183. private _orthoLeft;
  47184. private _orthoRight;
  47185. private _orthoTop;
  47186. private _orthoBottom;
  47187. /**
  47188. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47189. * The directional light is emitted from everywhere in the given direction.
  47190. * It can cast shadows.
  47191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47192. * @param name The friendly name of the light
  47193. * @param direction The direction of the light
  47194. * @param scene The scene the light belongs to
  47195. */
  47196. constructor(name: string, direction: Vector3, scene: Scene);
  47197. /**
  47198. * Returns the string "DirectionalLight".
  47199. * @return The class name
  47200. */
  47201. getClassName(): string;
  47202. /**
  47203. * Returns the integer 1.
  47204. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47205. */
  47206. getTypeID(): number;
  47207. /**
  47208. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47209. * Returns the DirectionalLight Shadow projection matrix.
  47210. */
  47211. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47212. /**
  47213. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47214. * Returns the DirectionalLight Shadow projection matrix.
  47215. */
  47216. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47217. /**
  47218. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47219. * Returns the DirectionalLight Shadow projection matrix.
  47220. */
  47221. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47222. protected _buildUniformLayout(): void;
  47223. /**
  47224. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47225. * @param effect The effect to update
  47226. * @param lightIndex The index of the light in the effect to update
  47227. * @returns The directional light
  47228. */
  47229. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47230. /**
  47231. * Gets the minZ used for shadow according to both the scene and the light.
  47232. *
  47233. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47234. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47235. * @param activeCamera The camera we are returning the min for
  47236. * @returns the depth min z
  47237. */
  47238. getDepthMinZ(activeCamera: Camera): number;
  47239. /**
  47240. * Gets the maxZ used for shadow according to both the scene and the light.
  47241. *
  47242. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47243. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47244. * @param activeCamera The camera we are returning the max for
  47245. * @returns the depth max z
  47246. */
  47247. getDepthMaxZ(activeCamera: Camera): number;
  47248. /**
  47249. * Prepares the list of defines specific to the light type.
  47250. * @param defines the list of defines
  47251. * @param lightIndex defines the index of the light for the effect
  47252. */
  47253. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47254. }
  47255. }
  47256. declare module "babylonjs/Lights/pointLight" {
  47257. import { Scene } from "babylonjs/scene";
  47258. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47260. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47261. import { Effect } from "babylonjs/Materials/effect";
  47262. /**
  47263. * A point light is a light defined by an unique point in world space.
  47264. * The light is emitted in every direction from this point.
  47265. * A good example of a point light is a standard light bulb.
  47266. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47267. */
  47268. export class PointLight extends ShadowLight {
  47269. private _shadowAngle;
  47270. /**
  47271. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47272. * This specifies what angle the shadow will use to be created.
  47273. *
  47274. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47275. */
  47276. /**
  47277. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47278. * This specifies what angle the shadow will use to be created.
  47279. *
  47280. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47281. */
  47282. shadowAngle: number;
  47283. /**
  47284. * Gets the direction if it has been set.
  47285. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47286. */
  47287. /**
  47288. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47289. */
  47290. direction: Vector3;
  47291. /**
  47292. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47293. * A PointLight emits the light in every direction.
  47294. * It can cast shadows.
  47295. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47296. * ```javascript
  47297. * var pointLight = new PointLight("pl", camera.position, scene);
  47298. * ```
  47299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47300. * @param name The light friendly name
  47301. * @param position The position of the point light in the scene
  47302. * @param scene The scene the lights belongs to
  47303. */
  47304. constructor(name: string, position: Vector3, scene: Scene);
  47305. /**
  47306. * Returns the string "PointLight"
  47307. * @returns the class name
  47308. */
  47309. getClassName(): string;
  47310. /**
  47311. * Returns the integer 0.
  47312. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47313. */
  47314. getTypeID(): number;
  47315. /**
  47316. * Specifies wether or not the shadowmap should be a cube texture.
  47317. * @returns true if the shadowmap needs to be a cube texture.
  47318. */
  47319. needCube(): boolean;
  47320. /**
  47321. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47322. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47323. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47324. */
  47325. getShadowDirection(faceIndex?: number): Vector3;
  47326. /**
  47327. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47328. * - fov = PI / 2
  47329. * - aspect ratio : 1.0
  47330. * - z-near and far equal to the active camera minZ and maxZ.
  47331. * Returns the PointLight.
  47332. */
  47333. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47334. protected _buildUniformLayout(): void;
  47335. /**
  47336. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47337. * @param effect The effect to update
  47338. * @param lightIndex The index of the light in the effect to update
  47339. * @returns The point light
  47340. */
  47341. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47342. /**
  47343. * Prepares the list of defines specific to the light type.
  47344. * @param defines the list of defines
  47345. * @param lightIndex defines the index of the light for the effect
  47346. */
  47347. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47348. }
  47349. }
  47350. declare module "babylonjs/Lights/spotLight" {
  47351. import { Nullable } from "babylonjs/types";
  47352. import { Scene } from "babylonjs/scene";
  47353. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47355. import { Effect } from "babylonjs/Materials/effect";
  47356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47357. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47358. /**
  47359. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47360. * These values define a cone of light starting from the position, emitting toward the direction.
  47361. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47362. * and the exponent defines the speed of the decay of the light with distance (reach).
  47363. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47364. */
  47365. export class SpotLight extends ShadowLight {
  47366. private _angle;
  47367. private _innerAngle;
  47368. private _cosHalfAngle;
  47369. private _lightAngleScale;
  47370. private _lightAngleOffset;
  47371. /**
  47372. * Gets the cone angle of the spot light in Radians.
  47373. */
  47374. /**
  47375. * Sets the cone angle of the spot light in Radians.
  47376. */
  47377. angle: number;
  47378. /**
  47379. * Only used in gltf falloff mode, this defines the angle where
  47380. * the directional falloff will start before cutting at angle which could be seen
  47381. * as outer angle.
  47382. */
  47383. /**
  47384. * Only used in gltf falloff mode, this defines the angle where
  47385. * the directional falloff will start before cutting at angle which could be seen
  47386. * as outer angle.
  47387. */
  47388. innerAngle: number;
  47389. private _shadowAngleScale;
  47390. /**
  47391. * Allows scaling the angle of the light for shadow generation only.
  47392. */
  47393. /**
  47394. * Allows scaling the angle of the light for shadow generation only.
  47395. */
  47396. shadowAngleScale: number;
  47397. /**
  47398. * The light decay speed with the distance from the emission spot.
  47399. */
  47400. exponent: number;
  47401. private _projectionTextureMatrix;
  47402. /**
  47403. * Allows reading the projecton texture
  47404. */
  47405. readonly projectionTextureMatrix: Matrix;
  47406. protected _projectionTextureLightNear: number;
  47407. /**
  47408. * Gets the near clip of the Spotlight for texture projection.
  47409. */
  47410. /**
  47411. * Sets the near clip of the Spotlight for texture projection.
  47412. */
  47413. projectionTextureLightNear: number;
  47414. protected _projectionTextureLightFar: number;
  47415. /**
  47416. * Gets the far clip of the Spotlight for texture projection.
  47417. */
  47418. /**
  47419. * Sets the far clip of the Spotlight for texture projection.
  47420. */
  47421. projectionTextureLightFar: number;
  47422. protected _projectionTextureUpDirection: Vector3;
  47423. /**
  47424. * Gets the Up vector of the Spotlight for texture projection.
  47425. */
  47426. /**
  47427. * Sets the Up vector of the Spotlight for texture projection.
  47428. */
  47429. projectionTextureUpDirection: Vector3;
  47430. private _projectionTexture;
  47431. /**
  47432. * Gets the projection texture of the light.
  47433. */
  47434. /**
  47435. * Sets the projection texture of the light.
  47436. */
  47437. projectionTexture: Nullable<BaseTexture>;
  47438. private _projectionTextureViewLightDirty;
  47439. private _projectionTextureProjectionLightDirty;
  47440. private _projectionTextureDirty;
  47441. private _projectionTextureViewTargetVector;
  47442. private _projectionTextureViewLightMatrix;
  47443. private _projectionTextureProjectionLightMatrix;
  47444. private _projectionTextureScalingMatrix;
  47445. /**
  47446. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47447. * It can cast shadows.
  47448. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47449. * @param name The light friendly name
  47450. * @param position The position of the spot light in the scene
  47451. * @param direction The direction of the light in the scene
  47452. * @param angle The cone angle of the light in Radians
  47453. * @param exponent The light decay speed with the distance from the emission spot
  47454. * @param scene The scene the lights belongs to
  47455. */
  47456. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47457. /**
  47458. * Returns the string "SpotLight".
  47459. * @returns the class name
  47460. */
  47461. getClassName(): string;
  47462. /**
  47463. * Returns the integer 2.
  47464. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47465. */
  47466. getTypeID(): number;
  47467. /**
  47468. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47469. */
  47470. protected _setDirection(value: Vector3): void;
  47471. /**
  47472. * Overrides the position setter to recompute the projection texture view light Matrix.
  47473. */
  47474. protected _setPosition(value: Vector3): void;
  47475. /**
  47476. * 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.
  47477. * Returns the SpotLight.
  47478. */
  47479. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47480. protected _computeProjectionTextureViewLightMatrix(): void;
  47481. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47482. /**
  47483. * Main function for light texture projection matrix computing.
  47484. */
  47485. protected _computeProjectionTextureMatrix(): void;
  47486. protected _buildUniformLayout(): void;
  47487. private _computeAngleValues;
  47488. /**
  47489. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47490. * @param effect The effect to update
  47491. * @param lightIndex The index of the light in the effect to update
  47492. * @returns The spot light
  47493. */
  47494. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47495. /**
  47496. * Disposes the light and the associated resources.
  47497. */
  47498. dispose(): void;
  47499. /**
  47500. * Prepares the list of defines specific to the light type.
  47501. * @param defines the list of defines
  47502. * @param lightIndex defines the index of the light for the effect
  47503. */
  47504. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47505. }
  47506. }
  47507. declare module "babylonjs/Lights/index" {
  47508. export * from "babylonjs/Lights/light";
  47509. export * from "babylonjs/Lights/shadowLight";
  47510. export * from "babylonjs/Lights/Shadows/index";
  47511. export * from "babylonjs/Lights/directionalLight";
  47512. export * from "babylonjs/Lights/hemisphericLight";
  47513. export * from "babylonjs/Lights/pointLight";
  47514. export * from "babylonjs/Lights/spotLight";
  47515. }
  47516. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47517. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47518. /**
  47519. * Header information of HDR texture files.
  47520. */
  47521. export interface HDRInfo {
  47522. /**
  47523. * The height of the texture in pixels.
  47524. */
  47525. height: number;
  47526. /**
  47527. * The width of the texture in pixels.
  47528. */
  47529. width: number;
  47530. /**
  47531. * The index of the beginning of the data in the binary file.
  47532. */
  47533. dataPosition: number;
  47534. }
  47535. /**
  47536. * This groups tools to convert HDR texture to native colors array.
  47537. */
  47538. export class HDRTools {
  47539. private static Ldexp;
  47540. private static Rgbe2float;
  47541. private static readStringLine;
  47542. /**
  47543. * Reads header information from an RGBE texture stored in a native array.
  47544. * More information on this format are available here:
  47545. * https://en.wikipedia.org/wiki/RGBE_image_format
  47546. *
  47547. * @param uint8array The binary file stored in native array.
  47548. * @return The header information.
  47549. */
  47550. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47551. /**
  47552. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47553. * This RGBE texture needs to store the information as a panorama.
  47554. *
  47555. * More information on this format are available here:
  47556. * https://en.wikipedia.org/wiki/RGBE_image_format
  47557. *
  47558. * @param buffer The binary file stored in an array buffer.
  47559. * @param size The expected size of the extracted cubemap.
  47560. * @return The Cube Map information.
  47561. */
  47562. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47563. /**
  47564. * Returns the pixels data extracted from an RGBE texture.
  47565. * This pixels will be stored left to right up to down in the R G B order in one array.
  47566. *
  47567. * More information on this format are available here:
  47568. * https://en.wikipedia.org/wiki/RGBE_image_format
  47569. *
  47570. * @param uint8array The binary file stored in an array buffer.
  47571. * @param hdrInfo The header information of the file.
  47572. * @return The pixels data in RGB right to left up to down order.
  47573. */
  47574. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47575. private static RGBE_ReadPixels_RLE;
  47576. }
  47577. }
  47578. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47579. import { Nullable } from "babylonjs/types";
  47580. import { Scene } from "babylonjs/scene";
  47581. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47583. /**
  47584. * This represents a texture coming from an HDR input.
  47585. *
  47586. * The only supported format is currently panorama picture stored in RGBE format.
  47587. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47588. */
  47589. export class HDRCubeTexture extends BaseTexture {
  47590. private static _facesMapping;
  47591. private _generateHarmonics;
  47592. private _noMipmap;
  47593. private _textureMatrix;
  47594. private _size;
  47595. private _onLoad;
  47596. private _onError;
  47597. /**
  47598. * The texture URL.
  47599. */
  47600. url: string;
  47601. /**
  47602. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47603. */
  47604. coordinatesMode: number;
  47605. protected _isBlocking: boolean;
  47606. /**
  47607. * Sets wether or not the texture is blocking during loading.
  47608. */
  47609. /**
  47610. * Gets wether or not the texture is blocking during loading.
  47611. */
  47612. isBlocking: boolean;
  47613. protected _rotationY: number;
  47614. /**
  47615. * Sets texture matrix rotation angle around Y axis in radians.
  47616. */
  47617. /**
  47618. * Gets texture matrix rotation angle around Y axis radians.
  47619. */
  47620. rotationY: number;
  47621. /**
  47622. * Gets or sets the center of the bounding box associated with the cube texture
  47623. * It must define where the camera used to render the texture was set
  47624. */
  47625. boundingBoxPosition: Vector3;
  47626. private _boundingBoxSize;
  47627. /**
  47628. * Gets or sets the size of the bounding box associated with the cube texture
  47629. * When defined, the cubemap will switch to local mode
  47630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47631. * @example https://www.babylonjs-playground.com/#RNASML
  47632. */
  47633. boundingBoxSize: Vector3;
  47634. /**
  47635. * Instantiates an HDRTexture from the following parameters.
  47636. *
  47637. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47638. * @param scene The scene the texture will be used in
  47639. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47640. * @param noMipmap Forces to not generate the mipmap if true
  47641. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47642. * @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)
  47643. * @param reserved Reserved flag for internal use.
  47644. */
  47645. 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>);
  47646. /**
  47647. * Get the current class name of the texture useful for serialization or dynamic coding.
  47648. * @returns "HDRCubeTexture"
  47649. */
  47650. getClassName(): string;
  47651. /**
  47652. * Occurs when the file is raw .hdr file.
  47653. */
  47654. private loadTexture;
  47655. clone(): HDRCubeTexture;
  47656. delayLoad(): void;
  47657. /**
  47658. * Get the texture reflection matrix used to rotate/transform the reflection.
  47659. * @returns the reflection matrix
  47660. */
  47661. getReflectionTextureMatrix(): Matrix;
  47662. /**
  47663. * Set the texture reflection matrix used to rotate/transform the reflection.
  47664. * @param value Define the reflection matrix to set
  47665. */
  47666. setReflectionTextureMatrix(value: Matrix): void;
  47667. /**
  47668. * Parses a JSON representation of an HDR Texture in order to create the texture
  47669. * @param parsedTexture Define the JSON representation
  47670. * @param scene Define the scene the texture should be created in
  47671. * @param rootUrl Define the root url in case we need to load relative dependencies
  47672. * @returns the newly created texture after parsing
  47673. */
  47674. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47675. serialize(): any;
  47676. }
  47677. }
  47678. declare module "babylonjs/Physics/physicsEngine" {
  47679. import { Nullable } from "babylonjs/types";
  47680. import { Vector3 } from "babylonjs/Maths/math";
  47681. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47682. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47683. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47684. /**
  47685. * Class used to control physics engine
  47686. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47687. */
  47688. export class PhysicsEngine implements IPhysicsEngine {
  47689. private _physicsPlugin;
  47690. /**
  47691. * Global value used to control the smallest number supported by the simulation
  47692. */
  47693. static Epsilon: number;
  47694. private _impostors;
  47695. private _joints;
  47696. /**
  47697. * Gets the gravity vector used by the simulation
  47698. */
  47699. gravity: Vector3;
  47700. /**
  47701. * Factory used to create the default physics plugin.
  47702. * @returns The default physics plugin
  47703. */
  47704. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47705. /**
  47706. * Creates a new Physics Engine
  47707. * @param gravity defines the gravity vector used by the simulation
  47708. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47709. */
  47710. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47711. /**
  47712. * Sets the gravity vector used by the simulation
  47713. * @param gravity defines the gravity vector to use
  47714. */
  47715. setGravity(gravity: Vector3): void;
  47716. /**
  47717. * Set the time step of the physics engine.
  47718. * Default is 1/60.
  47719. * To slow it down, enter 1/600 for example.
  47720. * To speed it up, 1/30
  47721. * @param newTimeStep defines the new timestep to apply to this world.
  47722. */
  47723. setTimeStep(newTimeStep?: number): void;
  47724. /**
  47725. * Get the time step of the physics engine.
  47726. * @returns the current time step
  47727. */
  47728. getTimeStep(): number;
  47729. /**
  47730. * Release all resources
  47731. */
  47732. dispose(): void;
  47733. /**
  47734. * Gets the name of the current physics plugin
  47735. * @returns the name of the plugin
  47736. */
  47737. getPhysicsPluginName(): string;
  47738. /**
  47739. * Adding a new impostor for the impostor tracking.
  47740. * This will be done by the impostor itself.
  47741. * @param impostor the impostor to add
  47742. */
  47743. addImpostor(impostor: PhysicsImpostor): void;
  47744. /**
  47745. * Remove an impostor from the engine.
  47746. * This impostor and its mesh will not longer be updated by the physics engine.
  47747. * @param impostor the impostor to remove
  47748. */
  47749. removeImpostor(impostor: PhysicsImpostor): void;
  47750. /**
  47751. * Add a joint to the physics engine
  47752. * @param mainImpostor defines the main impostor to which the joint is added.
  47753. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47754. * @param joint defines the joint that will connect both impostors.
  47755. */
  47756. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47757. /**
  47758. * Removes a joint from the simulation
  47759. * @param mainImpostor defines the impostor used with the joint
  47760. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47761. * @param joint defines the joint to remove
  47762. */
  47763. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47764. /**
  47765. * Called by the scene. No need to call it.
  47766. * @param delta defines the timespam between frames
  47767. */
  47768. _step(delta: number): void;
  47769. /**
  47770. * Gets the current plugin used to run the simulation
  47771. * @returns current plugin
  47772. */
  47773. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47774. /**
  47775. * Gets the list of physic impostors
  47776. * @returns an array of PhysicsImpostor
  47777. */
  47778. getImpostors(): Array<PhysicsImpostor>;
  47779. /**
  47780. * Gets the impostor for a physics enabled object
  47781. * @param object defines the object impersonated by the impostor
  47782. * @returns the PhysicsImpostor or null if not found
  47783. */
  47784. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47785. /**
  47786. * Gets the impostor for a physics body object
  47787. * @param body defines physics body used by the impostor
  47788. * @returns the PhysicsImpostor or null if not found
  47789. */
  47790. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47791. }
  47792. }
  47793. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47794. import { Nullable } from "babylonjs/types";
  47795. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47797. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47798. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47799. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47800. /** @hidden */
  47801. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47802. private _useDeltaForWorldStep;
  47803. world: any;
  47804. name: string;
  47805. private _physicsMaterials;
  47806. private _fixedTimeStep;
  47807. BJSCANNON: any;
  47808. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47809. setGravity(gravity: Vector3): void;
  47810. setTimeStep(timeStep: number): void;
  47811. getTimeStep(): number;
  47812. executeStep(delta: number): void;
  47813. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47814. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47815. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47816. private _processChildMeshes;
  47817. removePhysicsBody(impostor: PhysicsImpostor): void;
  47818. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47819. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47820. private _addMaterial;
  47821. private _checkWithEpsilon;
  47822. private _createShape;
  47823. private _createHeightmap;
  47824. private _minus90X;
  47825. private _plus90X;
  47826. private _tmpPosition;
  47827. private _tmpDeltaPosition;
  47828. private _tmpUnityRotation;
  47829. private _updatePhysicsBodyTransformation;
  47830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47831. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47832. isSupported(): boolean;
  47833. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47834. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47836. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47838. getBodyMass(impostor: PhysicsImpostor): number;
  47839. getBodyFriction(impostor: PhysicsImpostor): number;
  47840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47841. getBodyRestitution(impostor: PhysicsImpostor): number;
  47842. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47843. sleepBody(impostor: PhysicsImpostor): void;
  47844. wakeUpBody(impostor: PhysicsImpostor): void;
  47845. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47846. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47848. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47849. getRadius(impostor: PhysicsImpostor): number;
  47850. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47851. dispose(): void;
  47852. private _extendNamespace;
  47853. }
  47854. }
  47855. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47856. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47857. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47858. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47860. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47861. import { Nullable } from "babylonjs/types";
  47862. /** @hidden */
  47863. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47864. world: any;
  47865. name: string;
  47866. BJSOIMO: any;
  47867. constructor(iterations?: number, oimoInjection?: any);
  47868. setGravity(gravity: Vector3): void;
  47869. setTimeStep(timeStep: number): void;
  47870. getTimeStep(): number;
  47871. private _tmpImpostorsArray;
  47872. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47873. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47874. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47875. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47876. private _tmpPositionVector;
  47877. removePhysicsBody(impostor: PhysicsImpostor): void;
  47878. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47879. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47880. isSupported(): boolean;
  47881. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47882. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47883. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47884. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47885. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47886. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47887. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47888. getBodyMass(impostor: PhysicsImpostor): number;
  47889. getBodyFriction(impostor: PhysicsImpostor): number;
  47890. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47891. getBodyRestitution(impostor: PhysicsImpostor): number;
  47892. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47893. sleepBody(impostor: PhysicsImpostor): void;
  47894. wakeUpBody(impostor: PhysicsImpostor): void;
  47895. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47896. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47897. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47898. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47899. getRadius(impostor: PhysicsImpostor): number;
  47900. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47901. dispose(): void;
  47902. }
  47903. }
  47904. declare module "babylonjs/Probes/reflectionProbe" {
  47905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47906. import { Vector3 } from "babylonjs/Maths/math";
  47907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47908. import { Nullable } from "babylonjs/types";
  47909. import { Scene } from "babylonjs/scene";
  47910. module "babylonjs/abstractScene" {
  47911. interface AbstractScene {
  47912. /**
  47913. * The list of reflection probes added to the scene
  47914. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47915. */
  47916. reflectionProbes: Array<ReflectionProbe>;
  47917. /**
  47918. * Removes the given reflection probe from this scene.
  47919. * @param toRemove The reflection probe to remove
  47920. * @returns The index of the removed reflection probe
  47921. */
  47922. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47923. /**
  47924. * Adds the given reflection probe to this scene.
  47925. * @param newReflectionProbe The reflection probe to add
  47926. */
  47927. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47928. }
  47929. }
  47930. /**
  47931. * Class used to generate realtime reflection / refraction cube textures
  47932. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47933. */
  47934. export class ReflectionProbe {
  47935. /** defines the name of the probe */
  47936. name: string;
  47937. private _scene;
  47938. private _renderTargetTexture;
  47939. private _projectionMatrix;
  47940. private _viewMatrix;
  47941. private _target;
  47942. private _add;
  47943. private _attachedMesh;
  47944. private _invertYAxis;
  47945. /** Gets or sets probe position (center of the cube map) */
  47946. position: Vector3;
  47947. /**
  47948. * Creates a new reflection probe
  47949. * @param name defines the name of the probe
  47950. * @param size defines the texture resolution (for each face)
  47951. * @param scene defines the hosting scene
  47952. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47953. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47954. */
  47955. constructor(
  47956. /** defines the name of the probe */
  47957. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47958. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47959. samples: number;
  47960. /** Gets or sets the refresh rate to use (on every frame by default) */
  47961. refreshRate: number;
  47962. /**
  47963. * Gets the hosting scene
  47964. * @returns a Scene
  47965. */
  47966. getScene(): Scene;
  47967. /** Gets the internal CubeTexture used to render to */
  47968. readonly cubeTexture: RenderTargetTexture;
  47969. /** Gets the list of meshes to render */
  47970. readonly renderList: Nullable<AbstractMesh[]>;
  47971. /**
  47972. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47973. * @param mesh defines the mesh to attach to
  47974. */
  47975. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47976. /**
  47977. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47978. * @param renderingGroupId The rendering group id corresponding to its index
  47979. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47980. */
  47981. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47982. /**
  47983. * Clean all associated resources
  47984. */
  47985. dispose(): void;
  47986. /**
  47987. * Converts the reflection probe information to a readable string for debug purpose.
  47988. * @param fullDetails Supports for multiple levels of logging within scene loading
  47989. * @returns the human readable reflection probe info
  47990. */
  47991. toString(fullDetails?: boolean): string;
  47992. /**
  47993. * Get the class name of the relfection probe.
  47994. * @returns "ReflectionProbe"
  47995. */
  47996. getClassName(): string;
  47997. /**
  47998. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47999. * @returns The JSON representation of the texture
  48000. */
  48001. serialize(): any;
  48002. /**
  48003. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48004. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48005. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48006. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48007. * @returns The parsed reflection probe if successful
  48008. */
  48009. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48010. }
  48011. }
  48012. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48013. /** @hidden */
  48014. export var _BabylonLoaderRegistered: boolean;
  48015. }
  48016. declare module "babylonjs/Loading/Plugins/index" {
  48017. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48018. }
  48019. declare module "babylonjs/Loading/index" {
  48020. export * from "babylonjs/Loading/loadingScreen";
  48021. export * from "babylonjs/Loading/Plugins/index";
  48022. export * from "babylonjs/Loading/sceneLoader";
  48023. export * from "babylonjs/Loading/sceneLoaderFlags";
  48024. }
  48025. declare module "babylonjs/Materials/Background/index" {
  48026. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48027. }
  48028. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48029. import { Scene } from "babylonjs/scene";
  48030. import { Color3 } from "babylonjs/Maths/math";
  48031. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48033. /**
  48034. * The Physically based simple base material of BJS.
  48035. *
  48036. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48037. * It is used as the base class for both the specGloss and metalRough conventions.
  48038. */
  48039. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48040. /**
  48041. * Number of Simultaneous lights allowed on the material.
  48042. */
  48043. maxSimultaneousLights: number;
  48044. /**
  48045. * If sets to true, disables all the lights affecting the material.
  48046. */
  48047. disableLighting: boolean;
  48048. /**
  48049. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48050. */
  48051. environmentTexture: BaseTexture;
  48052. /**
  48053. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48054. */
  48055. invertNormalMapX: boolean;
  48056. /**
  48057. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48058. */
  48059. invertNormalMapY: boolean;
  48060. /**
  48061. * Normal map used in the model.
  48062. */
  48063. normalTexture: BaseTexture;
  48064. /**
  48065. * Emissivie color used to self-illuminate the model.
  48066. */
  48067. emissiveColor: Color3;
  48068. /**
  48069. * Emissivie texture used to self-illuminate the model.
  48070. */
  48071. emissiveTexture: BaseTexture;
  48072. /**
  48073. * Occlusion Channel Strenght.
  48074. */
  48075. occlusionStrength: number;
  48076. /**
  48077. * Occlusion Texture of the material (adding extra occlusion effects).
  48078. */
  48079. occlusionTexture: BaseTexture;
  48080. /**
  48081. * Defines the alpha limits in alpha test mode.
  48082. */
  48083. alphaCutOff: number;
  48084. /**
  48085. * Gets the current double sided mode.
  48086. */
  48087. /**
  48088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48089. */
  48090. doubleSided: boolean;
  48091. /**
  48092. * Stores the pre-calculated light information of a mesh in a texture.
  48093. */
  48094. lightmapTexture: BaseTexture;
  48095. /**
  48096. * If true, the light map contains occlusion information instead of lighting info.
  48097. */
  48098. useLightmapAsShadowmap: boolean;
  48099. /**
  48100. * Return the active textures of the material.
  48101. */
  48102. getActiveTextures(): BaseTexture[];
  48103. hasTexture(texture: BaseTexture): boolean;
  48104. /**
  48105. * Instantiates a new PBRMaterial instance.
  48106. *
  48107. * @param name The material name
  48108. * @param scene The scene the material will be use in.
  48109. */
  48110. constructor(name: string, scene: Scene);
  48111. getClassName(): string;
  48112. }
  48113. }
  48114. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48115. import { Scene } from "babylonjs/scene";
  48116. import { Color3 } from "babylonjs/Maths/math";
  48117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48118. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48119. /**
  48120. * The PBR material of BJS following the metal roughness convention.
  48121. *
  48122. * This fits to the PBR convention in the GLTF definition:
  48123. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48124. */
  48125. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48126. /**
  48127. * The base color has two different interpretations depending on the value of metalness.
  48128. * When the material is a metal, the base color is the specific measured reflectance value
  48129. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48130. * of the material.
  48131. */
  48132. baseColor: Color3;
  48133. /**
  48134. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48135. * well as opacity information in the alpha channel.
  48136. */
  48137. baseTexture: BaseTexture;
  48138. /**
  48139. * Specifies the metallic scalar value of the material.
  48140. * Can also be used to scale the metalness values of the metallic texture.
  48141. */
  48142. metallic: number;
  48143. /**
  48144. * Specifies the roughness scalar value of the material.
  48145. * Can also be used to scale the roughness values of the metallic texture.
  48146. */
  48147. roughness: number;
  48148. /**
  48149. * Texture containing both the metallic value in the B channel and the
  48150. * roughness value in the G channel to keep better precision.
  48151. */
  48152. metallicRoughnessTexture: BaseTexture;
  48153. /**
  48154. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48155. *
  48156. * @param name The material name
  48157. * @param scene The scene the material will be use in.
  48158. */
  48159. constructor(name: string, scene: Scene);
  48160. /**
  48161. * Return the currrent class name of the material.
  48162. */
  48163. getClassName(): string;
  48164. /**
  48165. * Return the active textures of the material.
  48166. */
  48167. getActiveTextures(): BaseTexture[];
  48168. /**
  48169. * Checks to see if a texture is used in the material.
  48170. * @param texture - Base texture to use.
  48171. * @returns - Boolean specifying if a texture is used in the material.
  48172. */
  48173. hasTexture(texture: BaseTexture): boolean;
  48174. /**
  48175. * Makes a duplicate of the current material.
  48176. * @param name - name to use for the new material.
  48177. */
  48178. clone(name: string): PBRMetallicRoughnessMaterial;
  48179. /**
  48180. * Serialize the material to a parsable JSON object.
  48181. */
  48182. serialize(): any;
  48183. /**
  48184. * Parses a JSON object correponding to the serialize function.
  48185. */
  48186. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48187. }
  48188. }
  48189. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48190. import { Scene } from "babylonjs/scene";
  48191. import { Color3 } from "babylonjs/Maths/math";
  48192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48193. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48194. /**
  48195. * The PBR material of BJS following the specular glossiness convention.
  48196. *
  48197. * This fits to the PBR convention in the GLTF definition:
  48198. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48199. */
  48200. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48201. /**
  48202. * Specifies the diffuse color of the material.
  48203. */
  48204. diffuseColor: Color3;
  48205. /**
  48206. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48207. * channel.
  48208. */
  48209. diffuseTexture: BaseTexture;
  48210. /**
  48211. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48212. */
  48213. specularColor: Color3;
  48214. /**
  48215. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48216. */
  48217. glossiness: number;
  48218. /**
  48219. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48220. */
  48221. specularGlossinessTexture: BaseTexture;
  48222. /**
  48223. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48224. *
  48225. * @param name The material name
  48226. * @param scene The scene the material will be use in.
  48227. */
  48228. constructor(name: string, scene: Scene);
  48229. /**
  48230. * Return the currrent class name of the material.
  48231. */
  48232. getClassName(): string;
  48233. /**
  48234. * Return the active textures of the material.
  48235. */
  48236. getActiveTextures(): BaseTexture[];
  48237. /**
  48238. * Checks to see if a texture is used in the material.
  48239. * @param texture - Base texture to use.
  48240. * @returns - Boolean specifying if a texture is used in the material.
  48241. */
  48242. hasTexture(texture: BaseTexture): boolean;
  48243. /**
  48244. * Makes a duplicate of the current material.
  48245. * @param name - name to use for the new material.
  48246. */
  48247. clone(name: string): PBRSpecularGlossinessMaterial;
  48248. /**
  48249. * Serialize the material to a parsable JSON object.
  48250. */
  48251. serialize(): any;
  48252. /**
  48253. * Parses a JSON object correponding to the serialize function.
  48254. */
  48255. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48256. }
  48257. }
  48258. declare module "babylonjs/Materials/PBR/index" {
  48259. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48260. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48261. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48262. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48263. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48264. }
  48265. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48266. import { Nullable } from "babylonjs/types";
  48267. import { Scene } from "babylonjs/scene";
  48268. import { Matrix } from "babylonjs/Maths/math";
  48269. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48270. /**
  48271. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48272. * It can help converting any input color in a desired output one. This can then be used to create effects
  48273. * from sepia, black and white to sixties or futuristic rendering...
  48274. *
  48275. * The only supported format is currently 3dl.
  48276. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48277. */
  48278. export class ColorGradingTexture extends BaseTexture {
  48279. /**
  48280. * The current texture matrix. (will always be identity in color grading texture)
  48281. */
  48282. private _textureMatrix;
  48283. /**
  48284. * The texture URL.
  48285. */
  48286. url: string;
  48287. /**
  48288. * Empty line regex stored for GC.
  48289. */
  48290. private static _noneEmptyLineRegex;
  48291. private _engine;
  48292. /**
  48293. * Instantiates a ColorGradingTexture from the following parameters.
  48294. *
  48295. * @param url The location of the color gradind data (currently only supporting 3dl)
  48296. * @param scene The scene the texture will be used in
  48297. */
  48298. constructor(url: string, scene: Scene);
  48299. /**
  48300. * Returns the texture matrix used in most of the material.
  48301. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48302. */
  48303. getTextureMatrix(): Matrix;
  48304. /**
  48305. * Occurs when the file being loaded is a .3dl LUT file.
  48306. */
  48307. private load3dlTexture;
  48308. /**
  48309. * Starts the loading process of the texture.
  48310. */
  48311. private loadTexture;
  48312. /**
  48313. * Clones the color gradind texture.
  48314. */
  48315. clone(): ColorGradingTexture;
  48316. /**
  48317. * Called during delayed load for textures.
  48318. */
  48319. delayLoad(): void;
  48320. /**
  48321. * Parses a color grading texture serialized by Babylon.
  48322. * @param parsedTexture The texture information being parsedTexture
  48323. * @param scene The scene to load the texture in
  48324. * @param rootUrl The root url of the data assets to load
  48325. * @return A color gradind texture
  48326. */
  48327. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48328. /**
  48329. * Serializes the LUT texture to json format.
  48330. */
  48331. serialize(): any;
  48332. }
  48333. }
  48334. declare module "babylonjs/Misc/dds" {
  48335. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48336. import { Engine } from "babylonjs/Engines/engine";
  48337. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48338. import { Nullable } from "babylonjs/types";
  48339. import { Scene } from "babylonjs/scene";
  48340. /**
  48341. * Direct draw surface info
  48342. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48343. */
  48344. export interface DDSInfo {
  48345. /**
  48346. * Width of the texture
  48347. */
  48348. width: number;
  48349. /**
  48350. * Width of the texture
  48351. */
  48352. height: number;
  48353. /**
  48354. * Number of Mipmaps for the texture
  48355. * @see https://en.wikipedia.org/wiki/Mipmap
  48356. */
  48357. mipmapCount: number;
  48358. /**
  48359. * If the textures format is a known fourCC format
  48360. * @see https://www.fourcc.org/
  48361. */
  48362. isFourCC: boolean;
  48363. /**
  48364. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48365. */
  48366. isRGB: boolean;
  48367. /**
  48368. * If the texture is a lumincance format
  48369. */
  48370. isLuminance: boolean;
  48371. /**
  48372. * If this is a cube texture
  48373. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48374. */
  48375. isCube: boolean;
  48376. /**
  48377. * If the texture is a compressed format eg. FOURCC_DXT1
  48378. */
  48379. isCompressed: boolean;
  48380. /**
  48381. * The dxgiFormat of the texture
  48382. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48383. */
  48384. dxgiFormat: number;
  48385. /**
  48386. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48387. */
  48388. textureType: number;
  48389. /**
  48390. * Sphericle polynomial created for the dds texture
  48391. */
  48392. sphericalPolynomial?: SphericalPolynomial;
  48393. }
  48394. /**
  48395. * Class used to provide DDS decompression tools
  48396. */
  48397. export class DDSTools {
  48398. /**
  48399. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48400. */
  48401. static StoreLODInAlphaChannel: boolean;
  48402. /**
  48403. * Gets DDS information from an array buffer
  48404. * @param arrayBuffer defines the array buffer to read data from
  48405. * @returns the DDS information
  48406. */
  48407. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48408. private static _FloatView;
  48409. private static _Int32View;
  48410. private static _ToHalfFloat;
  48411. private static _FromHalfFloat;
  48412. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48413. private static _GetHalfFloatRGBAArrayBuffer;
  48414. private static _GetFloatRGBAArrayBuffer;
  48415. private static _GetFloatAsUIntRGBAArrayBuffer;
  48416. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48417. private static _GetRGBAArrayBuffer;
  48418. private static _ExtractLongWordOrder;
  48419. private static _GetRGBArrayBuffer;
  48420. private static _GetLuminanceArrayBuffer;
  48421. /**
  48422. * Uploads DDS Levels to a Babylon Texture
  48423. * @hidden
  48424. */
  48425. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48426. }
  48427. module "babylonjs/Engines/engine" {
  48428. interface Engine {
  48429. /**
  48430. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48431. * @param rootUrl defines the url where the file to load is located
  48432. * @param scene defines the current scene
  48433. * @param lodScale defines scale to apply to the mip map selection
  48434. * @param lodOffset defines offset to apply to the mip map selection
  48435. * @param onLoad defines an optional callback raised when the texture is loaded
  48436. * @param onError defines an optional callback raised if there is an issue to load the texture
  48437. * @param format defines the format of the data
  48438. * @param forcedExtension defines the extension to use to pick the right loader
  48439. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48440. * @returns the cube texture as an InternalTexture
  48441. */
  48442. 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;
  48443. }
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48449. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48450. /**
  48451. * Implementation of the DDS Texture Loader.
  48452. * @hidden
  48453. */
  48454. export class _DDSTextureLoader implements IInternalTextureLoader {
  48455. /**
  48456. * Defines wether the loader supports cascade loading the different faces.
  48457. */
  48458. readonly supportCascades: boolean;
  48459. /**
  48460. * This returns if the loader support the current file information.
  48461. * @param extension defines the file extension of the file being loaded
  48462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48463. * @param fallback defines the fallback internal texture if any
  48464. * @param isBase64 defines whether the texture is encoded as a base64
  48465. * @param isBuffer defines whether the texture data are stored as a buffer
  48466. * @returns true if the loader can load the specified file
  48467. */
  48468. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48469. /**
  48470. * Transform the url before loading if required.
  48471. * @param rootUrl the url of the texture
  48472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48473. * @returns the transformed texture
  48474. */
  48475. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48476. /**
  48477. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48478. * @param rootUrl the url of the texture
  48479. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48480. * @returns the fallback texture
  48481. */
  48482. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48483. /**
  48484. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48485. * @param data contains the texture data
  48486. * @param texture defines the BabylonJS internal texture
  48487. * @param createPolynomials will be true if polynomials have been requested
  48488. * @param onLoad defines the callback to trigger once the texture is ready
  48489. * @param onError defines the callback to trigger in case of error
  48490. */
  48491. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48492. /**
  48493. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48494. * @param data contains the texture data
  48495. * @param texture defines the BabylonJS internal texture
  48496. * @param callback defines the method to call once ready to upload
  48497. */
  48498. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48499. }
  48500. }
  48501. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48503. /** @hidden */
  48504. export var rgbdEncodePixelShader: {
  48505. name: string;
  48506. shader: string;
  48507. };
  48508. }
  48509. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48510. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48511. /** @hidden */
  48512. export var rgbdDecodePixelShader: {
  48513. name: string;
  48514. shader: string;
  48515. };
  48516. }
  48517. declare module "babylonjs/Misc/environmentTextureTools" {
  48518. import { Nullable } from "babylonjs/types";
  48519. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48521. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48522. import "babylonjs/Shaders/rgbdEncode.fragment";
  48523. import "babylonjs/Shaders/rgbdDecode.fragment";
  48524. /**
  48525. * Raw texture data and descriptor sufficient for WebGL texture upload
  48526. */
  48527. export interface EnvironmentTextureInfo {
  48528. /**
  48529. * Version of the environment map
  48530. */
  48531. version: number;
  48532. /**
  48533. * Width of image
  48534. */
  48535. width: number;
  48536. /**
  48537. * Irradiance information stored in the file.
  48538. */
  48539. irradiance: any;
  48540. /**
  48541. * Specular information stored in the file.
  48542. */
  48543. specular: any;
  48544. }
  48545. /**
  48546. * Sets of helpers addressing the serialization and deserialization of environment texture
  48547. * stored in a BabylonJS env file.
  48548. * Those files are usually stored as .env files.
  48549. */
  48550. export class EnvironmentTextureTools {
  48551. /**
  48552. * Magic number identifying the env file.
  48553. */
  48554. private static _MagicBytes;
  48555. /**
  48556. * Gets the environment info from an env file.
  48557. * @param data The array buffer containing the .env bytes.
  48558. * @returns the environment file info (the json header) if successfully parsed.
  48559. */
  48560. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48561. /**
  48562. * Creates an environment texture from a loaded cube texture.
  48563. * @param texture defines the cube texture to convert in env file
  48564. * @return a promise containing the environment data if succesfull.
  48565. */
  48566. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48567. /**
  48568. * Creates a JSON representation of the spherical data.
  48569. * @param texture defines the texture containing the polynomials
  48570. * @return the JSON representation of the spherical info
  48571. */
  48572. private static _CreateEnvTextureIrradiance;
  48573. /**
  48574. * Uploads the texture info contained in the env file to the GPU.
  48575. * @param texture defines the internal texture to upload to
  48576. * @param arrayBuffer defines the buffer cotaining the data to load
  48577. * @param info defines the texture info retrieved through the GetEnvInfo method
  48578. * @returns a promise
  48579. */
  48580. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48581. /**
  48582. * Uploads the levels of image data to the GPU.
  48583. * @param texture defines the internal texture to upload to
  48584. * @param imageData defines the array buffer views of image data [mipmap][face]
  48585. * @returns a promise
  48586. */
  48587. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48588. /**
  48589. * Uploads spherical polynomials information to the texture.
  48590. * @param texture defines the texture we are trying to upload the information to
  48591. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48592. */
  48593. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48594. /** @hidden */
  48595. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48596. }
  48597. }
  48598. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48599. import { Nullable } from "babylonjs/types";
  48600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48601. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48602. /**
  48603. * Implementation of the ENV Texture Loader.
  48604. * @hidden
  48605. */
  48606. export class _ENVTextureLoader implements IInternalTextureLoader {
  48607. /**
  48608. * Defines wether the loader supports cascade loading the different faces.
  48609. */
  48610. readonly supportCascades: boolean;
  48611. /**
  48612. * This returns if the loader support the current file information.
  48613. * @param extension defines the file extension of the file being loaded
  48614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48615. * @param fallback defines the fallback internal texture if any
  48616. * @param isBase64 defines whether the texture is encoded as a base64
  48617. * @param isBuffer defines whether the texture data are stored as a buffer
  48618. * @returns true if the loader can load the specified file
  48619. */
  48620. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48621. /**
  48622. * Transform the url before loading if required.
  48623. * @param rootUrl the url of the texture
  48624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48625. * @returns the transformed texture
  48626. */
  48627. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48628. /**
  48629. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48630. * @param rootUrl the url of the texture
  48631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48632. * @returns the fallback texture
  48633. */
  48634. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48635. /**
  48636. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48637. * @param data contains the texture data
  48638. * @param texture defines the BabylonJS internal texture
  48639. * @param createPolynomials will be true if polynomials have been requested
  48640. * @param onLoad defines the callback to trigger once the texture is ready
  48641. * @param onError defines the callback to trigger in case of error
  48642. */
  48643. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48644. /**
  48645. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48646. * @param data contains the texture data
  48647. * @param texture defines the BabylonJS internal texture
  48648. * @param callback defines the method to call once ready to upload
  48649. */
  48650. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48651. }
  48652. }
  48653. declare module "babylonjs/Misc/khronosTextureContainer" {
  48654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48655. /**
  48656. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48657. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48658. */
  48659. export class KhronosTextureContainer {
  48660. /** contents of the KTX container file */
  48661. arrayBuffer: any;
  48662. private static HEADER_LEN;
  48663. private static COMPRESSED_2D;
  48664. private static COMPRESSED_3D;
  48665. private static TEX_2D;
  48666. private static TEX_3D;
  48667. /**
  48668. * Gets the openGL type
  48669. */
  48670. glType: number;
  48671. /**
  48672. * Gets the openGL type size
  48673. */
  48674. glTypeSize: number;
  48675. /**
  48676. * Gets the openGL format
  48677. */
  48678. glFormat: number;
  48679. /**
  48680. * Gets the openGL internal format
  48681. */
  48682. glInternalFormat: number;
  48683. /**
  48684. * Gets the base internal format
  48685. */
  48686. glBaseInternalFormat: number;
  48687. /**
  48688. * Gets image width in pixel
  48689. */
  48690. pixelWidth: number;
  48691. /**
  48692. * Gets image height in pixel
  48693. */
  48694. pixelHeight: number;
  48695. /**
  48696. * Gets image depth in pixels
  48697. */
  48698. pixelDepth: number;
  48699. /**
  48700. * Gets the number of array elements
  48701. */
  48702. numberOfArrayElements: number;
  48703. /**
  48704. * Gets the number of faces
  48705. */
  48706. numberOfFaces: number;
  48707. /**
  48708. * Gets the number of mipmap levels
  48709. */
  48710. numberOfMipmapLevels: number;
  48711. /**
  48712. * Gets the bytes of key value data
  48713. */
  48714. bytesOfKeyValueData: number;
  48715. /**
  48716. * Gets the load type
  48717. */
  48718. loadType: number;
  48719. /**
  48720. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48721. */
  48722. isInvalid: boolean;
  48723. /**
  48724. * Creates a new KhronosTextureContainer
  48725. * @param arrayBuffer contents of the KTX container file
  48726. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48727. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48728. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48729. */
  48730. constructor(
  48731. /** contents of the KTX container file */
  48732. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48733. /**
  48734. * Uploads KTX content to a Babylon Texture.
  48735. * It is assumed that the texture has already been created & is currently bound
  48736. * @hidden
  48737. */
  48738. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48739. private _upload2DCompressedLevels;
  48740. }
  48741. }
  48742. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48743. import { Nullable } from "babylonjs/types";
  48744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48745. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48746. /**
  48747. * Implementation of the KTX Texture Loader.
  48748. * @hidden
  48749. */
  48750. export class _KTXTextureLoader implements IInternalTextureLoader {
  48751. /**
  48752. * Defines wether the loader supports cascade loading the different faces.
  48753. */
  48754. readonly supportCascades: boolean;
  48755. /**
  48756. * This returns if the loader support the current file information.
  48757. * @param extension defines the file extension of the file being loaded
  48758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48759. * @param fallback defines the fallback internal texture if any
  48760. * @param isBase64 defines whether the texture is encoded as a base64
  48761. * @param isBuffer defines whether the texture data are stored as a buffer
  48762. * @returns true if the loader can load the specified file
  48763. */
  48764. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48765. /**
  48766. * Transform the url before loading if required.
  48767. * @param rootUrl the url of the texture
  48768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48769. * @returns the transformed texture
  48770. */
  48771. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48772. /**
  48773. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48774. * @param rootUrl the url of the texture
  48775. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48776. * @returns the fallback texture
  48777. */
  48778. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48779. /**
  48780. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48781. * @param data contains the texture data
  48782. * @param texture defines the BabylonJS internal texture
  48783. * @param createPolynomials will be true if polynomials have been requested
  48784. * @param onLoad defines the callback to trigger once the texture is ready
  48785. * @param onError defines the callback to trigger in case of error
  48786. */
  48787. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48788. /**
  48789. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48790. * @param data contains the texture data
  48791. * @param texture defines the BabylonJS internal texture
  48792. * @param callback defines the method to call once ready to upload
  48793. */
  48794. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48795. }
  48796. }
  48797. declare module "babylonjs/Misc/tga" {
  48798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48799. /**
  48800. * Based on jsTGALoader - Javascript loader for TGA file
  48801. * By Vincent Thibault
  48802. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48803. */
  48804. export class TGATools {
  48805. private static _TYPE_INDEXED;
  48806. private static _TYPE_RGB;
  48807. private static _TYPE_GREY;
  48808. private static _TYPE_RLE_INDEXED;
  48809. private static _TYPE_RLE_RGB;
  48810. private static _TYPE_RLE_GREY;
  48811. private static _ORIGIN_MASK;
  48812. private static _ORIGIN_SHIFT;
  48813. private static _ORIGIN_BL;
  48814. private static _ORIGIN_BR;
  48815. private static _ORIGIN_UL;
  48816. private static _ORIGIN_UR;
  48817. /**
  48818. * Gets the header of a TGA file
  48819. * @param data defines the TGA data
  48820. * @returns the header
  48821. */
  48822. static GetTGAHeader(data: Uint8Array): any;
  48823. /**
  48824. * Uploads TGA content to a Babylon Texture
  48825. * @hidden
  48826. */
  48827. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48828. /** @hidden */
  48829. 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;
  48830. /** @hidden */
  48831. 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;
  48832. /** @hidden */
  48833. 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;
  48834. /** @hidden */
  48835. 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;
  48836. /** @hidden */
  48837. 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;
  48838. /** @hidden */
  48839. 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;
  48840. }
  48841. }
  48842. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48843. import { Nullable } from "babylonjs/types";
  48844. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48845. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48846. /**
  48847. * Implementation of the TGA Texture Loader.
  48848. * @hidden
  48849. */
  48850. export class _TGATextureLoader implements IInternalTextureLoader {
  48851. /**
  48852. * Defines wether the loader supports cascade loading the different faces.
  48853. */
  48854. readonly supportCascades: boolean;
  48855. /**
  48856. * This returns if the loader support the current file information.
  48857. * @param extension defines the file extension of the file being loaded
  48858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48859. * @param fallback defines the fallback internal texture if any
  48860. * @param isBase64 defines whether the texture is encoded as a base64
  48861. * @param isBuffer defines whether the texture data are stored as a buffer
  48862. * @returns true if the loader can load the specified file
  48863. */
  48864. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48865. /**
  48866. * Transform the url before loading if required.
  48867. * @param rootUrl the url of the texture
  48868. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48869. * @returns the transformed texture
  48870. */
  48871. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48872. /**
  48873. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48874. * @param rootUrl the url of the texture
  48875. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48876. * @returns the fallback texture
  48877. */
  48878. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48879. /**
  48880. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48881. * @param data contains the texture data
  48882. * @param texture defines the BabylonJS internal texture
  48883. * @param createPolynomials will be true if polynomials have been requested
  48884. * @param onLoad defines the callback to trigger once the texture is ready
  48885. * @param onError defines the callback to trigger in case of error
  48886. */
  48887. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48888. /**
  48889. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48890. * @param data contains the texture data
  48891. * @param texture defines the BabylonJS internal texture
  48892. * @param callback defines the method to call once ready to upload
  48893. */
  48894. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48895. }
  48896. }
  48897. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48898. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48899. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48900. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48901. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48902. }
  48903. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48904. import { Scene } from "babylonjs/scene";
  48905. import { Texture } from "babylonjs/Materials/Textures/texture";
  48906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48907. /**
  48908. * 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.
  48909. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48910. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48911. */
  48912. export class CustomProceduralTexture extends ProceduralTexture {
  48913. private _animate;
  48914. private _time;
  48915. private _config;
  48916. private _texturePath;
  48917. /**
  48918. * Instantiates a new Custom Procedural Texture.
  48919. * 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.
  48920. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48921. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48922. * @param name Define the name of the texture
  48923. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48924. * @param size Define the size of the texture to create
  48925. * @param scene Define the scene the texture belongs to
  48926. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48927. * @param generateMipMaps Define if the texture should creates mip maps or not
  48928. */
  48929. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48930. private _loadJson;
  48931. /**
  48932. * Is the texture ready to be used ? (rendered at least once)
  48933. * @returns true if ready, otherwise, false.
  48934. */
  48935. isReady(): boolean;
  48936. /**
  48937. * Render the texture to its associated render target.
  48938. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48939. */
  48940. render(useCameraPostProcess?: boolean): void;
  48941. /**
  48942. * Update the list of dependant textures samplers in the shader.
  48943. */
  48944. updateTextures(): void;
  48945. /**
  48946. * Update the uniform values of the procedural texture in the shader.
  48947. */
  48948. updateShaderUniforms(): void;
  48949. /**
  48950. * Define if the texture animates or not.
  48951. */
  48952. animate: boolean;
  48953. }
  48954. }
  48955. declare module "babylonjs/Shaders/noise.fragment" {
  48956. /** @hidden */
  48957. export var noisePixelShader: {
  48958. name: string;
  48959. shader: string;
  48960. };
  48961. }
  48962. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48963. import { Nullable } from "babylonjs/types";
  48964. import { Scene } from "babylonjs/scene";
  48965. import { Texture } from "babylonjs/Materials/Textures/texture";
  48966. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48967. import "babylonjs/Shaders/noise.fragment";
  48968. /**
  48969. * Class used to generate noise procedural textures
  48970. */
  48971. export class NoiseProceduralTexture extends ProceduralTexture {
  48972. private _time;
  48973. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48974. brightness: number;
  48975. /** Defines the number of octaves to process */
  48976. octaves: number;
  48977. /** Defines the level of persistence (0.8 by default) */
  48978. persistence: number;
  48979. /** Gets or sets animation speed factor (default is 1) */
  48980. animationSpeedFactor: number;
  48981. /**
  48982. * Creates a new NoiseProceduralTexture
  48983. * @param name defines the name fo the texture
  48984. * @param size defines the size of the texture (default is 256)
  48985. * @param scene defines the hosting scene
  48986. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48987. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48988. */
  48989. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48990. private _updateShaderUniforms;
  48991. protected _getDefines(): string;
  48992. /** Generate the current state of the procedural texture */
  48993. render(useCameraPostProcess?: boolean): void;
  48994. /**
  48995. * Serializes this noise procedural texture
  48996. * @returns a serialized noise procedural texture object
  48997. */
  48998. serialize(): any;
  48999. /**
  49000. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49001. * @param parsedTexture defines parsed texture data
  49002. * @param scene defines the current scene
  49003. * @param rootUrl defines the root URL containing noise procedural texture information
  49004. * @returns a parsed NoiseProceduralTexture
  49005. */
  49006. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49007. }
  49008. }
  49009. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49010. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49011. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49012. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49013. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49014. }
  49015. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49016. import { Nullable } from "babylonjs/types";
  49017. import { Scene } from "babylonjs/scene";
  49018. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49020. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49021. /**
  49022. * Raw cube texture where the raw buffers are passed in
  49023. */
  49024. export class RawCubeTexture extends CubeTexture {
  49025. /**
  49026. * Creates a cube texture where the raw buffers are passed in.
  49027. * @param scene defines the scene the texture is attached to
  49028. * @param data defines the array of data to use to create each face
  49029. * @param size defines the size of the textures
  49030. * @param format defines the format of the data
  49031. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49032. * @param generateMipMaps defines if the engine should generate the mip levels
  49033. * @param invertY defines if data must be stored with Y axis inverted
  49034. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49035. * @param compression defines the compression used (null by default)
  49036. */
  49037. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49038. /**
  49039. * Updates the raw cube texture.
  49040. * @param data defines the data to store
  49041. * @param format defines the data format
  49042. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49043. * @param invertY defines if data must be stored with Y axis inverted
  49044. * @param compression defines the compression used (null by default)
  49045. * @param level defines which level of the texture to update
  49046. */
  49047. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49048. /**
  49049. * Updates a raw cube texture with RGBD encoded data.
  49050. * @param data defines the array of data [mipmap][face] to use to create each face
  49051. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49052. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49053. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49054. * @returns a promsie that resolves when the operation is complete
  49055. */
  49056. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49057. /**
  49058. * Clones the raw cube texture.
  49059. * @return a new cube texture
  49060. */
  49061. clone(): CubeTexture;
  49062. /** @hidden */
  49063. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49064. }
  49065. }
  49066. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49067. import { Scene } from "babylonjs/scene";
  49068. import { Texture } from "babylonjs/Materials/Textures/texture";
  49069. /**
  49070. * Class used to store 3D textures containing user data
  49071. */
  49072. export class RawTexture3D extends Texture {
  49073. /** Gets or sets the texture format to use */
  49074. format: number;
  49075. private _engine;
  49076. /**
  49077. * Create a new RawTexture3D
  49078. * @param data defines the data of the texture
  49079. * @param width defines the width of the texture
  49080. * @param height defines the height of the texture
  49081. * @param depth defines the depth of the texture
  49082. * @param format defines the texture format to use
  49083. * @param scene defines the hosting scene
  49084. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49085. * @param invertY defines if texture must be stored with Y axis inverted
  49086. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49087. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49088. */
  49089. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49090. /** Gets or sets the texture format to use */
  49091. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49092. /**
  49093. * Update the texture with new data
  49094. * @param data defines the data to store in the texture
  49095. */
  49096. update(data: ArrayBufferView): void;
  49097. }
  49098. }
  49099. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49100. import { Scene } from "babylonjs/scene";
  49101. import { Plane } from "babylonjs/Maths/math";
  49102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49103. /**
  49104. * Creates a refraction texture used by refraction channel of the standard material.
  49105. * It is like a mirror but to see through a material.
  49106. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49107. */
  49108. export class RefractionTexture extends RenderTargetTexture {
  49109. /**
  49110. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49111. * 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.
  49112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49113. */
  49114. refractionPlane: Plane;
  49115. /**
  49116. * Define how deep under the surface we should see.
  49117. */
  49118. depth: number;
  49119. /**
  49120. * Creates a refraction texture used by refraction channel of the standard material.
  49121. * It is like a mirror but to see through a material.
  49122. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49123. * @param name Define the texture name
  49124. * @param size Define the size of the underlying texture
  49125. * @param scene Define the scene the refraction belongs to
  49126. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49127. */
  49128. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49129. /**
  49130. * Clone the refraction texture.
  49131. * @returns the cloned texture
  49132. */
  49133. clone(): RefractionTexture;
  49134. /**
  49135. * Serialize the texture to a JSON representation you could use in Parse later on
  49136. * @returns the serialized JSON representation
  49137. */
  49138. serialize(): any;
  49139. }
  49140. }
  49141. declare module "babylonjs/Materials/Textures/index" {
  49142. export * from "babylonjs/Materials/Textures/baseTexture";
  49143. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49144. export * from "babylonjs/Materials/Textures/cubeTexture";
  49145. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49146. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49147. export * from "babylonjs/Materials/Textures/internalTexture";
  49148. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49149. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49150. export * from "babylonjs/Materials/Textures/Loaders/index";
  49151. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49152. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49153. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49154. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49155. export * from "babylonjs/Materials/Textures/rawTexture";
  49156. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49157. export * from "babylonjs/Materials/Textures/refractionTexture";
  49158. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49159. export * from "babylonjs/Materials/Textures/texture";
  49160. export * from "babylonjs/Materials/Textures/videoTexture";
  49161. }
  49162. declare module "babylonjs/Materials/index" {
  49163. export * from "babylonjs/Materials/Background/index";
  49164. export * from "babylonjs/Materials/colorCurves";
  49165. export * from "babylonjs/Materials/effect";
  49166. export * from "babylonjs/Materials/fresnelParameters";
  49167. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49168. export * from "babylonjs/Materials/material";
  49169. export * from "babylonjs/Materials/materialDefines";
  49170. export * from "babylonjs/Materials/materialHelper";
  49171. export * from "babylonjs/Materials/multiMaterial";
  49172. export * from "babylonjs/Materials/PBR/index";
  49173. export * from "babylonjs/Materials/pushMaterial";
  49174. export * from "babylonjs/Materials/shaderMaterial";
  49175. export * from "babylonjs/Materials/standardMaterial";
  49176. export * from "babylonjs/Materials/Textures/index";
  49177. export * from "babylonjs/Materials/uniformBuffer";
  49178. export * from "babylonjs/Materials/materialFlags";
  49179. }
  49180. declare module "babylonjs/Maths/index" {
  49181. export * from "babylonjs/Maths/math.scalar";
  49182. export * from "babylonjs/Maths/math";
  49183. export * from "babylonjs/Maths/sphericalPolynomial";
  49184. }
  49185. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49186. import { IDisposable } from "babylonjs/scene";
  49187. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49188. /**
  49189. * Configuration for Draco compression
  49190. */
  49191. export interface IDracoCompressionConfiguration {
  49192. /**
  49193. * Configuration for the decoder.
  49194. */
  49195. decoder?: {
  49196. /**
  49197. * The url to the WebAssembly module.
  49198. */
  49199. wasmUrl?: string;
  49200. /**
  49201. * The url to the WebAssembly binary.
  49202. */
  49203. wasmBinaryUrl?: string;
  49204. /**
  49205. * The url to the fallback JavaScript module.
  49206. */
  49207. fallbackUrl?: string;
  49208. };
  49209. }
  49210. /**
  49211. * Draco compression (https://google.github.io/draco/)
  49212. *
  49213. * This class wraps the Draco module.
  49214. *
  49215. * **Encoder**
  49216. *
  49217. * The encoder is not currently implemented.
  49218. *
  49219. * **Decoder**
  49220. *
  49221. * 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.
  49222. *
  49223. * To update the configuration, use the following code:
  49224. * ```javascript
  49225. * DracoCompression.Configuration = {
  49226. * decoder: {
  49227. * wasmUrl: "<url to the WebAssembly library>",
  49228. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49229. * fallbackUrl: "<url to the fallback JavaScript library>",
  49230. * }
  49231. * };
  49232. * ```
  49233. *
  49234. * 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.
  49235. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49236. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49237. *
  49238. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49239. * ```javascript
  49240. * var dracoCompression = new DracoCompression();
  49241. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49242. * [VertexBuffer.PositionKind]: 0
  49243. * });
  49244. * ```
  49245. *
  49246. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49247. */
  49248. export class DracoCompression implements IDisposable {
  49249. private static _DecoderModulePromise;
  49250. /**
  49251. * The configuration. Defaults to the following urls:
  49252. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49253. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49254. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49255. */
  49256. static Configuration: IDracoCompressionConfiguration;
  49257. /**
  49258. * Returns true if the decoder is available.
  49259. */
  49260. static readonly DecoderAvailable: boolean;
  49261. /**
  49262. * Constructor
  49263. */
  49264. constructor();
  49265. /**
  49266. * Stop all async operations and release resources.
  49267. */
  49268. dispose(): void;
  49269. /**
  49270. * Decode Draco compressed mesh data to vertex data.
  49271. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49272. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49273. * @returns A promise that resolves with the decoded vertex data
  49274. */
  49275. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49276. [kind: string]: number;
  49277. }): Promise<VertexData>;
  49278. private static _GetDecoderModule;
  49279. private static _LoadScriptAsync;
  49280. private static _LoadFileAsync;
  49281. }
  49282. }
  49283. declare module "babylonjs/Meshes/Compression/index" {
  49284. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49285. }
  49286. declare module "babylonjs/Meshes/csg" {
  49287. import { Nullable } from "babylonjs/types";
  49288. import { Scene } from "babylonjs/scene";
  49289. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49290. import { Mesh } from "babylonjs/Meshes/mesh";
  49291. import { Material } from "babylonjs/Materials/material";
  49292. /**
  49293. * Class for building Constructive Solid Geometry
  49294. */
  49295. export class CSG {
  49296. private polygons;
  49297. /**
  49298. * The world matrix
  49299. */
  49300. matrix: Matrix;
  49301. /**
  49302. * Stores the position
  49303. */
  49304. position: Vector3;
  49305. /**
  49306. * Stores the rotation
  49307. */
  49308. rotation: Vector3;
  49309. /**
  49310. * Stores the rotation quaternion
  49311. */
  49312. rotationQuaternion: Nullable<Quaternion>;
  49313. /**
  49314. * Stores the scaling vector
  49315. */
  49316. scaling: Vector3;
  49317. /**
  49318. * Convert the Mesh to CSG
  49319. * @param mesh The Mesh to convert to CSG
  49320. * @returns A new CSG from the Mesh
  49321. */
  49322. static FromMesh(mesh: Mesh): CSG;
  49323. /**
  49324. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49325. * @param polygons Polygons used to construct a CSG solid
  49326. */
  49327. private static FromPolygons;
  49328. /**
  49329. * Clones, or makes a deep copy, of the CSG
  49330. * @returns A new CSG
  49331. */
  49332. clone(): CSG;
  49333. /**
  49334. * Unions this CSG with another CSG
  49335. * @param csg The CSG to union against this CSG
  49336. * @returns The unioned CSG
  49337. */
  49338. union(csg: CSG): CSG;
  49339. /**
  49340. * Unions this CSG with another CSG in place
  49341. * @param csg The CSG to union against this CSG
  49342. */
  49343. unionInPlace(csg: CSG): void;
  49344. /**
  49345. * Subtracts this CSG with another CSG
  49346. * @param csg The CSG to subtract against this CSG
  49347. * @returns A new CSG
  49348. */
  49349. subtract(csg: CSG): CSG;
  49350. /**
  49351. * Subtracts this CSG with another CSG in place
  49352. * @param csg The CSG to subtact against this CSG
  49353. */
  49354. subtractInPlace(csg: CSG): void;
  49355. /**
  49356. * Intersect this CSG with another CSG
  49357. * @param csg The CSG to intersect against this CSG
  49358. * @returns A new CSG
  49359. */
  49360. intersect(csg: CSG): CSG;
  49361. /**
  49362. * Intersects this CSG with another CSG in place
  49363. * @param csg The CSG to intersect against this CSG
  49364. */
  49365. intersectInPlace(csg: CSG): void;
  49366. /**
  49367. * Return a new CSG solid with solid and empty space switched. This solid is
  49368. * not modified.
  49369. * @returns A new CSG solid with solid and empty space switched
  49370. */
  49371. inverse(): CSG;
  49372. /**
  49373. * Inverses the CSG in place
  49374. */
  49375. inverseInPlace(): void;
  49376. /**
  49377. * This is used to keep meshes transformations so they can be restored
  49378. * when we build back a Babylon Mesh
  49379. * NB : All CSG operations are performed in world coordinates
  49380. * @param csg The CSG to copy the transform attributes from
  49381. * @returns This CSG
  49382. */
  49383. copyTransformAttributes(csg: CSG): CSG;
  49384. /**
  49385. * Build Raw mesh from CSG
  49386. * Coordinates here are in world space
  49387. * @param name The name of the mesh geometry
  49388. * @param scene The Scene
  49389. * @param keepSubMeshes Specifies if the submeshes should be kept
  49390. * @returns A new Mesh
  49391. */
  49392. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49393. /**
  49394. * Build Mesh from CSG taking material and transforms into account
  49395. * @param name The name of the Mesh
  49396. * @param material The material of the Mesh
  49397. * @param scene The Scene
  49398. * @param keepSubMeshes Specifies if submeshes should be kept
  49399. * @returns The new Mesh
  49400. */
  49401. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49402. }
  49403. }
  49404. declare module "babylonjs/Meshes/meshSimplification" {
  49405. import { Mesh } from "babylonjs/Meshes/mesh";
  49406. /**
  49407. * A simplifier interface for future simplification implementations
  49408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49409. */
  49410. export interface ISimplifier {
  49411. /**
  49412. * Simplification of a given mesh according to the given settings.
  49413. * Since this requires computation, it is assumed that the function runs async.
  49414. * @param settings The settings of the simplification, including quality and distance
  49415. * @param successCallback A callback that will be called after the mesh was simplified.
  49416. * @param errorCallback in case of an error, this callback will be called. optional.
  49417. */
  49418. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49419. }
  49420. /**
  49421. * Expected simplification settings.
  49422. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49423. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49424. */
  49425. export interface ISimplificationSettings {
  49426. /**
  49427. * Gets or sets the expected quality
  49428. */
  49429. quality: number;
  49430. /**
  49431. * Gets or sets the distance when this optimized version should be used
  49432. */
  49433. distance: number;
  49434. /**
  49435. * Gets an already optimized mesh
  49436. */
  49437. optimizeMesh?: boolean;
  49438. }
  49439. /**
  49440. * Class used to specify simplification options
  49441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49442. */
  49443. export class SimplificationSettings implements ISimplificationSettings {
  49444. /** expected quality */
  49445. quality: number;
  49446. /** distance when this optimized version should be used */
  49447. distance: number;
  49448. /** already optimized mesh */
  49449. optimizeMesh?: boolean | undefined;
  49450. /**
  49451. * Creates a SimplificationSettings
  49452. * @param quality expected quality
  49453. * @param distance distance when this optimized version should be used
  49454. * @param optimizeMesh already optimized mesh
  49455. */
  49456. constructor(
  49457. /** expected quality */
  49458. quality: number,
  49459. /** distance when this optimized version should be used */
  49460. distance: number,
  49461. /** already optimized mesh */
  49462. optimizeMesh?: boolean | undefined);
  49463. }
  49464. /**
  49465. * Interface used to define a simplification task
  49466. */
  49467. export interface ISimplificationTask {
  49468. /**
  49469. * Array of settings
  49470. */
  49471. settings: Array<ISimplificationSettings>;
  49472. /**
  49473. * Simplification type
  49474. */
  49475. simplificationType: SimplificationType;
  49476. /**
  49477. * Mesh to simplify
  49478. */
  49479. mesh: Mesh;
  49480. /**
  49481. * Callback called on success
  49482. */
  49483. successCallback?: () => void;
  49484. /**
  49485. * Defines if parallel processing can be used
  49486. */
  49487. parallelProcessing: boolean;
  49488. }
  49489. /**
  49490. * Queue used to order the simplification tasks
  49491. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49492. */
  49493. export class SimplificationQueue {
  49494. private _simplificationArray;
  49495. /**
  49496. * Gets a boolean indicating that the process is still running
  49497. */
  49498. running: boolean;
  49499. /**
  49500. * Creates a new queue
  49501. */
  49502. constructor();
  49503. /**
  49504. * Adds a new simplification task
  49505. * @param task defines a task to add
  49506. */
  49507. addTask(task: ISimplificationTask): void;
  49508. /**
  49509. * Execute next task
  49510. */
  49511. executeNext(): void;
  49512. /**
  49513. * Execute a simplification task
  49514. * @param task defines the task to run
  49515. */
  49516. runSimplification(task: ISimplificationTask): void;
  49517. private getSimplifier;
  49518. }
  49519. /**
  49520. * The implemented types of simplification
  49521. * At the moment only Quadratic Error Decimation is implemented
  49522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49523. */
  49524. export enum SimplificationType {
  49525. /** Quadratic error decimation */
  49526. QUADRATIC = 0
  49527. }
  49528. }
  49529. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49530. import { Scene } from "babylonjs/scene";
  49531. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49532. import { ISceneComponent } from "babylonjs/sceneComponent";
  49533. module "babylonjs/scene" {
  49534. interface Scene {
  49535. /** @hidden (Backing field) */
  49536. _simplificationQueue: SimplificationQueue;
  49537. /**
  49538. * Gets or sets the simplification queue attached to the scene
  49539. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49540. */
  49541. simplificationQueue: SimplificationQueue;
  49542. }
  49543. }
  49544. module "babylonjs/Meshes/mesh" {
  49545. interface Mesh {
  49546. /**
  49547. * Simplify the mesh according to the given array of settings.
  49548. * Function will return immediately and will simplify async
  49549. * @param settings a collection of simplification settings
  49550. * @param parallelProcessing should all levels calculate parallel or one after the other
  49551. * @param simplificationType the type of simplification to run
  49552. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49553. * @returns the current mesh
  49554. */
  49555. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49556. }
  49557. }
  49558. /**
  49559. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49560. * created in a scene
  49561. */
  49562. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49563. /**
  49564. * The component name helpfull to identify the component in the list of scene components.
  49565. */
  49566. readonly name: string;
  49567. /**
  49568. * The scene the component belongs to.
  49569. */
  49570. scene: Scene;
  49571. /**
  49572. * Creates a new instance of the component for the given scene
  49573. * @param scene Defines the scene to register the component in
  49574. */
  49575. constructor(scene: Scene);
  49576. /**
  49577. * Registers the component in a given scene
  49578. */
  49579. register(): void;
  49580. /**
  49581. * Rebuilds the elements related to this component in case of
  49582. * context lost for instance.
  49583. */
  49584. rebuild(): void;
  49585. /**
  49586. * Disposes the component and the associated ressources
  49587. */
  49588. dispose(): void;
  49589. private _beforeCameraUpdate;
  49590. }
  49591. }
  49592. declare module "babylonjs/Meshes/index" {
  49593. export * from "babylonjs/Meshes/abstractMesh";
  49594. export * from "babylonjs/Meshes/buffer";
  49595. export * from "babylonjs/Meshes/Compression/index";
  49596. export * from "babylonjs/Meshes/csg";
  49597. export * from "babylonjs/Meshes/geometry";
  49598. export * from "babylonjs/Meshes/groundMesh";
  49599. export * from "babylonjs/Meshes/instancedMesh";
  49600. export * from "babylonjs/Meshes/linesMesh";
  49601. export * from "babylonjs/Meshes/mesh";
  49602. export * from "babylonjs/Meshes/mesh.vertexData";
  49603. export * from "babylonjs/Meshes/meshBuilder";
  49604. export * from "babylonjs/Meshes/meshSimplification";
  49605. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  49606. export * from "babylonjs/Meshes/polygonMesh";
  49607. export * from "babylonjs/Meshes/subMesh";
  49608. export * from "babylonjs/Meshes/transformNode";
  49609. }
  49610. declare module "babylonjs/Morph/index" {
  49611. export * from "babylonjs/Morph/morphTarget";
  49612. export * from "babylonjs/Morph/morphTargetManager";
  49613. }
  49614. declare module "babylonjs/Offline/database" {
  49615. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  49616. /**
  49617. * Class used to enable access to IndexedDB
  49618. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49619. */
  49620. export class Database implements IOfflineProvider {
  49621. private _callbackManifestChecked;
  49622. private _currentSceneUrl;
  49623. private _db;
  49624. private _enableSceneOffline;
  49625. private _enableTexturesOffline;
  49626. private _manifestVersionFound;
  49627. private _mustUpdateRessources;
  49628. private _hasReachedQuota;
  49629. private _isSupported;
  49630. private _idbFactory;
  49631. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49632. private static IsUASupportingBlobStorage;
  49633. /**
  49634. * Gets a boolean indicating if Database storate is enabled (off by default)
  49635. */
  49636. static IDBStorageEnabled: boolean;
  49637. /**
  49638. * Gets a boolean indicating if scene must be saved in the database
  49639. */
  49640. readonly enableSceneOffline: boolean;
  49641. /**
  49642. * Gets a boolean indicating if textures must be saved in the database
  49643. */
  49644. readonly enableTexturesOffline: boolean;
  49645. /**
  49646. * Creates a new Database
  49647. * @param urlToScene defines the url to load the scene
  49648. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49649. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49650. */
  49651. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49652. private static _ParseURL;
  49653. private static _ReturnFullUrlLocation;
  49654. private _checkManifestFile;
  49655. /**
  49656. * Open the database and make it available
  49657. * @param successCallback defines the callback to call on success
  49658. * @param errorCallback defines the callback to call on error
  49659. */
  49660. open(successCallback: () => void, errorCallback: () => void): void;
  49661. /**
  49662. * Loads an image from the database
  49663. * @param url defines the url to load from
  49664. * @param image defines the target DOM image
  49665. */
  49666. loadImage(url: string, image: HTMLImageElement): void;
  49667. private _loadImageFromDBAsync;
  49668. private _saveImageIntoDBAsync;
  49669. private _checkVersionFromDB;
  49670. private _loadVersionFromDBAsync;
  49671. private _saveVersionIntoDBAsync;
  49672. /**
  49673. * Loads a file from database
  49674. * @param url defines the URL to load from
  49675. * @param sceneLoaded defines a callback to call on success
  49676. * @param progressCallBack defines a callback to call when progress changed
  49677. * @param errorCallback defines a callback to call on error
  49678. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49679. */
  49680. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49681. private _loadFileAsync;
  49682. private _saveFileAsync;
  49683. /**
  49684. * Validates if xhr data is correct
  49685. * @param xhr defines the request to validate
  49686. * @param dataType defines the expected data type
  49687. * @returns true if data is correct
  49688. */
  49689. private static _ValidateXHRData;
  49690. }
  49691. }
  49692. declare module "babylonjs/Offline/index" {
  49693. export * from "babylonjs/Offline/database";
  49694. export * from "babylonjs/Offline/IOfflineProvider";
  49695. }
  49696. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  49697. /** @hidden */
  49698. export var gpuUpdateParticlesPixelShader: {
  49699. name: string;
  49700. shader: string;
  49701. };
  49702. }
  49703. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  49704. /** @hidden */
  49705. export var gpuUpdateParticlesVertexShader: {
  49706. name: string;
  49707. shader: string;
  49708. };
  49709. }
  49710. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  49711. /** @hidden */
  49712. export var clipPlaneFragmentDeclaration2: {
  49713. name: string;
  49714. shader: string;
  49715. };
  49716. }
  49717. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  49718. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  49719. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49721. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49723. /** @hidden */
  49724. export var gpuRenderParticlesPixelShader: {
  49725. name: string;
  49726. shader: string;
  49727. };
  49728. }
  49729. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  49730. /** @hidden */
  49731. export var clipPlaneVertexDeclaration2: {
  49732. name: string;
  49733. shader: string;
  49734. };
  49735. }
  49736. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  49737. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  49738. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49739. /** @hidden */
  49740. export var gpuRenderParticlesVertexShader: {
  49741. name: string;
  49742. shader: string;
  49743. };
  49744. }
  49745. declare module "babylonjs/Particles/gpuParticleSystem" {
  49746. import { Nullable } from "babylonjs/types";
  49747. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  49748. import { Observable } from "babylonjs/Misc/observable";
  49749. import { Color4, Color3 } from "babylonjs/Maths/math";
  49750. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49751. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  49752. import { Scene, IDisposable } from "babylonjs/scene";
  49753. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  49754. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  49755. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  49756. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  49757. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  49758. /**
  49759. * This represents a GPU particle system in Babylon
  49760. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49761. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49762. */
  49763. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49764. /**
  49765. * The layer mask we are rendering the particles through.
  49766. */
  49767. layerMask: number;
  49768. private _capacity;
  49769. private _activeCount;
  49770. private _currentActiveCount;
  49771. private _accumulatedCount;
  49772. private _renderEffect;
  49773. private _updateEffect;
  49774. private _buffer0;
  49775. private _buffer1;
  49776. private _spriteBuffer;
  49777. private _updateVAO;
  49778. private _renderVAO;
  49779. private _targetIndex;
  49780. private _sourceBuffer;
  49781. private _targetBuffer;
  49782. private _engine;
  49783. private _currentRenderId;
  49784. private _started;
  49785. private _stopped;
  49786. private _timeDelta;
  49787. private _randomTexture;
  49788. private _randomTexture2;
  49789. private _attributesStrideSize;
  49790. private _updateEffectOptions;
  49791. private _randomTextureSize;
  49792. private _actualFrame;
  49793. private readonly _rawTextureWidth;
  49794. /**
  49795. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49796. */
  49797. static readonly IsSupported: boolean;
  49798. /**
  49799. * An event triggered when the system is disposed.
  49800. */
  49801. onDisposeObservable: Observable<GPUParticleSystem>;
  49802. /**
  49803. * Gets the maximum number of particles active at the same time.
  49804. * @returns The max number of active particles.
  49805. */
  49806. getCapacity(): number;
  49807. /**
  49808. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49809. * to override the particles.
  49810. */
  49811. forceDepthWrite: boolean;
  49812. /**
  49813. * Gets or set the number of active particles
  49814. */
  49815. activeParticleCount: number;
  49816. private _preWarmDone;
  49817. /**
  49818. * Is this system ready to be used/rendered
  49819. * @return true if the system is ready
  49820. */
  49821. isReady(): boolean;
  49822. /**
  49823. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49824. * @returns True if it has been started, otherwise false.
  49825. */
  49826. isStarted(): boolean;
  49827. /**
  49828. * Starts the particle system and begins to emit
  49829. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49830. */
  49831. start(delay?: number): void;
  49832. /**
  49833. * Stops the particle system.
  49834. */
  49835. stop(): void;
  49836. /**
  49837. * Remove all active particles
  49838. */
  49839. reset(): void;
  49840. /**
  49841. * Returns the string "GPUParticleSystem"
  49842. * @returns a string containing the class name
  49843. */
  49844. getClassName(): string;
  49845. private _colorGradientsTexture;
  49846. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49847. /**
  49848. * Adds a new color gradient
  49849. * @param gradient defines the gradient to use (between 0 and 1)
  49850. * @param color1 defines the color to affect to the specified gradient
  49851. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49852. * @returns the current particle system
  49853. */
  49854. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49855. /**
  49856. * Remove a specific color gradient
  49857. * @param gradient defines the gradient to remove
  49858. * @returns the current particle system
  49859. */
  49860. removeColorGradient(gradient: number): GPUParticleSystem;
  49861. private _angularSpeedGradientsTexture;
  49862. private _sizeGradientsTexture;
  49863. private _velocityGradientsTexture;
  49864. private _limitVelocityGradientsTexture;
  49865. private _dragGradientsTexture;
  49866. private _addFactorGradient;
  49867. /**
  49868. * Adds a new size gradient
  49869. * @param gradient defines the gradient to use (between 0 and 1)
  49870. * @param factor defines the size factor to affect to the specified gradient
  49871. * @returns the current particle system
  49872. */
  49873. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49874. /**
  49875. * Remove a specific size gradient
  49876. * @param gradient defines the gradient to remove
  49877. * @returns the current particle system
  49878. */
  49879. removeSizeGradient(gradient: number): GPUParticleSystem;
  49880. /**
  49881. * Adds a new angular speed gradient
  49882. * @param gradient defines the gradient to use (between 0 and 1)
  49883. * @param factor defines the angular speed to affect to the specified gradient
  49884. * @returns the current particle system
  49885. */
  49886. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49887. /**
  49888. * Remove a specific angular speed gradient
  49889. * @param gradient defines the gradient to remove
  49890. * @returns the current particle system
  49891. */
  49892. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49893. /**
  49894. * Adds a new velocity gradient
  49895. * @param gradient defines the gradient to use (between 0 and 1)
  49896. * @param factor defines the velocity to affect to the specified gradient
  49897. * @returns the current particle system
  49898. */
  49899. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49900. /**
  49901. * Remove a specific velocity gradient
  49902. * @param gradient defines the gradient to remove
  49903. * @returns the current particle system
  49904. */
  49905. removeVelocityGradient(gradient: number): GPUParticleSystem;
  49906. /**
  49907. * Adds a new limit velocity gradient
  49908. * @param gradient defines the gradient to use (between 0 and 1)
  49909. * @param factor defines the limit velocity value to affect to the specified gradient
  49910. * @returns the current particle system
  49911. */
  49912. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49913. /**
  49914. * Remove a specific limit velocity gradient
  49915. * @param gradient defines the gradient to remove
  49916. * @returns the current particle system
  49917. */
  49918. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  49919. /**
  49920. * Adds a new drag gradient
  49921. * @param gradient defines the gradient to use (between 0 and 1)
  49922. * @param factor defines the drag value to affect to the specified gradient
  49923. * @returns the current particle system
  49924. */
  49925. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  49926. /**
  49927. * Remove a specific drag gradient
  49928. * @param gradient defines the gradient to remove
  49929. * @returns the current particle system
  49930. */
  49931. removeDragGradient(gradient: number): GPUParticleSystem;
  49932. /**
  49933. * Not supported by GPUParticleSystem
  49934. * @param gradient defines the gradient to use (between 0 and 1)
  49935. * @param factor defines the emit rate value to affect to the specified gradient
  49936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49937. * @returns the current particle system
  49938. */
  49939. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49940. /**
  49941. * Not supported by GPUParticleSystem
  49942. * @param gradient defines the gradient to remove
  49943. * @returns the current particle system
  49944. */
  49945. removeEmitRateGradient(gradient: number): IParticleSystem;
  49946. /**
  49947. * Not supported by GPUParticleSystem
  49948. * @param gradient defines the gradient to use (between 0 and 1)
  49949. * @param factor defines the start size value to affect to the specified gradient
  49950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  49951. * @returns the current particle system
  49952. */
  49953. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  49954. /**
  49955. * Not supported by GPUParticleSystem
  49956. * @param gradient defines the gradient to remove
  49957. * @returns the current particle system
  49958. */
  49959. removeStartSizeGradient(gradient: number): IParticleSystem;
  49960. /**
  49961. * Not supported by GPUParticleSystem
  49962. * @param gradient defines the gradient to use (between 0 and 1)
  49963. * @param min defines the color remap minimal range
  49964. * @param max defines the color remap maximal range
  49965. * @returns the current particle system
  49966. */
  49967. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49968. /**
  49969. * Not supported by GPUParticleSystem
  49970. * @param gradient defines the gradient to remove
  49971. * @returns the current particle system
  49972. */
  49973. removeColorRemapGradient(): IParticleSystem;
  49974. /**
  49975. * Not supported by GPUParticleSystem
  49976. * @param gradient defines the gradient to use (between 0 and 1)
  49977. * @param min defines the alpha remap minimal range
  49978. * @param max defines the alpha remap maximal range
  49979. * @returns the current particle system
  49980. */
  49981. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  49982. /**
  49983. * Not supported by GPUParticleSystem
  49984. * @param gradient defines the gradient to remove
  49985. * @returns the current particle system
  49986. */
  49987. removeAlphaRemapGradient(): IParticleSystem;
  49988. /**
  49989. * Not supported by GPUParticleSystem
  49990. * @param gradient defines the gradient to use (between 0 and 1)
  49991. * @param color defines the color to affect to the specified gradient
  49992. * @returns the current particle system
  49993. */
  49994. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  49995. /**
  49996. * Not supported by GPUParticleSystem
  49997. * @param gradient defines the gradient to remove
  49998. * @returns the current particle system
  49999. */
  50000. removeRampGradient(): IParticleSystem;
  50001. /**
  50002. * Not supported by GPUParticleSystem
  50003. * @returns the list of ramp gradients
  50004. */
  50005. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50006. /**
  50007. * Not supported by GPUParticleSystem
  50008. * Gets or sets a boolean indicating that ramp gradients must be used
  50009. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50010. */
  50011. useRampGradients: boolean;
  50012. /**
  50013. * Not supported by GPUParticleSystem
  50014. * @param gradient defines the gradient to use (between 0 and 1)
  50015. * @param factor defines the life time factor to affect to the specified gradient
  50016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50017. * @returns the current particle system
  50018. */
  50019. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50020. /**
  50021. * Not supported by GPUParticleSystem
  50022. * @param gradient defines the gradient to remove
  50023. * @returns the current particle system
  50024. */
  50025. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50026. /**
  50027. * Instantiates a GPU particle system.
  50028. * 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.
  50029. * @param name The name of the particle system
  50030. * @param options The options used to create the system
  50031. * @param scene The scene the particle system belongs to
  50032. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50033. */
  50034. constructor(name: string, options: Partial<{
  50035. capacity: number;
  50036. randomTextureSize: number;
  50037. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50038. protected _reset(): void;
  50039. private _createUpdateVAO;
  50040. private _createRenderVAO;
  50041. private _initialize;
  50042. /** @hidden */
  50043. _recreateUpdateEffect(): void;
  50044. /** @hidden */
  50045. _recreateRenderEffect(): void;
  50046. /**
  50047. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50048. * @param preWarm defines if we are in the pre-warmimg phase
  50049. */
  50050. animate(preWarm?: boolean): void;
  50051. private _createFactorGradientTexture;
  50052. private _createSizeGradientTexture;
  50053. private _createAngularSpeedGradientTexture;
  50054. private _createVelocityGradientTexture;
  50055. private _createLimitVelocityGradientTexture;
  50056. private _createDragGradientTexture;
  50057. private _createColorGradientTexture;
  50058. /**
  50059. * Renders the particle system in its current state
  50060. * @param preWarm defines if the system should only update the particles but not render them
  50061. * @returns the current number of particles
  50062. */
  50063. render(preWarm?: boolean): number;
  50064. /**
  50065. * Rebuilds the particle system
  50066. */
  50067. rebuild(): void;
  50068. private _releaseBuffers;
  50069. private _releaseVAOs;
  50070. /**
  50071. * Disposes the particle system and free the associated resources
  50072. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50073. */
  50074. dispose(disposeTexture?: boolean): void;
  50075. /**
  50076. * Clones the particle system.
  50077. * @param name The name of the cloned object
  50078. * @param newEmitter The new emitter to use
  50079. * @returns the cloned particle system
  50080. */
  50081. clone(name: string, newEmitter: any): GPUParticleSystem;
  50082. /**
  50083. * Serializes the particle system to a JSON object.
  50084. * @returns the JSON object
  50085. */
  50086. serialize(): any;
  50087. /**
  50088. * Parses a JSON object to create a GPU particle system.
  50089. * @param parsedParticleSystem The JSON object to parse
  50090. * @param scene The scene to create the particle system in
  50091. * @param rootUrl The root url to use to load external dependencies like texture
  50092. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50093. * @returns the parsed GPU particle system
  50094. */
  50095. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50096. }
  50097. }
  50098. declare module "babylonjs/Particles/particleSystemSet" {
  50099. import { Nullable } from "babylonjs/types";
  50100. import { Color3 } from "babylonjs/Maths/math";
  50101. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50103. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50104. import { Scene, IDisposable } from "babylonjs/scene";
  50105. /**
  50106. * Represents a set of particle systems working together to create a specific effect
  50107. */
  50108. export class ParticleSystemSet implements IDisposable {
  50109. private _emitterCreationOptions;
  50110. private _emitterNode;
  50111. /**
  50112. * Gets the particle system list
  50113. */
  50114. systems: IParticleSystem[];
  50115. /**
  50116. * Gets the emitter node used with this set
  50117. */
  50118. readonly emitterNode: Nullable<TransformNode>;
  50119. /**
  50120. * Creates a new emitter mesh as a sphere
  50121. * @param options defines the options used to create the sphere
  50122. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50123. * @param scene defines the hosting scene
  50124. */
  50125. setEmitterAsSphere(options: {
  50126. diameter: number;
  50127. segments: number;
  50128. color: Color3;
  50129. }, renderingGroupId: number, scene: Scene): void;
  50130. /**
  50131. * Starts all particle systems of the set
  50132. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50133. */
  50134. start(emitter?: AbstractMesh): void;
  50135. /**
  50136. * Release all associated resources
  50137. */
  50138. dispose(): void;
  50139. /**
  50140. * Serialize the set into a JSON compatible object
  50141. * @returns a JSON compatible representation of the set
  50142. */
  50143. serialize(): any;
  50144. /**
  50145. * Parse a new ParticleSystemSet from a serialized source
  50146. * @param data defines a JSON compatible representation of the set
  50147. * @param scene defines the hosting scene
  50148. * @param gpu defines if we want GPU particles or CPU particles
  50149. * @returns a new ParticleSystemSet
  50150. */
  50151. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50152. }
  50153. }
  50154. declare module "babylonjs/Particles/particleHelper" {
  50155. import { Nullable } from "babylonjs/types";
  50156. import { Scene } from "babylonjs/scene";
  50157. import { Vector3 } from "babylonjs/Maths/math";
  50158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50159. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50160. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50161. /**
  50162. * This class is made for on one-liner static method to help creating particle system set.
  50163. */
  50164. export class ParticleHelper {
  50165. /**
  50166. * Gets or sets base Assets URL
  50167. */
  50168. static BaseAssetsUrl: string;
  50169. /**
  50170. * Create a default particle system that you can tweak
  50171. * @param emitter defines the emitter to use
  50172. * @param capacity defines the system capacity (default is 500 particles)
  50173. * @param scene defines the hosting scene
  50174. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50175. * @returns the new Particle system
  50176. */
  50177. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50178. /**
  50179. * This is the main static method (one-liner) of this helper to create different particle systems
  50180. * @param type This string represents the type to the particle system to create
  50181. * @param scene The scene where the particle system should live
  50182. * @param gpu If the system will use gpu
  50183. * @returns the ParticleSystemSet created
  50184. */
  50185. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50186. /**
  50187. * Static function used to export a particle system to a ParticleSystemSet variable.
  50188. * Please note that the emitter shape is not exported
  50189. * @param systems defines the particle systems to export
  50190. * @returns the created particle system set
  50191. */
  50192. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50193. }
  50194. }
  50195. declare module "babylonjs/Particles/particleSystemComponent" {
  50196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50197. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50198. import "babylonjs/Shaders/particles.vertex";
  50199. module "babylonjs/Engines/engine" {
  50200. interface Engine {
  50201. /**
  50202. * Create an effect to use with particle systems.
  50203. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50204. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50205. * @param uniformsNames defines a list of attribute names
  50206. * @param samplers defines an array of string used to represent textures
  50207. * @param defines defines the string containing the defines to use to compile the shaders
  50208. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50209. * @param onCompiled defines a function to call when the effect creation is successful
  50210. * @param onError defines a function to call when the effect creation has failed
  50211. * @returns the new Effect
  50212. */
  50213. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50214. }
  50215. }
  50216. module "babylonjs/Meshes/mesh" {
  50217. interface Mesh {
  50218. /**
  50219. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50220. * @returns an array of IParticleSystem
  50221. */
  50222. getEmittedParticleSystems(): IParticleSystem[];
  50223. /**
  50224. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50225. * @returns an array of IParticleSystem
  50226. */
  50227. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50228. }
  50229. }
  50230. /**
  50231. * @hidden
  50232. */
  50233. export var _IDoNeedToBeInTheBuild: number;
  50234. }
  50235. declare module "babylonjs/Particles/index" {
  50236. export * from "babylonjs/Particles/baseParticleSystem";
  50237. export * from "babylonjs/Particles/EmitterTypes/index";
  50238. export * from "babylonjs/Particles/gpuParticleSystem";
  50239. export * from "babylonjs/Particles/IParticleSystem";
  50240. export * from "babylonjs/Particles/particle";
  50241. export * from "babylonjs/Particles/particleHelper";
  50242. export * from "babylonjs/Particles/particleSystem";
  50243. export * from "babylonjs/Particles/particleSystemComponent";
  50244. export * from "babylonjs/Particles/particleSystemSet";
  50245. export * from "babylonjs/Particles/solidParticle";
  50246. export * from "babylonjs/Particles/solidParticleSystem";
  50247. export * from "babylonjs/Particles/subEmitter";
  50248. }
  50249. declare module "babylonjs/Physics/physicsEngineComponent" {
  50250. import { Nullable } from "babylonjs/types";
  50251. import { Observable, Observer } from "babylonjs/Misc/observable";
  50252. import { Vector3 } from "babylonjs/Maths/math";
  50253. import { Mesh } from "babylonjs/Meshes/mesh";
  50254. import { ISceneComponent } from "babylonjs/sceneComponent";
  50255. import { Scene } from "babylonjs/scene";
  50256. import { Node } from "babylonjs/node";
  50257. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50258. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50259. module "babylonjs/scene" {
  50260. interface Scene {
  50261. /** @hidden (Backing field) */
  50262. _physicsEngine: Nullable<IPhysicsEngine>;
  50263. /**
  50264. * Gets the current physics engine
  50265. * @returns a IPhysicsEngine or null if none attached
  50266. */
  50267. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50268. /**
  50269. * Enables physics to the current scene
  50270. * @param gravity defines the scene's gravity for the physics engine
  50271. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50272. * @return a boolean indicating if the physics engine was initialized
  50273. */
  50274. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50275. /**
  50276. * Disables and disposes the physics engine associated with the scene
  50277. */
  50278. disablePhysicsEngine(): void;
  50279. /**
  50280. * Gets a boolean indicating if there is an active physics engine
  50281. * @returns a boolean indicating if there is an active physics engine
  50282. */
  50283. isPhysicsEnabled(): boolean;
  50284. /**
  50285. * Deletes a physics compound impostor
  50286. * @param compound defines the compound to delete
  50287. */
  50288. deleteCompoundImpostor(compound: any): void;
  50289. /**
  50290. * An event triggered when physic simulation is about to be run
  50291. */
  50292. onBeforePhysicsObservable: Observable<Scene>;
  50293. /**
  50294. * An event triggered when physic simulation has been done
  50295. */
  50296. onAfterPhysicsObservable: Observable<Scene>;
  50297. }
  50298. }
  50299. module "babylonjs/Meshes/abstractMesh" {
  50300. interface AbstractMesh {
  50301. /** @hidden */
  50302. _physicsImpostor: Nullable<PhysicsImpostor>;
  50303. /**
  50304. * Gets or sets impostor used for physic simulation
  50305. * @see http://doc.babylonjs.com/features/physics_engine
  50306. */
  50307. physicsImpostor: Nullable<PhysicsImpostor>;
  50308. /**
  50309. * Gets the current physics impostor
  50310. * @see http://doc.babylonjs.com/features/physics_engine
  50311. * @returns a physics impostor or null
  50312. */
  50313. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50314. /** Apply a physic impulse to the mesh
  50315. * @param force defines the force to apply
  50316. * @param contactPoint defines where to apply the force
  50317. * @returns the current mesh
  50318. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50319. */
  50320. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50321. /**
  50322. * Creates a physic joint between two meshes
  50323. * @param otherMesh defines the other mesh to use
  50324. * @param pivot1 defines the pivot to use on this mesh
  50325. * @param pivot2 defines the pivot to use on the other mesh
  50326. * @param options defines additional options (can be plugin dependent)
  50327. * @returns the current mesh
  50328. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50329. */
  50330. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50331. /** @hidden */
  50332. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50333. }
  50334. }
  50335. /**
  50336. * Defines the physics engine scene component responsible to manage a physics engine
  50337. */
  50338. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50339. /**
  50340. * The component name helpful to identify the component in the list of scene components.
  50341. */
  50342. readonly name: string;
  50343. /**
  50344. * The scene the component belongs to.
  50345. */
  50346. scene: Scene;
  50347. /**
  50348. * Creates a new instance of the component for the given scene
  50349. * @param scene Defines the scene to register the component in
  50350. */
  50351. constructor(scene: Scene);
  50352. /**
  50353. * Registers the component in a given scene
  50354. */
  50355. register(): void;
  50356. /**
  50357. * Rebuilds the elements related to this component in case of
  50358. * context lost for instance.
  50359. */
  50360. rebuild(): void;
  50361. /**
  50362. * Disposes the component and the associated ressources
  50363. */
  50364. dispose(): void;
  50365. }
  50366. }
  50367. declare module "babylonjs/Physics/physicsHelper" {
  50368. import { Nullable } from "babylonjs/types";
  50369. import { Vector3 } from "babylonjs/Maths/math";
  50370. import { Mesh } from "babylonjs/Meshes/mesh";
  50371. import { Ray } from "babylonjs/Culling/ray";
  50372. import { Scene } from "babylonjs/scene";
  50373. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50374. /**
  50375. * A helper for physics simulations
  50376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50377. */
  50378. export class PhysicsHelper {
  50379. private _scene;
  50380. private _physicsEngine;
  50381. /**
  50382. * Initializes the Physics helper
  50383. * @param scene Babylon.js scene
  50384. */
  50385. constructor(scene: Scene);
  50386. /**
  50387. * Applies a radial explosion impulse
  50388. * @param origin the origin of the explosion
  50389. * @param radius the explosion radius
  50390. * @param strength the explosion strength
  50391. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50392. * @returns A physics radial explosion event, or null
  50393. */
  50394. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50395. /**
  50396. * Applies a radial explosion force
  50397. * @param origin the origin of the explosion
  50398. * @param radius the explosion radius
  50399. * @param strength the explosion strength
  50400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50401. * @returns A physics radial explosion event, or null
  50402. */
  50403. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50404. /**
  50405. * Creates a gravitational field
  50406. * @param origin the origin of the explosion
  50407. * @param radius the explosion radius
  50408. * @param strength the explosion strength
  50409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50410. * @returns A physics gravitational field event, or null
  50411. */
  50412. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50413. /**
  50414. * Creates a physics updraft event
  50415. * @param origin the origin of the updraft
  50416. * @param radius the radius of the updraft
  50417. * @param strength the strength of the updraft
  50418. * @param height the height of the updraft
  50419. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50420. * @returns A physics updraft event, or null
  50421. */
  50422. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50423. /**
  50424. * Creates a physics vortex event
  50425. * @param origin the of the vortex
  50426. * @param radius the radius of the vortex
  50427. * @param strength the strength of the vortex
  50428. * @param height the height of the vortex
  50429. * @returns a Physics vortex event, or null
  50430. * A physics vortex event or null
  50431. */
  50432. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50433. }
  50434. /**
  50435. * Represents a physics radial explosion event
  50436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50437. */
  50438. export class PhysicsRadialExplosionEvent {
  50439. private _scene;
  50440. private _sphere;
  50441. private _sphereOptions;
  50442. private _rays;
  50443. private _dataFetched;
  50444. /**
  50445. * Initializes a radial explosioin event
  50446. * @param scene BabylonJS scene
  50447. */
  50448. constructor(scene: Scene);
  50449. /**
  50450. * Returns the data related to the radial explosion event (sphere & rays).
  50451. * @returns The radial explosion event data
  50452. */
  50453. getData(): PhysicsRadialExplosionEventData;
  50454. /**
  50455. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50456. * @param impostor A physics imposter
  50457. * @param origin the origin of the explosion
  50458. * @param radius the explosion radius
  50459. * @param strength the explosion strength
  50460. * @param falloff possible options: Constant & Linear
  50461. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50462. */
  50463. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50464. /**
  50465. * Disposes the sphere.
  50466. * @param force Specifies if the sphere should be disposed by force
  50467. */
  50468. dispose(force?: boolean): void;
  50469. /*** Helpers ***/
  50470. private _prepareSphere;
  50471. private _intersectsWithSphere;
  50472. }
  50473. /**
  50474. * Represents a gravitational field event
  50475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50476. */
  50477. export class PhysicsGravitationalFieldEvent {
  50478. private _physicsHelper;
  50479. private _scene;
  50480. private _origin;
  50481. private _radius;
  50482. private _strength;
  50483. private _falloff;
  50484. private _tickCallback;
  50485. private _sphere;
  50486. private _dataFetched;
  50487. /**
  50488. * Initializes the physics gravitational field event
  50489. * @param physicsHelper A physics helper
  50490. * @param scene BabylonJS scene
  50491. * @param origin The origin position of the gravitational field event
  50492. * @param radius The radius of the gravitational field event
  50493. * @param strength The strength of the gravitational field event
  50494. * @param falloff The falloff for the gravitational field event
  50495. */
  50496. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50497. /**
  50498. * Returns the data related to the gravitational field event (sphere).
  50499. * @returns A gravitational field event
  50500. */
  50501. getData(): PhysicsGravitationalFieldEventData;
  50502. /**
  50503. * Enables the gravitational field.
  50504. */
  50505. enable(): void;
  50506. /**
  50507. * Disables the gravitational field.
  50508. */
  50509. disable(): void;
  50510. /**
  50511. * Disposes the sphere.
  50512. * @param force The force to dispose from the gravitational field event
  50513. */
  50514. dispose(force?: boolean): void;
  50515. private _tick;
  50516. }
  50517. /**
  50518. * Represents a physics updraft event
  50519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50520. */
  50521. export class PhysicsUpdraftEvent {
  50522. private _scene;
  50523. private _origin;
  50524. private _radius;
  50525. private _strength;
  50526. private _height;
  50527. private _updraftMode;
  50528. private _physicsEngine;
  50529. private _originTop;
  50530. private _originDirection;
  50531. private _tickCallback;
  50532. private _cylinder;
  50533. private _cylinderPosition;
  50534. private _dataFetched;
  50535. /**
  50536. * Initializes the physics updraft event
  50537. * @param _scene BabylonJS scene
  50538. * @param _origin The origin position of the updraft
  50539. * @param _radius The radius of the updraft
  50540. * @param _strength The strength of the updraft
  50541. * @param _height The height of the updraft
  50542. * @param _updraftMode The mode of the updraft
  50543. */
  50544. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50545. /**
  50546. * Returns the data related to the updraft event (cylinder).
  50547. * @returns A physics updraft event
  50548. */
  50549. getData(): PhysicsUpdraftEventData;
  50550. /**
  50551. * Enables the updraft.
  50552. */
  50553. enable(): void;
  50554. /**
  50555. * Disables the cortex.
  50556. */
  50557. disable(): void;
  50558. /**
  50559. * Disposes the sphere.
  50560. * @param force Specifies if the updraft should be disposed by force
  50561. */
  50562. dispose(force?: boolean): void;
  50563. private getImpostorForceAndContactPoint;
  50564. private _tick;
  50565. /*** Helpers ***/
  50566. private _prepareCylinder;
  50567. private _intersectsWithCylinder;
  50568. }
  50569. /**
  50570. * Represents a physics vortex event
  50571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50572. */
  50573. export class PhysicsVortexEvent {
  50574. private _scene;
  50575. private _origin;
  50576. private _radius;
  50577. private _strength;
  50578. private _height;
  50579. private _physicsEngine;
  50580. private _originTop;
  50581. private _centripetalForceThreshold;
  50582. private _updraftMultiplier;
  50583. private _tickCallback;
  50584. private _cylinder;
  50585. private _cylinderPosition;
  50586. private _dataFetched;
  50587. /**
  50588. * Initializes the physics vortex event
  50589. * @param _scene The BabylonJS scene
  50590. * @param _origin The origin position of the vortex
  50591. * @param _radius The radius of the vortex
  50592. * @param _strength The strength of the vortex
  50593. * @param _height The height of the vortex
  50594. */
  50595. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  50596. /**
  50597. * Returns the data related to the vortex event (cylinder).
  50598. * @returns The physics vortex event data
  50599. */
  50600. getData(): PhysicsVortexEventData;
  50601. /**
  50602. * Enables the vortex.
  50603. */
  50604. enable(): void;
  50605. /**
  50606. * Disables the cortex.
  50607. */
  50608. disable(): void;
  50609. /**
  50610. * Disposes the sphere.
  50611. * @param force
  50612. */
  50613. dispose(force?: boolean): void;
  50614. private getImpostorForceAndContactPoint;
  50615. private _tick;
  50616. /*** Helpers ***/
  50617. private _prepareCylinder;
  50618. private _intersectsWithCylinder;
  50619. }
  50620. /**
  50621. * The strenght of the force in correspondence to the distance of the affected object
  50622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50623. */
  50624. export enum PhysicsRadialImpulseFalloff {
  50625. /** Defines that impulse is constant in strength across it's whole radius */
  50626. Constant = 0,
  50627. /** DEfines that impulse gets weaker if it's further from the origin */
  50628. Linear = 1
  50629. }
  50630. /**
  50631. * The strength of the force in correspondence to the distance of the affected object
  50632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50633. */
  50634. export enum PhysicsUpdraftMode {
  50635. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50636. Center = 0,
  50637. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50638. Perpendicular = 1
  50639. }
  50640. /**
  50641. * Interface for a physics force and contact point
  50642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50643. */
  50644. export interface PhysicsForceAndContactPoint {
  50645. /**
  50646. * The force applied at the contact point
  50647. */
  50648. force: Vector3;
  50649. /**
  50650. * The contact point
  50651. */
  50652. contactPoint: Vector3;
  50653. }
  50654. /**
  50655. * Interface for radial explosion event data
  50656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50657. */
  50658. export interface PhysicsRadialExplosionEventData {
  50659. /**
  50660. * A sphere used for the radial explosion event
  50661. */
  50662. sphere: Mesh;
  50663. /**
  50664. * An array of rays for the radial explosion event
  50665. */
  50666. rays: Array<Ray>;
  50667. }
  50668. /**
  50669. * Interface for gravitational field event data
  50670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50671. */
  50672. export interface PhysicsGravitationalFieldEventData {
  50673. /**
  50674. * A sphere mesh used for the gravitational field event
  50675. */
  50676. sphere: Mesh;
  50677. }
  50678. /**
  50679. * Interface for updraft event data
  50680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50681. */
  50682. export interface PhysicsUpdraftEventData {
  50683. /**
  50684. * A cylinder used for the updraft event
  50685. */
  50686. cylinder: Mesh;
  50687. }
  50688. /**
  50689. * Interface for vortex event data
  50690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50691. */
  50692. export interface PhysicsVortexEventData {
  50693. /**
  50694. * A cylinder used for the vortex event
  50695. */
  50696. cylinder: Mesh;
  50697. }
  50698. }
  50699. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50700. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50701. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50702. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50703. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50704. import { Nullable } from "babylonjs/types";
  50705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50706. /**
  50707. * AmmoJS Physics plugin
  50708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50709. * @see https://github.com/kripken/ammo.js/
  50710. */
  50711. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50712. private _useDeltaForWorldStep;
  50713. /**
  50714. * Reference to the Ammo library
  50715. */
  50716. bjsAMMO: any;
  50717. /**
  50718. * Created ammoJS world which physics bodies are added to
  50719. */
  50720. world: any;
  50721. /**
  50722. * Name of the plugin
  50723. */
  50724. name: string;
  50725. private _timeStep;
  50726. private _fixedTimeStep;
  50727. private _maxSteps;
  50728. private _tmpQuaternion;
  50729. private _tmpAmmoTransform;
  50730. private _tmpAmmoQuaternion;
  50731. private _tmpAmmoConcreteContactResultCallback;
  50732. private _collisionConfiguration;
  50733. private _dispatcher;
  50734. private _overlappingPairCache;
  50735. private _solver;
  50736. private _tmpAmmoVectorA;
  50737. private _tmpAmmoVectorB;
  50738. private _tmpAmmoVectorC;
  50739. private _tmpContactCallbackResult;
  50740. private static readonly DISABLE_COLLISION_FLAG;
  50741. private static readonly KINEMATIC_FLAG;
  50742. private static readonly DISABLE_DEACTIVATION_FLAG;
  50743. /**
  50744. * Initializes the ammoJS plugin
  50745. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50746. * @param ammoInjection can be used to inject your own ammo reference
  50747. */
  50748. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50749. /**
  50750. * Sets the gravity of the physics world (m/(s^2))
  50751. * @param gravity Gravity to set
  50752. */
  50753. setGravity(gravity: Vector3): void;
  50754. /**
  50755. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50756. * @param timeStep timestep to use in seconds
  50757. */
  50758. setTimeStep(timeStep: number): void;
  50759. /**
  50760. * 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)
  50761. * @param fixedTimeStep fixedTimeStep to use in seconds
  50762. */
  50763. setFixedTimeStep(fixedTimeStep: number): void;
  50764. /**
  50765. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50766. * @param maxSteps the maximum number of steps by the physics engine per frame
  50767. */
  50768. setMaxSteps(maxSteps: number): void;
  50769. /**
  50770. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50771. * @returns the current timestep in seconds
  50772. */
  50773. getTimeStep(): number;
  50774. private _isImpostorInContact;
  50775. private _isImpostorPairInContact;
  50776. private _stepSimulation;
  50777. /**
  50778. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50779. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50780. * After the step the babylon meshes are set to the position of the physics imposters
  50781. * @param delta amount of time to step forward
  50782. * @param impostors array of imposters to update before/after the step
  50783. */
  50784. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50785. private _tmpVector;
  50786. private _tmpMatrix;
  50787. /**
  50788. * Applies an implulse on the imposter
  50789. * @param impostor imposter to apply impulse
  50790. * @param force amount of force to be applied to the imposter
  50791. * @param contactPoint the location to apply the impulse on the imposter
  50792. */
  50793. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50794. /**
  50795. * Applies a force on the imposter
  50796. * @param impostor imposter to apply force
  50797. * @param force amount of force to be applied to the imposter
  50798. * @param contactPoint the location to apply the force on the imposter
  50799. */
  50800. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50801. /**
  50802. * Creates a physics body using the plugin
  50803. * @param impostor the imposter to create the physics body on
  50804. */
  50805. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50806. /**
  50807. * Removes the physics body from the imposter and disposes of the body's memory
  50808. * @param impostor imposter to remove the physics body from
  50809. */
  50810. removePhysicsBody(impostor: PhysicsImpostor): void;
  50811. /**
  50812. * Generates a joint
  50813. * @param impostorJoint the imposter joint to create the joint with
  50814. */
  50815. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50816. /**
  50817. * Removes a joint
  50818. * @param impostorJoint the imposter joint to remove the joint from
  50819. */
  50820. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50821. private _addMeshVerts;
  50822. private _createShape;
  50823. /**
  50824. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50825. * @param impostor imposter containing the physics body and babylon object
  50826. */
  50827. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50828. /**
  50829. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50830. * @param impostor imposter containing the physics body and babylon object
  50831. * @param newPosition new position
  50832. * @param newRotation new rotation
  50833. */
  50834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50835. /**
  50836. * If this plugin is supported
  50837. * @returns true if its supported
  50838. */
  50839. isSupported(): boolean;
  50840. /**
  50841. * Sets the linear velocity of the physics body
  50842. * @param impostor imposter to set the velocity on
  50843. * @param velocity velocity to set
  50844. */
  50845. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50846. /**
  50847. * Sets the angular velocity of the physics body
  50848. * @param impostor imposter to set the velocity on
  50849. * @param velocity velocity to set
  50850. */
  50851. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50852. /**
  50853. * gets the linear velocity
  50854. * @param impostor imposter to get linear velocity from
  50855. * @returns linear velocity
  50856. */
  50857. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50858. /**
  50859. * gets the angular velocity
  50860. * @param impostor imposter to get angular velocity from
  50861. * @returns angular velocity
  50862. */
  50863. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50864. /**
  50865. * Sets the mass of physics body
  50866. * @param impostor imposter to set the mass on
  50867. * @param mass mass to set
  50868. */
  50869. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50870. /**
  50871. * Gets the mass of the physics body
  50872. * @param impostor imposter to get the mass from
  50873. * @returns mass
  50874. */
  50875. getBodyMass(impostor: PhysicsImpostor): number;
  50876. /**
  50877. * Gets friction of the impostor
  50878. * @param impostor impostor to get friction from
  50879. * @returns friction value
  50880. */
  50881. getBodyFriction(impostor: PhysicsImpostor): number;
  50882. /**
  50883. * Sets friction of the impostor
  50884. * @param impostor impostor to set friction on
  50885. * @param friction friction value
  50886. */
  50887. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50888. /**
  50889. * Gets restitution of the impostor
  50890. * @param impostor impostor to get restitution from
  50891. * @returns restitution value
  50892. */
  50893. getBodyRestitution(impostor: PhysicsImpostor): number;
  50894. /**
  50895. * Sets resitution of the impostor
  50896. * @param impostor impostor to set resitution on
  50897. * @param restitution resitution value
  50898. */
  50899. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50900. /**
  50901. * Sleeps the physics body and stops it from being active
  50902. * @param impostor impostor to sleep
  50903. */
  50904. sleepBody(impostor: PhysicsImpostor): void;
  50905. /**
  50906. * Activates the physics body
  50907. * @param impostor impostor to activate
  50908. */
  50909. wakeUpBody(impostor: PhysicsImpostor): void;
  50910. /**
  50911. * Updates the distance parameters of the joint
  50912. * @param joint joint to update
  50913. * @param maxDistance maximum distance of the joint
  50914. * @param minDistance minimum distance of the joint
  50915. */
  50916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50917. /**
  50918. * Sets a motor on the joint
  50919. * @param joint joint to set motor on
  50920. * @param speed speed of the motor
  50921. * @param maxForce maximum force of the motor
  50922. * @param motorIndex index of the motor
  50923. */
  50924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50925. /**
  50926. * Sets the motors limit
  50927. * @param joint joint to set limit on
  50928. * @param upperLimit upper limit
  50929. * @param lowerLimit lower limit
  50930. */
  50931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50932. /**
  50933. * Syncs the position and rotation of a mesh with the impostor
  50934. * @param mesh mesh to sync
  50935. * @param impostor impostor to update the mesh with
  50936. */
  50937. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50938. /**
  50939. * Gets the radius of the impostor
  50940. * @param impostor impostor to get radius from
  50941. * @returns the radius
  50942. */
  50943. getRadius(impostor: PhysicsImpostor): number;
  50944. /**
  50945. * Gets the box size of the impostor
  50946. * @param impostor impostor to get box size from
  50947. * @param result the resulting box size
  50948. */
  50949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50950. /**
  50951. * Disposes of the impostor
  50952. */
  50953. dispose(): void;
  50954. }
  50955. }
  50956. declare module "babylonjs/Physics/Plugins/index" {
  50957. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  50958. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  50959. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  50960. }
  50961. declare module "babylonjs/Physics/index" {
  50962. export * from "babylonjs/Physics/IPhysicsEngine";
  50963. export * from "babylonjs/Physics/physicsEngine";
  50964. export * from "babylonjs/Physics/physicsEngineComponent";
  50965. export * from "babylonjs/Physics/physicsHelper";
  50966. export * from "babylonjs/Physics/physicsImpostor";
  50967. export * from "babylonjs/Physics/physicsJoint";
  50968. export * from "babylonjs/Physics/Plugins/index";
  50969. }
  50970. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  50971. /** @hidden */
  50972. export var blackAndWhitePixelShader: {
  50973. name: string;
  50974. shader: string;
  50975. };
  50976. }
  50977. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  50978. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50979. import { Camera } from "babylonjs/Cameras/camera";
  50980. import { Engine } from "babylonjs/Engines/engine";
  50981. import "babylonjs/Shaders/blackAndWhite.fragment";
  50982. /**
  50983. * Post process used to render in black and white
  50984. */
  50985. export class BlackAndWhitePostProcess extends PostProcess {
  50986. /**
  50987. * Linear about to convert he result to black and white (default: 1)
  50988. */
  50989. degree: number;
  50990. /**
  50991. * Creates a black and white post process
  50992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  50993. * @param name The name of the effect.
  50994. * @param options The required width/height ratio to downsize to before computing the render pass.
  50995. * @param camera The camera to apply the render pass to.
  50996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50997. * @param engine The engine which the post process will be applied. (default: current engine)
  50998. * @param reusable If the post process can be reused on the same frame. (default: false)
  50999. */
  51000. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51001. }
  51002. }
  51003. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51004. import { Nullable } from "babylonjs/types";
  51005. import { Camera } from "babylonjs/Cameras/camera";
  51006. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51007. import { Engine } from "babylonjs/Engines/engine";
  51008. /**
  51009. * This represents a set of one or more post processes in Babylon.
  51010. * A post process can be used to apply a shader to a texture after it is rendered.
  51011. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51012. */
  51013. export class PostProcessRenderEffect {
  51014. private _postProcesses;
  51015. private _getPostProcesses;
  51016. private _singleInstance;
  51017. private _cameras;
  51018. private _indicesForCamera;
  51019. /**
  51020. * Name of the effect
  51021. * @hidden
  51022. */
  51023. _name: string;
  51024. /**
  51025. * Instantiates a post process render effect.
  51026. * A post process can be used to apply a shader to a texture after it is rendered.
  51027. * @param engine The engine the effect is tied to
  51028. * @param name The name of the effect
  51029. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51030. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51031. */
  51032. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51033. /**
  51034. * Checks if all the post processes in the effect are supported.
  51035. */
  51036. readonly isSupported: boolean;
  51037. /**
  51038. * Updates the current state of the effect
  51039. * @hidden
  51040. */
  51041. _update(): void;
  51042. /**
  51043. * Attaches the effect on cameras
  51044. * @param cameras The camera to attach to.
  51045. * @hidden
  51046. */
  51047. _attachCameras(cameras: Camera): void;
  51048. /**
  51049. * Attaches the effect on cameras
  51050. * @param cameras The camera to attach to.
  51051. * @hidden
  51052. */
  51053. _attachCameras(cameras: Camera[]): void;
  51054. /**
  51055. * Detatches the effect on cameras
  51056. * @param cameras The camera to detatch from.
  51057. * @hidden
  51058. */
  51059. _detachCameras(cameras: Camera): void;
  51060. /**
  51061. * Detatches the effect on cameras
  51062. * @param cameras The camera to detatch from.
  51063. * @hidden
  51064. */
  51065. _detachCameras(cameras: Camera[]): void;
  51066. /**
  51067. * Enables the effect on given cameras
  51068. * @param cameras The camera to enable.
  51069. * @hidden
  51070. */
  51071. _enable(cameras: Camera): void;
  51072. /**
  51073. * Enables the effect on given cameras
  51074. * @param cameras The camera to enable.
  51075. * @hidden
  51076. */
  51077. _enable(cameras: Nullable<Camera[]>): void;
  51078. /**
  51079. * Disables the effect on the given cameras
  51080. * @param cameras The camera to disable.
  51081. * @hidden
  51082. */
  51083. _disable(cameras: Camera): void;
  51084. /**
  51085. * Disables the effect on the given cameras
  51086. * @param cameras The camera to disable.
  51087. * @hidden
  51088. */
  51089. _disable(cameras: Nullable<Camera[]>): void;
  51090. /**
  51091. * Gets a list of the post processes contained in the effect.
  51092. * @param camera The camera to get the post processes on.
  51093. * @returns The list of the post processes in the effect.
  51094. */
  51095. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51096. }
  51097. }
  51098. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51099. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51100. /** @hidden */
  51101. export var extractHighlightsPixelShader: {
  51102. name: string;
  51103. shader: string;
  51104. };
  51105. }
  51106. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51107. import { Nullable } from "babylonjs/types";
  51108. import { Camera } from "babylonjs/Cameras/camera";
  51109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51110. import { Engine } from "babylonjs/Engines/engine";
  51111. import "babylonjs/Shaders/extractHighlights.fragment";
  51112. /**
  51113. * 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.
  51114. */
  51115. export class ExtractHighlightsPostProcess extends PostProcess {
  51116. /**
  51117. * The luminance threshold, pixels below this value will be set to black.
  51118. */
  51119. threshold: number;
  51120. /** @hidden */
  51121. _exposure: number;
  51122. /**
  51123. * Post process which has the input texture to be used when performing highlight extraction
  51124. * @hidden
  51125. */
  51126. _inputPostProcess: Nullable<PostProcess>;
  51127. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51128. }
  51129. }
  51130. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51131. /** @hidden */
  51132. export var bloomMergePixelShader: {
  51133. name: string;
  51134. shader: string;
  51135. };
  51136. }
  51137. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51138. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51139. import { Nullable } from "babylonjs/types";
  51140. import { Engine } from "babylonjs/Engines/engine";
  51141. import { Camera } from "babylonjs/Cameras/camera";
  51142. import "babylonjs/Shaders/bloomMerge.fragment";
  51143. /**
  51144. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51145. */
  51146. export class BloomMergePostProcess extends PostProcess {
  51147. /** Weight of the bloom to be added to the original input. */
  51148. weight: number;
  51149. /**
  51150. * Creates a new instance of @see BloomMergePostProcess
  51151. * @param name The name of the effect.
  51152. * @param originalFromInput Post process which's input will be used for the merge.
  51153. * @param blurred Blurred highlights post process which's output will be used.
  51154. * @param weight Weight of the bloom to be added to the original input.
  51155. * @param options The required width/height ratio to downsize to before computing the render pass.
  51156. * @param camera The camera to apply the render pass to.
  51157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51158. * @param engine The engine which the post process will be applied. (default: current engine)
  51159. * @param reusable If the post process can be reused on the same frame. (default: false)
  51160. * @param textureType Type of textures used when performing the post process. (default: 0)
  51161. * @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)
  51162. */
  51163. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51164. /** Weight of the bloom to be added to the original input. */
  51165. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51166. }
  51167. }
  51168. declare module "babylonjs/PostProcesses/bloomEffect" {
  51169. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51170. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51171. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51172. import { Camera } from "babylonjs/Cameras/camera";
  51173. import { Scene } from "babylonjs/scene";
  51174. /**
  51175. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51176. */
  51177. export class BloomEffect extends PostProcessRenderEffect {
  51178. private bloomScale;
  51179. /**
  51180. * @hidden Internal
  51181. */
  51182. _effects: Array<PostProcess>;
  51183. /**
  51184. * @hidden Internal
  51185. */
  51186. _downscale: ExtractHighlightsPostProcess;
  51187. private _blurX;
  51188. private _blurY;
  51189. private _merge;
  51190. /**
  51191. * The luminance threshold to find bright areas of the image to bloom.
  51192. */
  51193. threshold: number;
  51194. /**
  51195. * The strength of the bloom.
  51196. */
  51197. weight: number;
  51198. /**
  51199. * Specifies the size of the bloom blur kernel, relative to the final output size
  51200. */
  51201. kernel: number;
  51202. /**
  51203. * Creates a new instance of @see BloomEffect
  51204. * @param scene The scene the effect belongs to.
  51205. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51206. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51207. * @param bloomWeight The the strength of bloom.
  51208. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51209. * @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)
  51210. */
  51211. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51212. /**
  51213. * Disposes each of the internal effects for a given camera.
  51214. * @param camera The camera to dispose the effect on.
  51215. */
  51216. disposeEffects(camera: Camera): void;
  51217. /**
  51218. * @hidden Internal
  51219. */
  51220. _updateEffects(): void;
  51221. /**
  51222. * Internal
  51223. * @returns if all the contained post processes are ready.
  51224. * @hidden
  51225. */
  51226. _isReady(): boolean;
  51227. }
  51228. }
  51229. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51230. /** @hidden */
  51231. export var chromaticAberrationPixelShader: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51237. import { Vector2 } from "babylonjs/Maths/math";
  51238. import { Nullable } from "babylonjs/types";
  51239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Engine } from "babylonjs/Engines/engine";
  51242. import "babylonjs/Shaders/chromaticAberration.fragment";
  51243. /**
  51244. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51245. */
  51246. export class ChromaticAberrationPostProcess extends PostProcess {
  51247. /**
  51248. * The amount of seperation of rgb channels (default: 30)
  51249. */
  51250. aberrationAmount: number;
  51251. /**
  51252. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51253. */
  51254. radialIntensity: number;
  51255. /**
  51256. * 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))
  51257. */
  51258. direction: Vector2;
  51259. /**
  51260. * 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))
  51261. */
  51262. centerPosition: Vector2;
  51263. /**
  51264. * Creates a new instance ChromaticAberrationPostProcess
  51265. * @param name The name of the effect.
  51266. * @param screenWidth The width of the screen to apply the effect on.
  51267. * @param screenHeight The height of the screen to apply the effect on.
  51268. * @param options The required width/height ratio to downsize to before computing the render pass.
  51269. * @param camera The camera to apply the render pass to.
  51270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51271. * @param engine The engine which the post process will be applied. (default: current engine)
  51272. * @param reusable If the post process can be reused on the same frame. (default: false)
  51273. * @param textureType Type of textures used when performing the post process. (default: 0)
  51274. * @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)
  51275. */
  51276. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51277. }
  51278. }
  51279. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51280. /** @hidden */
  51281. export var circleOfConfusionPixelShader: {
  51282. name: string;
  51283. shader: string;
  51284. };
  51285. }
  51286. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51287. import { Nullable } from "babylonjs/types";
  51288. import { Engine } from "babylonjs/Engines/engine";
  51289. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51291. import { Camera } from "babylonjs/Cameras/camera";
  51292. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51293. /**
  51294. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51295. */
  51296. export class CircleOfConfusionPostProcess extends PostProcess {
  51297. /**
  51298. * 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.
  51299. */
  51300. lensSize: number;
  51301. /**
  51302. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51303. */
  51304. fStop: number;
  51305. /**
  51306. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51307. */
  51308. focusDistance: number;
  51309. /**
  51310. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51311. */
  51312. focalLength: number;
  51313. private _depthTexture;
  51314. /**
  51315. * Creates a new instance CircleOfConfusionPostProcess
  51316. * @param name The name of the effect.
  51317. * @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.
  51318. * @param options The required width/height ratio to downsize to before computing the render pass.
  51319. * @param camera The camera to apply the render pass to.
  51320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51321. * @param engine The engine which the post process will be applied. (default: current engine)
  51322. * @param reusable If the post process can be reused on the same frame. (default: false)
  51323. * @param textureType Type of textures used when performing the post process. (default: 0)
  51324. * @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)
  51325. */
  51326. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51327. /**
  51328. * 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.
  51329. */
  51330. depthTexture: RenderTargetTexture;
  51331. }
  51332. }
  51333. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51334. /** @hidden */
  51335. export var colorCorrectionPixelShader: {
  51336. name: string;
  51337. shader: string;
  51338. };
  51339. }
  51340. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51342. import { Engine } from "babylonjs/Engines/engine";
  51343. import { Camera } from "babylonjs/Cameras/camera";
  51344. import "babylonjs/Shaders/colorCorrection.fragment";
  51345. /**
  51346. *
  51347. * This post-process allows the modification of rendered colors by using
  51348. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51349. *
  51350. * The object needs to be provided an url to a texture containing the color
  51351. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51352. * Use an image editing software to tweak the LUT to match your needs.
  51353. *
  51354. * For an example of a color LUT, see here:
  51355. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51356. * For explanations on color grading, see here:
  51357. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51358. *
  51359. */
  51360. export class ColorCorrectionPostProcess extends PostProcess {
  51361. private _colorTableTexture;
  51362. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51363. }
  51364. }
  51365. declare module "babylonjs/Shaders/convolution.fragment" {
  51366. /** @hidden */
  51367. export var convolutionPixelShader: {
  51368. name: string;
  51369. shader: string;
  51370. };
  51371. }
  51372. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51374. import { Nullable } from "babylonjs/types";
  51375. import { Camera } from "babylonjs/Cameras/camera";
  51376. import { Engine } from "babylonjs/Engines/engine";
  51377. import "babylonjs/Shaders/convolution.fragment";
  51378. /**
  51379. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51380. * input texture to perform effects such as edge detection or sharpening
  51381. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51382. */
  51383. export class ConvolutionPostProcess extends PostProcess {
  51384. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51385. kernel: number[];
  51386. /**
  51387. * Creates a new instance ConvolutionPostProcess
  51388. * @param name The name of the effect.
  51389. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51390. * @param options The required width/height ratio to downsize to before computing the render pass.
  51391. * @param camera The camera to apply the render pass to.
  51392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51393. * @param engine The engine which the post process will be applied. (default: current engine)
  51394. * @param reusable If the post process can be reused on the same frame. (default: false)
  51395. * @param textureType Type of textures used when performing the post process. (default: 0)
  51396. */
  51397. constructor(name: string,
  51398. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51399. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51400. /**
  51401. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51402. */
  51403. static EdgeDetect0Kernel: number[];
  51404. /**
  51405. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51406. */
  51407. static EdgeDetect1Kernel: number[];
  51408. /**
  51409. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51410. */
  51411. static EdgeDetect2Kernel: number[];
  51412. /**
  51413. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51414. */
  51415. static SharpenKernel: number[];
  51416. /**
  51417. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51418. */
  51419. static EmbossKernel: number[];
  51420. /**
  51421. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51422. */
  51423. static GaussianKernel: number[];
  51424. }
  51425. }
  51426. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51427. import { Nullable } from "babylonjs/types";
  51428. import { Vector2 } from "babylonjs/Maths/math";
  51429. import { Camera } from "babylonjs/Cameras/camera";
  51430. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51431. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51432. import { Engine } from "babylonjs/Engines/engine";
  51433. import { Scene } from "babylonjs/scene";
  51434. /**
  51435. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51436. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51437. * based on samples that have a large difference in distance than the center pixel.
  51438. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51439. */
  51440. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51441. direction: Vector2;
  51442. /**
  51443. * Creates a new instance CircleOfConfusionPostProcess
  51444. * @param name The name of the effect.
  51445. * @param scene The scene the effect belongs to.
  51446. * @param direction The direction the blur should be applied.
  51447. * @param kernel The size of the kernel used to blur.
  51448. * @param options The required width/height ratio to downsize to before computing the render pass.
  51449. * @param camera The camera to apply the render pass to.
  51450. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51451. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51453. * @param engine The engine which the post process will be applied. (default: current engine)
  51454. * @param reusable If the post process can be reused on the same frame. (default: false)
  51455. * @param textureType Type of textures used when performing the post process. (default: 0)
  51456. * @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)
  51457. */
  51458. 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);
  51459. }
  51460. }
  51461. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51462. /** @hidden */
  51463. export var depthOfFieldMergePixelShader: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51469. import { Nullable } from "babylonjs/types";
  51470. import { Camera } from "babylonjs/Cameras/camera";
  51471. import { Effect } from "babylonjs/Materials/effect";
  51472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51473. import { Engine } from "babylonjs/Engines/engine";
  51474. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51475. /**
  51476. * Options to be set when merging outputs from the default pipeline.
  51477. */
  51478. export class DepthOfFieldMergePostProcessOptions {
  51479. /**
  51480. * The original image to merge on top of
  51481. */
  51482. originalFromInput: PostProcess;
  51483. /**
  51484. * Parameters to perform the merge of the depth of field effect
  51485. */
  51486. depthOfField?: {
  51487. circleOfConfusion: PostProcess;
  51488. blurSteps: Array<PostProcess>;
  51489. };
  51490. /**
  51491. * Parameters to perform the merge of bloom effect
  51492. */
  51493. bloom?: {
  51494. blurred: PostProcess;
  51495. weight: number;
  51496. };
  51497. }
  51498. /**
  51499. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51500. */
  51501. export class DepthOfFieldMergePostProcess extends PostProcess {
  51502. private blurSteps;
  51503. /**
  51504. * Creates a new instance of DepthOfFieldMergePostProcess
  51505. * @param name The name of the effect.
  51506. * @param originalFromInput Post process which's input will be used for the merge.
  51507. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51508. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51509. * @param options The required width/height ratio to downsize to before computing the render pass.
  51510. * @param camera The camera to apply the render pass to.
  51511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51512. * @param engine The engine which the post process will be applied. (default: current engine)
  51513. * @param reusable If the post process can be reused on the same frame. (default: false)
  51514. * @param textureType Type of textures used when performing the post process. (default: 0)
  51515. * @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)
  51516. */
  51517. 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);
  51518. /**
  51519. * Updates the effect with the current post process compile time values and recompiles the shader.
  51520. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51521. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51522. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51523. * @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
  51524. * @param onCompiled Called when the shader has been compiled.
  51525. * @param onError Called if there is an error when compiling a shader.
  51526. */
  51527. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51528. }
  51529. }
  51530. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51531. import { Nullable } from "babylonjs/types";
  51532. import { Camera } from "babylonjs/Cameras/camera";
  51533. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51535. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51536. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51537. import { Scene } from "babylonjs/scene";
  51538. /**
  51539. * Specifies the level of max blur that should be applied when using the depth of field effect
  51540. */
  51541. export enum DepthOfFieldEffectBlurLevel {
  51542. /**
  51543. * Subtle blur
  51544. */
  51545. Low = 0,
  51546. /**
  51547. * Medium blur
  51548. */
  51549. Medium = 1,
  51550. /**
  51551. * Large blur
  51552. */
  51553. High = 2
  51554. }
  51555. /**
  51556. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51557. */
  51558. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51559. private _circleOfConfusion;
  51560. /**
  51561. * @hidden Internal, blurs from high to low
  51562. */
  51563. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51564. private _depthOfFieldBlurY;
  51565. private _dofMerge;
  51566. /**
  51567. * @hidden Internal post processes in depth of field effect
  51568. */
  51569. _effects: Array<PostProcess>;
  51570. /**
  51571. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51572. */
  51573. focalLength: number;
  51574. /**
  51575. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51576. */
  51577. fStop: number;
  51578. /**
  51579. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51580. */
  51581. focusDistance: number;
  51582. /**
  51583. * 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.
  51584. */
  51585. lensSize: number;
  51586. /**
  51587. * Creates a new instance DepthOfFieldEffect
  51588. * @param scene The scene the effect belongs to.
  51589. * @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.
  51590. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51591. * @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)
  51592. */
  51593. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51594. /**
  51595. * 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.
  51596. */
  51597. depthTexture: RenderTargetTexture;
  51598. /**
  51599. * Disposes each of the internal effects for a given camera.
  51600. * @param camera The camera to dispose the effect on.
  51601. */
  51602. disposeEffects(camera: Camera): void;
  51603. /**
  51604. * @hidden Internal
  51605. */
  51606. _updateEffects(): void;
  51607. /**
  51608. * Internal
  51609. * @returns if all the contained post processes are ready.
  51610. * @hidden
  51611. */
  51612. _isReady(): boolean;
  51613. }
  51614. }
  51615. declare module "babylonjs/Shaders/displayPass.fragment" {
  51616. /** @hidden */
  51617. export var displayPassPixelShader: {
  51618. name: string;
  51619. shader: string;
  51620. };
  51621. }
  51622. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  51623. import { Nullable } from "babylonjs/types";
  51624. import { Camera } from "babylonjs/Cameras/camera";
  51625. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51626. import { Engine } from "babylonjs/Engines/engine";
  51627. import "babylonjs/Shaders/displayPass.fragment";
  51628. /**
  51629. * DisplayPassPostProcess which produces an output the same as it's input
  51630. */
  51631. export class DisplayPassPostProcess extends PostProcess {
  51632. /**
  51633. * Creates the DisplayPassPostProcess
  51634. * @param name The name of the effect.
  51635. * @param options The required width/height ratio to downsize to before computing the render pass.
  51636. * @param camera The camera to apply the render pass to.
  51637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51638. * @param engine The engine which the post process will be applied. (default: current engine)
  51639. * @param reusable If the post process can be reused on the same frame. (default: false)
  51640. */
  51641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51642. }
  51643. }
  51644. declare module "babylonjs/Shaders/filter.fragment" {
  51645. /** @hidden */
  51646. export var filterPixelShader: {
  51647. name: string;
  51648. shader: string;
  51649. };
  51650. }
  51651. declare module "babylonjs/PostProcesses/filterPostProcess" {
  51652. import { Nullable } from "babylonjs/types";
  51653. import { Matrix } from "babylonjs/Maths/math";
  51654. import { Camera } from "babylonjs/Cameras/camera";
  51655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51656. import { Engine } from "babylonjs/Engines/engine";
  51657. import "babylonjs/Shaders/filter.fragment";
  51658. /**
  51659. * Applies a kernel filter to the image
  51660. */
  51661. export class FilterPostProcess extends PostProcess {
  51662. /** The matrix to be applied to the image */
  51663. kernelMatrix: Matrix;
  51664. /**
  51665. *
  51666. * @param name The name of the effect.
  51667. * @param kernelMatrix The matrix to be applied to the image
  51668. * @param options The required width/height ratio to downsize to before computing the render pass.
  51669. * @param camera The camera to apply the render pass to.
  51670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51671. * @param engine The engine which the post process will be applied. (default: current engine)
  51672. * @param reusable If the post process can be reused on the same frame. (default: false)
  51673. */
  51674. constructor(name: string,
  51675. /** The matrix to be applied to the image */
  51676. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51677. }
  51678. }
  51679. declare module "babylonjs/Shaders/fxaa.fragment" {
  51680. /** @hidden */
  51681. export var fxaaPixelShader: {
  51682. name: string;
  51683. shader: string;
  51684. };
  51685. }
  51686. declare module "babylonjs/Shaders/fxaa.vertex" {
  51687. /** @hidden */
  51688. export var fxaaVertexShader: {
  51689. name: string;
  51690. shader: string;
  51691. };
  51692. }
  51693. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  51694. import { Nullable } from "babylonjs/types";
  51695. import { Camera } from "babylonjs/Cameras/camera";
  51696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51697. import { Engine } from "babylonjs/Engines/engine";
  51698. import "babylonjs/Shaders/fxaa.fragment";
  51699. import "babylonjs/Shaders/fxaa.vertex";
  51700. /**
  51701. * Fxaa post process
  51702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51703. */
  51704. export class FxaaPostProcess extends PostProcess {
  51705. /** @hidden */
  51706. texelWidth: number;
  51707. /** @hidden */
  51708. texelHeight: number;
  51709. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51710. private _getDefines;
  51711. }
  51712. }
  51713. declare module "babylonjs/Shaders/grain.fragment" {
  51714. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51715. /** @hidden */
  51716. export var grainPixelShader: {
  51717. name: string;
  51718. shader: string;
  51719. };
  51720. }
  51721. declare module "babylonjs/PostProcesses/grainPostProcess" {
  51722. import { Nullable } from "babylonjs/types";
  51723. import { Camera } from "babylonjs/Cameras/camera";
  51724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51725. import { Engine } from "babylonjs/Engines/engine";
  51726. import "babylonjs/Shaders/grain.fragment";
  51727. /**
  51728. * The GrainPostProcess adds noise to the image at mid luminance levels
  51729. */
  51730. export class GrainPostProcess extends PostProcess {
  51731. /**
  51732. * The intensity of the grain added (default: 30)
  51733. */
  51734. intensity: number;
  51735. /**
  51736. * If the grain should be randomized on every frame
  51737. */
  51738. animated: boolean;
  51739. /**
  51740. * Creates a new instance of @see GrainPostProcess
  51741. * @param name The name of the effect.
  51742. * @param options The required width/height ratio to downsize to before computing the render pass.
  51743. * @param camera The camera to apply the render pass to.
  51744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51745. * @param engine The engine which the post process will be applied. (default: current engine)
  51746. * @param reusable If the post process can be reused on the same frame. (default: false)
  51747. * @param textureType Type of textures used when performing the post process. (default: 0)
  51748. * @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)
  51749. */
  51750. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51751. }
  51752. }
  51753. declare module "babylonjs/Shaders/highlights.fragment" {
  51754. /** @hidden */
  51755. export var highlightsPixelShader: {
  51756. name: string;
  51757. shader: string;
  51758. };
  51759. }
  51760. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  51761. import { Nullable } from "babylonjs/types";
  51762. import { Camera } from "babylonjs/Cameras/camera";
  51763. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51764. import { Engine } from "babylonjs/Engines/engine";
  51765. import "babylonjs/Shaders/highlights.fragment";
  51766. /**
  51767. * Extracts highlights from the image
  51768. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51769. */
  51770. export class HighlightsPostProcess extends PostProcess {
  51771. /**
  51772. * Extracts highlights from the image
  51773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51774. * @param name The name of the effect.
  51775. * @param options The required width/height ratio to downsize to before computing the render pass.
  51776. * @param camera The camera to apply the render pass to.
  51777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51778. * @param engine The engine which the post process will be applied. (default: current engine)
  51779. * @param reusable If the post process can be reused on the same frame. (default: false)
  51780. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51781. */
  51782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51783. }
  51784. }
  51785. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  51786. /** @hidden */
  51787. export var mrtFragmentDeclaration: {
  51788. name: string;
  51789. shader: string;
  51790. };
  51791. }
  51792. declare module "babylonjs/Shaders/geometry.fragment" {
  51793. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  51794. /** @hidden */
  51795. export var geometryPixelShader: {
  51796. name: string;
  51797. shader: string;
  51798. };
  51799. }
  51800. declare module "babylonjs/Shaders/geometry.vertex" {
  51801. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51802. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51803. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51804. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51805. /** @hidden */
  51806. export var geometryVertexShader: {
  51807. name: string;
  51808. shader: string;
  51809. };
  51810. }
  51811. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  51812. import { Matrix } from "babylonjs/Maths/math";
  51813. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51814. import { Mesh } from "babylonjs/Meshes/mesh";
  51815. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  51816. import { Effect } from "babylonjs/Materials/effect";
  51817. import { Scene } from "babylonjs/scene";
  51818. import "babylonjs/Shaders/geometry.fragment";
  51819. import "babylonjs/Shaders/geometry.vertex";
  51820. /**
  51821. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51822. */
  51823. export class GeometryBufferRenderer {
  51824. /**
  51825. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51826. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51827. */
  51828. static readonly POSITION_TEXTURE_TYPE: number;
  51829. /**
  51830. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51831. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51832. */
  51833. static readonly VELOCITY_TEXTURE_TYPE: number;
  51834. /**
  51835. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51836. * in order to compute objects velocities when enableVelocity is set to "true"
  51837. * @hidden
  51838. */
  51839. _previousTransformationMatrices: {
  51840. [index: number]: Matrix;
  51841. };
  51842. private _scene;
  51843. private _multiRenderTarget;
  51844. private _ratio;
  51845. private _enablePosition;
  51846. private _enableVelocity;
  51847. private _positionIndex;
  51848. private _velocityIndex;
  51849. protected _effect: Effect;
  51850. protected _cachedDefines: string;
  51851. /**
  51852. * Set the render list (meshes to be rendered) used in the G buffer.
  51853. */
  51854. renderList: Mesh[];
  51855. /**
  51856. * Gets wether or not G buffer are supported by the running hardware.
  51857. * This requires draw buffer supports
  51858. */
  51859. readonly isSupported: boolean;
  51860. /**
  51861. * Returns the index of the given texture type in the G-Buffer textures array
  51862. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51863. * @returns the index of the given texture type in the G-Buffer textures array
  51864. */
  51865. getTextureIndex(textureType: number): number;
  51866. /**
  51867. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51868. */
  51869. /**
  51870. * Sets whether or not objects positions are enabled for the G buffer.
  51871. */
  51872. enablePosition: boolean;
  51873. /**
  51874. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51875. */
  51876. /**
  51877. * Sets wether or not objects velocities are enabled for the G buffer.
  51878. */
  51879. enableVelocity: boolean;
  51880. /**
  51881. * Gets the scene associated with the buffer.
  51882. */
  51883. readonly scene: Scene;
  51884. /**
  51885. * Gets the ratio used by the buffer during its creation.
  51886. * How big is the buffer related to the main canvas.
  51887. */
  51888. readonly ratio: number;
  51889. /** @hidden */
  51890. static _SceneComponentInitialization: (scene: Scene) => void;
  51891. /**
  51892. * Creates a new G Buffer for the scene
  51893. * @param scene The scene the buffer belongs to
  51894. * @param ratio How big is the buffer related to the main canvas.
  51895. */
  51896. constructor(scene: Scene, ratio?: number);
  51897. /**
  51898. * Checks wether everything is ready to render a submesh to the G buffer.
  51899. * @param subMesh the submesh to check readiness for
  51900. * @param useInstances is the mesh drawn using instance or not
  51901. * @returns true if ready otherwise false
  51902. */
  51903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51904. /**
  51905. * Gets the current underlying G Buffer.
  51906. * @returns the buffer
  51907. */
  51908. getGBuffer(): MultiRenderTarget;
  51909. /**
  51910. * Gets the number of samples used to render the buffer (anti aliasing).
  51911. */
  51912. /**
  51913. * Sets the number of samples used to render the buffer (anti aliasing).
  51914. */
  51915. samples: number;
  51916. /**
  51917. * Disposes the renderer and frees up associated resources.
  51918. */
  51919. dispose(): void;
  51920. protected _createRenderTargets(): void;
  51921. }
  51922. }
  51923. declare module "babylonjs/Shaders/motionBlur.fragment" {
  51924. /** @hidden */
  51925. export var motionBlurPixelShader: {
  51926. name: string;
  51927. shader: string;
  51928. };
  51929. }
  51930. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  51931. import { Nullable } from "babylonjs/types";
  51932. import { Camera } from "babylonjs/Cameras/camera";
  51933. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51934. import { Scene } from "babylonjs/scene";
  51935. import "babylonjs/Shaders/motionBlur.fragment";
  51936. import { Engine } from "babylonjs/Engines/engine";
  51937. /**
  51938. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51939. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51940. * As an example, all you have to do is to create the post-process:
  51941. * var mb = new BABYLON.MotionBlurPostProcess(
  51942. * 'mb', // The name of the effect.
  51943. * scene, // The scene containing the objects to blur according to their velocity.
  51944. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51945. * camera // The camera to apply the render pass to.
  51946. * );
  51947. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51948. */
  51949. export class MotionBlurPostProcess extends PostProcess {
  51950. /**
  51951. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51952. */
  51953. motionStrength: number;
  51954. /**
  51955. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51956. */
  51957. /**
  51958. * Sets the number of iterations to be used for motion blur quality
  51959. */
  51960. motionBlurSamples: number;
  51961. private _motionBlurSamples;
  51962. private _geometryBufferRenderer;
  51963. /**
  51964. * Creates a new instance MotionBlurPostProcess
  51965. * @param name The name of the effect.
  51966. * @param scene The scene containing the objects to blur according to their velocity.
  51967. * @param options The required width/height ratio to downsize to before computing the render pass.
  51968. * @param camera The camera to apply the render pass to.
  51969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51970. * @param engine The engine which the post process will be applied. (default: current engine)
  51971. * @param reusable If the post process can be reused on the same frame. (default: false)
  51972. * @param textureType Type of textures used when performing the post process. (default: 0)
  51973. * @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)
  51974. */
  51975. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51976. /**
  51977. * Disposes the post process.
  51978. * @param camera The camera to dispose the post process on.
  51979. */
  51980. dispose(camera?: Camera): void;
  51981. }
  51982. }
  51983. declare module "babylonjs/Shaders/refraction.fragment" {
  51984. /** @hidden */
  51985. export var refractionPixelShader: {
  51986. name: string;
  51987. shader: string;
  51988. };
  51989. }
  51990. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  51991. import { Color3 } from "babylonjs/Maths/math";
  51992. import { Camera } from "babylonjs/Cameras/camera";
  51993. import { Texture } from "babylonjs/Materials/Textures/texture";
  51994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51995. import { Engine } from "babylonjs/Engines/engine";
  51996. import "babylonjs/Shaders/refraction.fragment";
  51997. /**
  51998. * Post process which applies a refractin texture
  51999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52000. */
  52001. export class RefractionPostProcess extends PostProcess {
  52002. /** the base color of the refraction (used to taint the rendering) */
  52003. color: Color3;
  52004. /** simulated refraction depth */
  52005. depth: number;
  52006. /** the coefficient of the base color (0 to remove base color tainting) */
  52007. colorLevel: number;
  52008. private _refTexture;
  52009. private _ownRefractionTexture;
  52010. /**
  52011. * Gets or sets the refraction texture
  52012. * Please note that you are responsible for disposing the texture if you set it manually
  52013. */
  52014. refractionTexture: Texture;
  52015. /**
  52016. * Initializes the RefractionPostProcess
  52017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52018. * @param name The name of the effect.
  52019. * @param refractionTextureUrl Url of the refraction texture to use
  52020. * @param color the base color of the refraction (used to taint the rendering)
  52021. * @param depth simulated refraction depth
  52022. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52023. * @param camera The camera to apply the render pass to.
  52024. * @param options The required width/height ratio to downsize to before computing the render pass.
  52025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52026. * @param engine The engine which the post process will be applied. (default: current engine)
  52027. * @param reusable If the post process can be reused on the same frame. (default: false)
  52028. */
  52029. constructor(name: string, refractionTextureUrl: string,
  52030. /** the base color of the refraction (used to taint the rendering) */
  52031. color: Color3,
  52032. /** simulated refraction depth */
  52033. depth: number,
  52034. /** the coefficient of the base color (0 to remove base color tainting) */
  52035. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52036. /**
  52037. * Disposes of the post process
  52038. * @param camera Camera to dispose post process on
  52039. */
  52040. dispose(camera: Camera): void;
  52041. }
  52042. }
  52043. declare module "babylonjs/Shaders/sharpen.fragment" {
  52044. /** @hidden */
  52045. export var sharpenPixelShader: {
  52046. name: string;
  52047. shader: string;
  52048. };
  52049. }
  52050. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52051. import { Nullable } from "babylonjs/types";
  52052. import { Camera } from "babylonjs/Cameras/camera";
  52053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52054. import "babylonjs/Shaders/sharpen.fragment";
  52055. import { Engine } from "babylonjs/Engines/engine";
  52056. /**
  52057. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52058. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52059. */
  52060. export class SharpenPostProcess extends PostProcess {
  52061. /**
  52062. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52063. */
  52064. colorAmount: number;
  52065. /**
  52066. * How much sharpness should be applied (default: 0.3)
  52067. */
  52068. edgeAmount: number;
  52069. /**
  52070. * Creates a new instance ConvolutionPostProcess
  52071. * @param name The name of the effect.
  52072. * @param options The required width/height ratio to downsize to before computing the render pass.
  52073. * @param camera The camera to apply the render pass to.
  52074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52075. * @param engine The engine which the post process will be applied. (default: current engine)
  52076. * @param reusable If the post process can be reused on the same frame. (default: false)
  52077. * @param textureType Type of textures used when performing the post process. (default: 0)
  52078. * @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)
  52079. */
  52080. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52081. }
  52082. }
  52083. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52084. import { Nullable } from "babylonjs/types";
  52085. import { Camera } from "babylonjs/Cameras/camera";
  52086. import { Engine } from "babylonjs/Engines/engine";
  52087. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52088. /**
  52089. * PostProcessRenderPipeline
  52090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52091. */
  52092. export class PostProcessRenderPipeline {
  52093. private engine;
  52094. private _renderEffects;
  52095. private _renderEffectsForIsolatedPass;
  52096. /**
  52097. * @hidden
  52098. */
  52099. protected _cameras: Camera[];
  52100. /** @hidden */
  52101. _name: string;
  52102. /**
  52103. * Initializes a PostProcessRenderPipeline
  52104. * @param engine engine to add the pipeline to
  52105. * @param name name of the pipeline
  52106. */
  52107. constructor(engine: Engine, name: string);
  52108. /**
  52109. * "PostProcessRenderPipeline"
  52110. * @returns "PostProcessRenderPipeline"
  52111. */
  52112. getClassName(): string;
  52113. /**
  52114. * If all the render effects in the pipeline are support
  52115. */
  52116. readonly isSupported: boolean;
  52117. /**
  52118. * Adds an effect to the pipeline
  52119. * @param renderEffect the effect to add
  52120. */
  52121. addEffect(renderEffect: PostProcessRenderEffect): void;
  52122. /** @hidden */
  52123. _rebuild(): void;
  52124. /** @hidden */
  52125. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52126. /** @hidden */
  52127. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52128. /** @hidden */
  52129. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52130. /** @hidden */
  52131. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52132. /** @hidden */
  52133. _attachCameras(cameras: Camera, unique: boolean): void;
  52134. /** @hidden */
  52135. _attachCameras(cameras: Camera[], unique: boolean): void;
  52136. /** @hidden */
  52137. _detachCameras(cameras: Camera): void;
  52138. /** @hidden */
  52139. _detachCameras(cameras: Nullable<Camera[]>): void;
  52140. /** @hidden */
  52141. _update(): void;
  52142. /** @hidden */
  52143. _reset(): void;
  52144. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52145. /**
  52146. * Disposes of the pipeline
  52147. */
  52148. dispose(): void;
  52149. }
  52150. }
  52151. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52152. import { IAnimatable } from "babylonjs/Misc/tools";
  52153. import { Camera } from "babylonjs/Cameras/camera";
  52154. import { IDisposable } from "babylonjs/scene";
  52155. import { Scene } from "babylonjs/scene";
  52156. import { Animation } from "babylonjs/Animations/animation";
  52157. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52158. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52159. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52160. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52161. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52162. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52163. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52164. /**
  52165. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52166. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52167. */
  52168. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52169. private _scene;
  52170. private _camerasToBeAttached;
  52171. /**
  52172. * ID of the sharpen post process,
  52173. */
  52174. private readonly SharpenPostProcessId;
  52175. /**
  52176. * @ignore
  52177. * ID of the image processing post process;
  52178. */
  52179. readonly ImageProcessingPostProcessId: string;
  52180. /**
  52181. * @ignore
  52182. * ID of the Fast Approximate Anti-Aliasing post process;
  52183. */
  52184. readonly FxaaPostProcessId: string;
  52185. /**
  52186. * ID of the chromatic aberration post process,
  52187. */
  52188. private readonly ChromaticAberrationPostProcessId;
  52189. /**
  52190. * ID of the grain post process
  52191. */
  52192. private readonly GrainPostProcessId;
  52193. /**
  52194. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52195. */
  52196. sharpen: SharpenPostProcess;
  52197. private _sharpenEffect;
  52198. private bloom;
  52199. /**
  52200. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52201. */
  52202. depthOfField: DepthOfFieldEffect;
  52203. /**
  52204. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52205. */
  52206. fxaa: FxaaPostProcess;
  52207. /**
  52208. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52209. */
  52210. imageProcessing: ImageProcessingPostProcess;
  52211. /**
  52212. * Chromatic aberration post process which will shift rgb colors in the image
  52213. */
  52214. chromaticAberration: ChromaticAberrationPostProcess;
  52215. private _chromaticAberrationEffect;
  52216. /**
  52217. * Grain post process which add noise to the image
  52218. */
  52219. grain: GrainPostProcess;
  52220. private _grainEffect;
  52221. /**
  52222. * Glow post process which adds a glow to emmisive areas of the image
  52223. */
  52224. private _glowLayer;
  52225. /**
  52226. * Animations which can be used to tweak settings over a period of time
  52227. */
  52228. animations: Animation[];
  52229. private _imageProcessingConfigurationObserver;
  52230. private _sharpenEnabled;
  52231. private _bloomEnabled;
  52232. private _depthOfFieldEnabled;
  52233. private _depthOfFieldBlurLevel;
  52234. private _fxaaEnabled;
  52235. private _imageProcessingEnabled;
  52236. private _defaultPipelineTextureType;
  52237. private _bloomScale;
  52238. private _chromaticAberrationEnabled;
  52239. private _grainEnabled;
  52240. private _buildAllowed;
  52241. /**
  52242. * Enable or disable the sharpen process from the pipeline
  52243. */
  52244. sharpenEnabled: boolean;
  52245. private _resizeObserver;
  52246. private _hardwareScaleLevel;
  52247. private _bloomKernel;
  52248. /**
  52249. * Specifies the size of the bloom blur kernel, relative to the final output size
  52250. */
  52251. bloomKernel: number;
  52252. /**
  52253. * Specifies the weight of the bloom in the final rendering
  52254. */
  52255. private _bloomWeight;
  52256. /**
  52257. * Specifies the luma threshold for the area that will be blurred by the bloom
  52258. */
  52259. private _bloomThreshold;
  52260. private _hdr;
  52261. /**
  52262. * The strength of the bloom.
  52263. */
  52264. bloomWeight: number;
  52265. /**
  52266. * The strength of the bloom.
  52267. */
  52268. bloomThreshold: number;
  52269. /**
  52270. * The scale of the bloom, lower value will provide better performance.
  52271. */
  52272. bloomScale: number;
  52273. /**
  52274. * Enable or disable the bloom from the pipeline
  52275. */
  52276. bloomEnabled: boolean;
  52277. private _rebuildBloom;
  52278. /**
  52279. * If the depth of field is enabled.
  52280. */
  52281. depthOfFieldEnabled: boolean;
  52282. /**
  52283. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52284. */
  52285. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52286. /**
  52287. * If the anti aliasing is enabled.
  52288. */
  52289. fxaaEnabled: boolean;
  52290. private _samples;
  52291. /**
  52292. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52293. */
  52294. samples: number;
  52295. /**
  52296. * If image processing is enabled.
  52297. */
  52298. imageProcessingEnabled: boolean;
  52299. /**
  52300. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52301. */
  52302. glowLayerEnabled: boolean;
  52303. /**
  52304. * Enable or disable the chromaticAberration process from the pipeline
  52305. */
  52306. chromaticAberrationEnabled: boolean;
  52307. /**
  52308. * Enable or disable the grain process from the pipeline
  52309. */
  52310. grainEnabled: boolean;
  52311. /**
  52312. * @constructor
  52313. * @param name - The rendering pipeline name (default: "")
  52314. * @param hdr - If high dynamic range textures should be used (default: true)
  52315. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52316. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52317. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52318. */
  52319. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52320. /**
  52321. * Force the compilation of the entire pipeline.
  52322. */
  52323. prepare(): void;
  52324. private _hasCleared;
  52325. private _prevPostProcess;
  52326. private _prevPrevPostProcess;
  52327. private _setAutoClearAndTextureSharing;
  52328. private _depthOfFieldSceneObserver;
  52329. private _buildPipeline;
  52330. private _disposePostProcesses;
  52331. /**
  52332. * Adds a camera to the pipeline
  52333. * @param camera the camera to be added
  52334. */
  52335. addCamera(camera: Camera): void;
  52336. /**
  52337. * Removes a camera from the pipeline
  52338. * @param camera the camera to remove
  52339. */
  52340. removeCamera(camera: Camera): void;
  52341. /**
  52342. * Dispose of the pipeline and stop all post processes
  52343. */
  52344. dispose(): void;
  52345. /**
  52346. * Serialize the rendering pipeline (Used when exporting)
  52347. * @returns the serialized object
  52348. */
  52349. serialize(): any;
  52350. /**
  52351. * Parse the serialized pipeline
  52352. * @param source Source pipeline.
  52353. * @param scene The scene to load the pipeline to.
  52354. * @param rootUrl The URL of the serialized pipeline.
  52355. * @returns An instantiated pipeline from the serialized object.
  52356. */
  52357. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52358. }
  52359. }
  52360. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52361. /** @hidden */
  52362. export var lensHighlightsPixelShader: {
  52363. name: string;
  52364. shader: string;
  52365. };
  52366. }
  52367. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52368. /** @hidden */
  52369. export var depthOfFieldPixelShader: {
  52370. name: string;
  52371. shader: string;
  52372. };
  52373. }
  52374. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52375. import { Camera } from "babylonjs/Cameras/camera";
  52376. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52377. import { Scene } from "babylonjs/scene";
  52378. import "babylonjs/Shaders/chromaticAberration.fragment";
  52379. import "babylonjs/Shaders/lensHighlights.fragment";
  52380. import "babylonjs/Shaders/depthOfField.fragment";
  52381. /**
  52382. * BABYLON.JS Chromatic Aberration GLSL Shader
  52383. * Author: Olivier Guyot
  52384. * Separates very slightly R, G and B colors on the edges of the screen
  52385. * Inspired by Francois Tarlier & Martins Upitis
  52386. */
  52387. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52388. /**
  52389. * @ignore
  52390. * The chromatic aberration PostProcess id in the pipeline
  52391. */
  52392. LensChromaticAberrationEffect: string;
  52393. /**
  52394. * @ignore
  52395. * The highlights enhancing PostProcess id in the pipeline
  52396. */
  52397. HighlightsEnhancingEffect: string;
  52398. /**
  52399. * @ignore
  52400. * The depth-of-field PostProcess id in the pipeline
  52401. */
  52402. LensDepthOfFieldEffect: string;
  52403. private _scene;
  52404. private _depthTexture;
  52405. private _grainTexture;
  52406. private _chromaticAberrationPostProcess;
  52407. private _highlightsPostProcess;
  52408. private _depthOfFieldPostProcess;
  52409. private _edgeBlur;
  52410. private _grainAmount;
  52411. private _chromaticAberration;
  52412. private _distortion;
  52413. private _highlightsGain;
  52414. private _highlightsThreshold;
  52415. private _dofDistance;
  52416. private _dofAperture;
  52417. private _dofDarken;
  52418. private _dofPentagon;
  52419. private _blurNoise;
  52420. /**
  52421. * @constructor
  52422. *
  52423. * Effect parameters are as follow:
  52424. * {
  52425. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52426. * edge_blur: number; // from 0 to x (1 for realism)
  52427. * distortion: number; // from 0 to x (1 for realism)
  52428. * grain_amount: number; // from 0 to 1
  52429. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52430. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52431. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52432. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52433. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52434. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52435. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52436. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52437. * }
  52438. * Note: if an effect parameter is unset, effect is disabled
  52439. *
  52440. * @param name The rendering pipeline name
  52441. * @param parameters - An object containing all parameters (see above)
  52442. * @param scene The scene linked to this pipeline
  52443. * @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)
  52444. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52445. */
  52446. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52447. /**
  52448. * Sets the amount of blur at the edges
  52449. * @param amount blur amount
  52450. */
  52451. setEdgeBlur(amount: number): void;
  52452. /**
  52453. * Sets edge blur to 0
  52454. */
  52455. disableEdgeBlur(): void;
  52456. /**
  52457. * Sets the amout of grain
  52458. * @param amount Amount of grain
  52459. */
  52460. setGrainAmount(amount: number): void;
  52461. /**
  52462. * Set grain amount to 0
  52463. */
  52464. disableGrain(): void;
  52465. /**
  52466. * Sets the chromatic aberration amount
  52467. * @param amount amount of chromatic aberration
  52468. */
  52469. setChromaticAberration(amount: number): void;
  52470. /**
  52471. * Sets chromatic aberration amount to 0
  52472. */
  52473. disableChromaticAberration(): void;
  52474. /**
  52475. * Sets the EdgeDistortion amount
  52476. * @param amount amount of EdgeDistortion
  52477. */
  52478. setEdgeDistortion(amount: number): void;
  52479. /**
  52480. * Sets edge distortion to 0
  52481. */
  52482. disableEdgeDistortion(): void;
  52483. /**
  52484. * Sets the FocusDistance amount
  52485. * @param amount amount of FocusDistance
  52486. */
  52487. setFocusDistance(amount: number): void;
  52488. /**
  52489. * Disables depth of field
  52490. */
  52491. disableDepthOfField(): void;
  52492. /**
  52493. * Sets the Aperture amount
  52494. * @param amount amount of Aperture
  52495. */
  52496. setAperture(amount: number): void;
  52497. /**
  52498. * Sets the DarkenOutOfFocus amount
  52499. * @param amount amount of DarkenOutOfFocus
  52500. */
  52501. setDarkenOutOfFocus(amount: number): void;
  52502. /**
  52503. * Creates a pentagon bokeh effect
  52504. */
  52505. enablePentagonBokeh(): void;
  52506. /**
  52507. * Disables the pentagon bokeh effect
  52508. */
  52509. disablePentagonBokeh(): void;
  52510. /**
  52511. * Enables noise blur
  52512. */
  52513. enableNoiseBlur(): void;
  52514. /**
  52515. * Disables noise blur
  52516. */
  52517. disableNoiseBlur(): void;
  52518. /**
  52519. * Sets the HighlightsGain amount
  52520. * @param amount amount of HighlightsGain
  52521. */
  52522. setHighlightsGain(amount: number): void;
  52523. /**
  52524. * Sets the HighlightsThreshold amount
  52525. * @param amount amount of HighlightsThreshold
  52526. */
  52527. setHighlightsThreshold(amount: number): void;
  52528. /**
  52529. * Disables highlights
  52530. */
  52531. disableHighlights(): void;
  52532. /**
  52533. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52534. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52535. */
  52536. dispose(disableDepthRender?: boolean): void;
  52537. private _createChromaticAberrationPostProcess;
  52538. private _createHighlightsPostProcess;
  52539. private _createDepthOfFieldPostProcess;
  52540. private _createGrainTexture;
  52541. }
  52542. }
  52543. declare module "babylonjs/Shaders/ssao2.fragment" {
  52544. /** @hidden */
  52545. export var ssao2PixelShader: {
  52546. name: string;
  52547. shader: string;
  52548. };
  52549. }
  52550. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52551. /** @hidden */
  52552. export var ssaoCombinePixelShader: {
  52553. name: string;
  52554. shader: string;
  52555. };
  52556. }
  52557. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  52558. import { Camera } from "babylonjs/Cameras/camera";
  52559. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52560. import { Scene } from "babylonjs/scene";
  52561. import "babylonjs/Shaders/ssao2.fragment";
  52562. import "babylonjs/Shaders/ssaoCombine.fragment";
  52563. /**
  52564. * Render pipeline to produce ssao effect
  52565. */
  52566. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52567. /**
  52568. * @ignore
  52569. * The PassPostProcess id in the pipeline that contains the original scene color
  52570. */
  52571. SSAOOriginalSceneColorEffect: string;
  52572. /**
  52573. * @ignore
  52574. * The SSAO PostProcess id in the pipeline
  52575. */
  52576. SSAORenderEffect: string;
  52577. /**
  52578. * @ignore
  52579. * The horizontal blur PostProcess id in the pipeline
  52580. */
  52581. SSAOBlurHRenderEffect: string;
  52582. /**
  52583. * @ignore
  52584. * The vertical blur PostProcess id in the pipeline
  52585. */
  52586. SSAOBlurVRenderEffect: string;
  52587. /**
  52588. * @ignore
  52589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52590. */
  52591. SSAOCombineRenderEffect: string;
  52592. /**
  52593. * The output strength of the SSAO post-process. Default value is 1.0.
  52594. */
  52595. totalStrength: number;
  52596. /**
  52597. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52598. */
  52599. maxZ: number;
  52600. /**
  52601. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52602. */
  52603. minZAspect: number;
  52604. private _samples;
  52605. /**
  52606. * Number of samples used for the SSAO calculations. Default value is 8
  52607. */
  52608. samples: number;
  52609. private _textureSamples;
  52610. /**
  52611. * Number of samples to use for antialiasing
  52612. */
  52613. textureSamples: number;
  52614. /**
  52615. * Ratio object used for SSAO ratio and blur ratio
  52616. */
  52617. private _ratio;
  52618. /**
  52619. * Dynamically generated sphere sampler.
  52620. */
  52621. private _sampleSphere;
  52622. /**
  52623. * Blur filter offsets
  52624. */
  52625. private _samplerOffsets;
  52626. private _expensiveBlur;
  52627. /**
  52628. * If bilateral blur should be used
  52629. */
  52630. expensiveBlur: boolean;
  52631. /**
  52632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52633. */
  52634. radius: number;
  52635. /**
  52636. * The base color of the SSAO post-process
  52637. * The final result is "base + ssao" between [0, 1]
  52638. */
  52639. base: number;
  52640. /**
  52641. * Support test.
  52642. */
  52643. static readonly IsSupported: boolean;
  52644. private _scene;
  52645. private _depthTexture;
  52646. private _normalTexture;
  52647. private _randomTexture;
  52648. private _originalColorPostProcess;
  52649. private _ssaoPostProcess;
  52650. private _blurHPostProcess;
  52651. private _blurVPostProcess;
  52652. private _ssaoCombinePostProcess;
  52653. private _firstUpdate;
  52654. /**
  52655. * @constructor
  52656. * @param name The rendering pipeline name
  52657. * @param scene The scene linked to this pipeline
  52658. * @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 }
  52659. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52660. */
  52661. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52662. /**
  52663. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52664. */
  52665. dispose(disableGeometryBufferRenderer?: boolean): void;
  52666. private _createBlurPostProcess;
  52667. /** @hidden */
  52668. _rebuild(): void;
  52669. private _bits;
  52670. private _radicalInverse_VdC;
  52671. private _hammersley;
  52672. private _hemisphereSample_uniform;
  52673. private _generateHemisphere;
  52674. private _createSSAOPostProcess;
  52675. private _createSSAOCombinePostProcess;
  52676. private _createRandomTexture;
  52677. /**
  52678. * Serialize the rendering pipeline (Used when exporting)
  52679. * @returns the serialized object
  52680. */
  52681. serialize(): any;
  52682. /**
  52683. * Parse the serialized pipeline
  52684. * @param source Source pipeline.
  52685. * @param scene The scene to load the pipeline to.
  52686. * @param rootUrl The URL of the serialized pipeline.
  52687. * @returns An instantiated pipeline from the serialized object.
  52688. */
  52689. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52690. }
  52691. }
  52692. declare module "babylonjs/Shaders/ssao.fragment" {
  52693. /** @hidden */
  52694. export var ssaoPixelShader: {
  52695. name: string;
  52696. shader: string;
  52697. };
  52698. }
  52699. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  52700. import { Camera } from "babylonjs/Cameras/camera";
  52701. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52702. import { Scene } from "babylonjs/scene";
  52703. import "babylonjs/Shaders/ssao.fragment";
  52704. import "babylonjs/Shaders/ssaoCombine.fragment";
  52705. /**
  52706. * Render pipeline to produce ssao effect
  52707. */
  52708. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52709. /**
  52710. * @ignore
  52711. * The PassPostProcess id in the pipeline that contains the original scene color
  52712. */
  52713. SSAOOriginalSceneColorEffect: string;
  52714. /**
  52715. * @ignore
  52716. * The SSAO PostProcess id in the pipeline
  52717. */
  52718. SSAORenderEffect: string;
  52719. /**
  52720. * @ignore
  52721. * The horizontal blur PostProcess id in the pipeline
  52722. */
  52723. SSAOBlurHRenderEffect: string;
  52724. /**
  52725. * @ignore
  52726. * The vertical blur PostProcess id in the pipeline
  52727. */
  52728. SSAOBlurVRenderEffect: string;
  52729. /**
  52730. * @ignore
  52731. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52732. */
  52733. SSAOCombineRenderEffect: string;
  52734. /**
  52735. * The output strength of the SSAO post-process. Default value is 1.0.
  52736. */
  52737. totalStrength: number;
  52738. /**
  52739. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52740. */
  52741. radius: number;
  52742. /**
  52743. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52744. * Must not be equal to fallOff and superior to fallOff.
  52745. * Default value is 0.975
  52746. */
  52747. area: number;
  52748. /**
  52749. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52750. * Must not be equal to area and inferior to area.
  52751. * Default value is 0.0
  52752. */
  52753. fallOff: number;
  52754. /**
  52755. * The base color of the SSAO post-process
  52756. * The final result is "base + ssao" between [0, 1]
  52757. */
  52758. base: number;
  52759. private _scene;
  52760. private _depthTexture;
  52761. private _randomTexture;
  52762. private _originalColorPostProcess;
  52763. private _ssaoPostProcess;
  52764. private _blurHPostProcess;
  52765. private _blurVPostProcess;
  52766. private _ssaoCombinePostProcess;
  52767. private _firstUpdate;
  52768. /**
  52769. * @constructor
  52770. * @param name - The rendering pipeline name
  52771. * @param scene - The scene linked to this pipeline
  52772. * @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 }
  52773. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52774. */
  52775. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52776. /**
  52777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52778. */
  52779. dispose(disableDepthRender?: boolean): void;
  52780. private _createBlurPostProcess;
  52781. /** @hidden */
  52782. _rebuild(): void;
  52783. private _createSSAOPostProcess;
  52784. private _createSSAOCombinePostProcess;
  52785. private _createRandomTexture;
  52786. }
  52787. }
  52788. declare module "babylonjs/Shaders/standard.fragment" {
  52789. /** @hidden */
  52790. export var standardPixelShader: {
  52791. name: string;
  52792. shader: string;
  52793. };
  52794. }
  52795. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  52796. import { Nullable } from "babylonjs/types";
  52797. import { IAnimatable } from "babylonjs/Misc/tools";
  52798. import { Camera } from "babylonjs/Cameras/camera";
  52799. import { Texture } from "babylonjs/Materials/Textures/texture";
  52800. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52801. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52802. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52803. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52804. import { IDisposable } from "babylonjs/scene";
  52805. import { SpotLight } from "babylonjs/Lights/spotLight";
  52806. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  52807. import { Scene } from "babylonjs/scene";
  52808. import { Animation } from "babylonjs/Animations/animation";
  52809. import "babylonjs/Shaders/standard.fragment";
  52810. /**
  52811. * Standard rendering pipeline
  52812. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52813. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52814. */
  52815. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52816. /**
  52817. * Public members
  52818. */
  52819. /**
  52820. * Post-process which contains the original scene color before the pipeline applies all the effects
  52821. */
  52822. originalPostProcess: Nullable<PostProcess>;
  52823. /**
  52824. * Post-process used to down scale an image x4
  52825. */
  52826. downSampleX4PostProcess: Nullable<PostProcess>;
  52827. /**
  52828. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52829. */
  52830. brightPassPostProcess: Nullable<PostProcess>;
  52831. /**
  52832. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52833. */
  52834. blurHPostProcesses: PostProcess[];
  52835. /**
  52836. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52837. */
  52838. blurVPostProcesses: PostProcess[];
  52839. /**
  52840. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52841. */
  52842. textureAdderPostProcess: Nullable<PostProcess>;
  52843. /**
  52844. * Post-process used to create volumetric lighting effect
  52845. */
  52846. volumetricLightPostProcess: Nullable<PostProcess>;
  52847. /**
  52848. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52849. */
  52850. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52851. /**
  52852. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52853. */
  52854. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52855. /**
  52856. * Post-process used to merge the volumetric light effect and the real scene color
  52857. */
  52858. volumetricLightMergePostProces: Nullable<PostProcess>;
  52859. /**
  52860. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52861. */
  52862. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52863. /**
  52864. * Base post-process used to calculate the average luminance of the final image for HDR
  52865. */
  52866. luminancePostProcess: Nullable<PostProcess>;
  52867. /**
  52868. * Post-processes used to create down sample post-processes in order to get
  52869. * the average luminance of the final image for HDR
  52870. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  52871. */
  52872. luminanceDownSamplePostProcesses: PostProcess[];
  52873. /**
  52874. * Post-process used to create a HDR effect (light adaptation)
  52875. */
  52876. hdrPostProcess: Nullable<PostProcess>;
  52877. /**
  52878. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  52879. */
  52880. textureAdderFinalPostProcess: Nullable<PostProcess>;
  52881. /**
  52882. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  52883. */
  52884. lensFlareFinalPostProcess: Nullable<PostProcess>;
  52885. /**
  52886. * Post-process used to merge the final HDR post-process and the real scene color
  52887. */
  52888. hdrFinalPostProcess: Nullable<PostProcess>;
  52889. /**
  52890. * Post-process used to create a lens flare effect
  52891. */
  52892. lensFlarePostProcess: Nullable<PostProcess>;
  52893. /**
  52894. * Post-process that merges the result of the lens flare post-process and the real scene color
  52895. */
  52896. lensFlareComposePostProcess: Nullable<PostProcess>;
  52897. /**
  52898. * Post-process used to create a motion blur effect
  52899. */
  52900. motionBlurPostProcess: Nullable<PostProcess>;
  52901. /**
  52902. * Post-process used to create a depth of field effect
  52903. */
  52904. depthOfFieldPostProcess: Nullable<PostProcess>;
  52905. /**
  52906. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52907. */
  52908. fxaaPostProcess: Nullable<FxaaPostProcess>;
  52909. /**
  52910. * Represents the brightness threshold in order to configure the illuminated surfaces
  52911. */
  52912. brightThreshold: number;
  52913. /**
  52914. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  52915. */
  52916. blurWidth: number;
  52917. /**
  52918. * Sets if the blur for highlighted surfaces must be only horizontal
  52919. */
  52920. horizontalBlur: boolean;
  52921. /**
  52922. * Sets the overall exposure used by the pipeline
  52923. */
  52924. exposure: number;
  52925. /**
  52926. * Texture used typically to simulate "dirty" on camera lens
  52927. */
  52928. lensTexture: Nullable<Texture>;
  52929. /**
  52930. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  52931. */
  52932. volumetricLightCoefficient: number;
  52933. /**
  52934. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  52935. */
  52936. volumetricLightPower: number;
  52937. /**
  52938. * Used the set the blur intensity to smooth the volumetric lights
  52939. */
  52940. volumetricLightBlurScale: number;
  52941. /**
  52942. * Light (spot or directional) used to generate the volumetric lights rays
  52943. * The source light must have a shadow generate so the pipeline can get its
  52944. * depth map
  52945. */
  52946. sourceLight: Nullable<SpotLight | DirectionalLight>;
  52947. /**
  52948. * For eye adaptation, represents the minimum luminance the eye can see
  52949. */
  52950. hdrMinimumLuminance: number;
  52951. /**
  52952. * For eye adaptation, represents the decrease luminance speed
  52953. */
  52954. hdrDecreaseRate: number;
  52955. /**
  52956. * For eye adaptation, represents the increase luminance speed
  52957. */
  52958. hdrIncreaseRate: number;
  52959. /**
  52960. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  52961. */
  52962. lensColorTexture: Nullable<Texture>;
  52963. /**
  52964. * The overall strengh for the lens flare effect
  52965. */
  52966. lensFlareStrength: number;
  52967. /**
  52968. * Dispersion coefficient for lens flare ghosts
  52969. */
  52970. lensFlareGhostDispersal: number;
  52971. /**
  52972. * Main lens flare halo width
  52973. */
  52974. lensFlareHaloWidth: number;
  52975. /**
  52976. * Based on the lens distortion effect, defines how much the lens flare result
  52977. * is distorted
  52978. */
  52979. lensFlareDistortionStrength: number;
  52980. /**
  52981. * Lens star texture must be used to simulate rays on the flares and is available
  52982. * in the documentation
  52983. */
  52984. lensStarTexture: Nullable<Texture>;
  52985. /**
  52986. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  52987. * flare effect by taking account of the dirt texture
  52988. */
  52989. lensFlareDirtTexture: Nullable<Texture>;
  52990. /**
  52991. * Represents the focal length for the depth of field effect
  52992. */
  52993. depthOfFieldDistance: number;
  52994. /**
  52995. * Represents the blur intensity for the blurred part of the depth of field effect
  52996. */
  52997. depthOfFieldBlurWidth: number;
  52998. /**
  52999. * For motion blur, defines how much the image is blurred by the movement
  53000. */
  53001. motionStrength: number;
  53002. /**
  53003. * List of animations for the pipeline (IAnimatable implementation)
  53004. */
  53005. animations: Animation[];
  53006. /**
  53007. * Private members
  53008. */
  53009. private _scene;
  53010. private _currentDepthOfFieldSource;
  53011. private _basePostProcess;
  53012. private _hdrCurrentLuminance;
  53013. private _floatTextureType;
  53014. private _ratio;
  53015. private _bloomEnabled;
  53016. private _depthOfFieldEnabled;
  53017. private _vlsEnabled;
  53018. private _lensFlareEnabled;
  53019. private _hdrEnabled;
  53020. private _motionBlurEnabled;
  53021. private _fxaaEnabled;
  53022. private _motionBlurSamples;
  53023. private _volumetricLightStepsCount;
  53024. private _samples;
  53025. /**
  53026. * @ignore
  53027. * Specifies if the bloom pipeline is enabled
  53028. */
  53029. BloomEnabled: boolean;
  53030. /**
  53031. * @ignore
  53032. * Specifies if the depth of field pipeline is enabed
  53033. */
  53034. DepthOfFieldEnabled: boolean;
  53035. /**
  53036. * @ignore
  53037. * Specifies if the lens flare pipeline is enabed
  53038. */
  53039. LensFlareEnabled: boolean;
  53040. /**
  53041. * @ignore
  53042. * Specifies if the HDR pipeline is enabled
  53043. */
  53044. HDREnabled: boolean;
  53045. /**
  53046. * @ignore
  53047. * Specifies if the volumetric lights scattering effect is enabled
  53048. */
  53049. VLSEnabled: boolean;
  53050. /**
  53051. * @ignore
  53052. * Specifies if the motion blur effect is enabled
  53053. */
  53054. MotionBlurEnabled: boolean;
  53055. /**
  53056. * Specifies if anti-aliasing is enabled
  53057. */
  53058. fxaaEnabled: boolean;
  53059. /**
  53060. * Specifies the number of steps used to calculate the volumetric lights
  53061. * Typically in interval [50, 200]
  53062. */
  53063. volumetricLightStepsCount: number;
  53064. /**
  53065. * Specifies the number of samples used for the motion blur effect
  53066. * Typically in interval [16, 64]
  53067. */
  53068. motionBlurSamples: number;
  53069. /**
  53070. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53071. */
  53072. samples: number;
  53073. /**
  53074. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53075. * @constructor
  53076. * @param name The rendering pipeline name
  53077. * @param scene The scene linked to this pipeline
  53078. * @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)
  53079. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53080. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53081. */
  53082. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53083. private _buildPipeline;
  53084. private _createDownSampleX4PostProcess;
  53085. private _createBrightPassPostProcess;
  53086. private _createBlurPostProcesses;
  53087. private _createTextureAdderPostProcess;
  53088. private _createVolumetricLightPostProcess;
  53089. private _createLuminancePostProcesses;
  53090. private _createHdrPostProcess;
  53091. private _createLensFlarePostProcess;
  53092. private _createDepthOfFieldPostProcess;
  53093. private _createMotionBlurPostProcess;
  53094. private _getDepthTexture;
  53095. private _disposePostProcesses;
  53096. /**
  53097. * Dispose of the pipeline and stop all post processes
  53098. */
  53099. dispose(): void;
  53100. /**
  53101. * Serialize the rendering pipeline (Used when exporting)
  53102. * @returns the serialized object
  53103. */
  53104. serialize(): any;
  53105. /**
  53106. * Parse the serialized pipeline
  53107. * @param source Source pipeline.
  53108. * @param scene The scene to load the pipeline to.
  53109. * @param rootUrl The URL of the serialized pipeline.
  53110. * @returns An instantiated pipeline from the serialized object.
  53111. */
  53112. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53113. /**
  53114. * Luminance steps
  53115. */
  53116. static LuminanceSteps: number;
  53117. }
  53118. }
  53119. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53120. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53121. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53124. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53125. }
  53126. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53127. import { Camera } from "babylonjs/Cameras/camera";
  53128. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53129. /**
  53130. * PostProcessRenderPipelineManager class
  53131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53132. */
  53133. export class PostProcessRenderPipelineManager {
  53134. private _renderPipelines;
  53135. /**
  53136. * Initializes a PostProcessRenderPipelineManager
  53137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53138. */
  53139. constructor();
  53140. /**
  53141. * Adds a pipeline to the manager
  53142. * @param renderPipeline The pipeline to add
  53143. */
  53144. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53145. /**
  53146. * Attaches a camera to the pipeline
  53147. * @param renderPipelineName The name of the pipeline to attach to
  53148. * @param cameras the camera to attach
  53149. * @param unique if the camera can be attached multiple times to the pipeline
  53150. */
  53151. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53152. /**
  53153. * Detaches a camera from the pipeline
  53154. * @param renderPipelineName The name of the pipeline to detach from
  53155. * @param cameras the camera to detach
  53156. */
  53157. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53158. /**
  53159. * Enables an effect by name on a pipeline
  53160. * @param renderPipelineName the name of the pipeline to enable the effect in
  53161. * @param renderEffectName the name of the effect to enable
  53162. * @param cameras the cameras that the effect should be enabled on
  53163. */
  53164. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53165. /**
  53166. * Disables an effect by name on a pipeline
  53167. * @param renderPipelineName the name of the pipeline to disable the effect in
  53168. * @param renderEffectName the name of the effect to disable
  53169. * @param cameras the cameras that the effect should be disabled on
  53170. */
  53171. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53172. /**
  53173. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53174. */
  53175. update(): void;
  53176. /** @hidden */
  53177. _rebuild(): void;
  53178. /**
  53179. * Disposes of the manager and pipelines
  53180. */
  53181. dispose(): void;
  53182. }
  53183. }
  53184. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53185. import { ISceneComponent } from "babylonjs/sceneComponent";
  53186. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53187. import { Scene } from "babylonjs/scene";
  53188. module "babylonjs/scene" {
  53189. interface Scene {
  53190. /** @hidden (Backing field) */
  53191. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53192. /**
  53193. * Gets the postprocess render pipeline manager
  53194. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53195. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53196. */
  53197. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53198. }
  53199. }
  53200. /**
  53201. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53202. */
  53203. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53204. /**
  53205. * The component name helpfull to identify the component in the list of scene components.
  53206. */
  53207. readonly name: string;
  53208. /**
  53209. * The scene the component belongs to.
  53210. */
  53211. scene: Scene;
  53212. /**
  53213. * Creates a new instance of the component for the given scene
  53214. * @param scene Defines the scene to register the component in
  53215. */
  53216. constructor(scene: Scene);
  53217. /**
  53218. * Registers the component in a given scene
  53219. */
  53220. register(): void;
  53221. /**
  53222. * Rebuilds the elements related to this component in case of
  53223. * context lost for instance.
  53224. */
  53225. rebuild(): void;
  53226. /**
  53227. * Disposes the component and the associated ressources
  53228. */
  53229. dispose(): void;
  53230. private _gatherRenderTargets;
  53231. }
  53232. }
  53233. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53234. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53235. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53236. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53237. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53238. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53239. }
  53240. declare module "babylonjs/Shaders/tonemap.fragment" {
  53241. /** @hidden */
  53242. export var tonemapPixelShader: {
  53243. name: string;
  53244. shader: string;
  53245. };
  53246. }
  53247. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53248. import { Camera } from "babylonjs/Cameras/camera";
  53249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53250. import "babylonjs/Shaders/tonemap.fragment";
  53251. import { Engine } from "babylonjs/Engines/engine";
  53252. /** Defines operator used for tonemapping */
  53253. export enum TonemappingOperator {
  53254. /** Hable */
  53255. Hable = 0,
  53256. /** Reinhard */
  53257. Reinhard = 1,
  53258. /** HejiDawson */
  53259. HejiDawson = 2,
  53260. /** Photographic */
  53261. Photographic = 3
  53262. }
  53263. /**
  53264. * Defines a post process to apply tone mapping
  53265. */
  53266. export class TonemapPostProcess extends PostProcess {
  53267. private _operator;
  53268. /** Defines the required exposure adjustement */
  53269. exposureAdjustment: number;
  53270. /**
  53271. * Creates a new TonemapPostProcess
  53272. * @param name defines the name of the postprocess
  53273. * @param _operator defines the operator to use
  53274. * @param exposureAdjustment defines the required exposure adjustement
  53275. * @param camera defines the camera to use (can be null)
  53276. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53277. * @param engine defines the hosting engine (can be ignore if camera is set)
  53278. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53279. */
  53280. constructor(name: string, _operator: TonemappingOperator,
  53281. /** Defines the required exposure adjustement */
  53282. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53283. }
  53284. }
  53285. declare module "babylonjs/Shaders/depth.vertex" {
  53286. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53287. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53288. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53289. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53290. /** @hidden */
  53291. export var depthVertexShader: {
  53292. name: string;
  53293. shader: string;
  53294. };
  53295. }
  53296. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53297. /** @hidden */
  53298. export var volumetricLightScatteringPixelShader: {
  53299. name: string;
  53300. shader: string;
  53301. };
  53302. }
  53303. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53304. /** @hidden */
  53305. export var volumetricLightScatteringPassPixelShader: {
  53306. name: string;
  53307. shader: string;
  53308. };
  53309. }
  53310. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53311. import { Vector3 } from "babylonjs/Maths/math";
  53312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53313. import { Mesh } from "babylonjs/Meshes/mesh";
  53314. import { Camera } from "babylonjs/Cameras/camera";
  53315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53316. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53317. import { Scene } from "babylonjs/scene";
  53318. import "babylonjs/Shaders/depth.vertex";
  53319. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53320. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53321. import { Engine } from "babylonjs/Engines/engine";
  53322. /**
  53323. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53324. */
  53325. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53326. private _volumetricLightScatteringPass;
  53327. private _volumetricLightScatteringRTT;
  53328. private _viewPort;
  53329. private _screenCoordinates;
  53330. private _cachedDefines;
  53331. /**
  53332. * If not undefined, the mesh position is computed from the attached node position
  53333. */
  53334. attachedNode: {
  53335. position: Vector3;
  53336. };
  53337. /**
  53338. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53339. */
  53340. customMeshPosition: Vector3;
  53341. /**
  53342. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53343. */
  53344. useCustomMeshPosition: boolean;
  53345. /**
  53346. * If the post-process should inverse the light scattering direction
  53347. */
  53348. invert: boolean;
  53349. /**
  53350. * The internal mesh used by the post-process
  53351. */
  53352. mesh: Mesh;
  53353. /**
  53354. * @hidden
  53355. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53356. */
  53357. useDiffuseColor: boolean;
  53358. /**
  53359. * Array containing the excluded meshes not rendered in the internal pass
  53360. */
  53361. excludedMeshes: AbstractMesh[];
  53362. /**
  53363. * Controls the overall intensity of the post-process
  53364. */
  53365. exposure: number;
  53366. /**
  53367. * Dissipates each sample's contribution in range [0, 1]
  53368. */
  53369. decay: number;
  53370. /**
  53371. * Controls the overall intensity of each sample
  53372. */
  53373. weight: number;
  53374. /**
  53375. * Controls the density of each sample
  53376. */
  53377. density: number;
  53378. /**
  53379. * @constructor
  53380. * @param name The post-process name
  53381. * @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)
  53382. * @param camera The camera that the post-process will be attached to
  53383. * @param mesh The mesh used to create the light scattering
  53384. * @param samples The post-process quality, default 100
  53385. * @param samplingModeThe post-process filtering mode
  53386. * @param engine The babylon engine
  53387. * @param reusable If the post-process is reusable
  53388. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53389. */
  53390. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53391. /**
  53392. * Returns the string "VolumetricLightScatteringPostProcess"
  53393. * @returns "VolumetricLightScatteringPostProcess"
  53394. */
  53395. getClassName(): string;
  53396. private _isReady;
  53397. /**
  53398. * Sets the new light position for light scattering effect
  53399. * @param position The new custom light position
  53400. */
  53401. setCustomMeshPosition(position: Vector3): void;
  53402. /**
  53403. * Returns the light position for light scattering effect
  53404. * @return Vector3 The custom light position
  53405. */
  53406. getCustomMeshPosition(): Vector3;
  53407. /**
  53408. * Disposes the internal assets and detaches the post-process from the camera
  53409. */
  53410. dispose(camera: Camera): void;
  53411. /**
  53412. * Returns the render target texture used by the post-process
  53413. * @return the render target texture used by the post-process
  53414. */
  53415. getPass(): RenderTargetTexture;
  53416. private _meshExcluded;
  53417. private _createPass;
  53418. private _updateMeshScreenCoordinates;
  53419. /**
  53420. * Creates a default mesh for the Volumeric Light Scattering post-process
  53421. * @param name The mesh name
  53422. * @param scene The scene where to create the mesh
  53423. * @return the default mesh
  53424. */
  53425. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53426. }
  53427. }
  53428. declare module "babylonjs/PostProcesses/index" {
  53429. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53430. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53431. export * from "babylonjs/PostProcesses/bloomEffect";
  53432. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53433. export * from "babylonjs/PostProcesses/blurPostProcess";
  53434. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53435. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53436. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53437. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53438. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53439. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53440. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53441. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53442. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53443. export * from "babylonjs/PostProcesses/filterPostProcess";
  53444. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53445. export * from "babylonjs/PostProcesses/grainPostProcess";
  53446. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53447. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53448. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53449. export * from "babylonjs/PostProcesses/passPostProcess";
  53450. export * from "babylonjs/PostProcesses/postProcess";
  53451. export * from "babylonjs/PostProcesses/postProcessManager";
  53452. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53453. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53454. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53455. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53456. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53457. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53458. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53459. }
  53460. declare module "babylonjs/Probes/index" {
  53461. export * from "babylonjs/Probes/reflectionProbe";
  53462. }
  53463. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53464. import { Scene } from "babylonjs/scene";
  53465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53466. import { Color3 } from "babylonjs/Maths/math";
  53467. import { SmartArray } from "babylonjs/Misc/smartArray";
  53468. import { ISceneComponent } from "babylonjs/sceneComponent";
  53469. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53470. import "babylonjs/Shaders/color.fragment";
  53471. import "babylonjs/Shaders/color.vertex";
  53472. module "babylonjs/scene" {
  53473. interface Scene {
  53474. /** @hidden (Backing field) */
  53475. _boundingBoxRenderer: BoundingBoxRenderer;
  53476. /** @hidden (Backing field) */
  53477. _forceShowBoundingBoxes: boolean;
  53478. /**
  53479. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53480. */
  53481. forceShowBoundingBoxes: boolean;
  53482. /**
  53483. * Gets the bounding box renderer associated with the scene
  53484. * @returns a BoundingBoxRenderer
  53485. */
  53486. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53487. }
  53488. }
  53489. module "babylonjs/Meshes/abstractMesh" {
  53490. interface AbstractMesh {
  53491. /** @hidden (Backing field) */
  53492. _showBoundingBox: boolean;
  53493. /**
  53494. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53495. */
  53496. showBoundingBox: boolean;
  53497. }
  53498. }
  53499. /**
  53500. * Component responsible of rendering the bounding box of the meshes in a scene.
  53501. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53502. */
  53503. export class BoundingBoxRenderer implements ISceneComponent {
  53504. /**
  53505. * The component name helpfull to identify the component in the list of scene components.
  53506. */
  53507. readonly name: string;
  53508. /**
  53509. * The scene the component belongs to.
  53510. */
  53511. scene: Scene;
  53512. /**
  53513. * Color of the bounding box lines placed in front of an object
  53514. */
  53515. frontColor: Color3;
  53516. /**
  53517. * Color of the bounding box lines placed behind an object
  53518. */
  53519. backColor: Color3;
  53520. /**
  53521. * Defines if the renderer should show the back lines or not
  53522. */
  53523. showBackLines: boolean;
  53524. /**
  53525. * @hidden
  53526. */
  53527. renderList: SmartArray<BoundingBox>;
  53528. private _colorShader;
  53529. private _vertexBuffers;
  53530. private _indexBuffer;
  53531. /**
  53532. * Instantiates a new bounding box renderer in a scene.
  53533. * @param scene the scene the renderer renders in
  53534. */
  53535. constructor(scene: Scene);
  53536. /**
  53537. * Registers the component in a given scene
  53538. */
  53539. register(): void;
  53540. private _evaluateSubMesh;
  53541. private _activeMesh;
  53542. private _prepareRessources;
  53543. private _createIndexBuffer;
  53544. /**
  53545. * Rebuilds the elements related to this component in case of
  53546. * context lost for instance.
  53547. */
  53548. rebuild(): void;
  53549. /**
  53550. * @hidden
  53551. */
  53552. reset(): void;
  53553. /**
  53554. * Render the bounding boxes of a specific rendering group
  53555. * @param renderingGroupId defines the rendering group to render
  53556. */
  53557. render(renderingGroupId: number): void;
  53558. /**
  53559. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53560. * @param mesh Define the mesh to render the occlusion bounding box for
  53561. */
  53562. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53563. /**
  53564. * Dispose and release the resources attached to this renderer.
  53565. */
  53566. dispose(): void;
  53567. }
  53568. }
  53569. declare module "babylonjs/Shaders/depth.fragment" {
  53570. /** @hidden */
  53571. export var depthPixelShader: {
  53572. name: string;
  53573. shader: string;
  53574. };
  53575. }
  53576. declare module "babylonjs/Rendering/depthRenderer" {
  53577. import { Nullable } from "babylonjs/types";
  53578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53579. import { Scene } from "babylonjs/scene";
  53580. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53581. import { Camera } from "babylonjs/Cameras/camera";
  53582. import "babylonjs/Shaders/depth.fragment";
  53583. import "babylonjs/Shaders/depth.vertex";
  53584. /**
  53585. * This represents a depth renderer in Babylon.
  53586. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53587. */
  53588. export class DepthRenderer {
  53589. private _scene;
  53590. private _depthMap;
  53591. private _effect;
  53592. private _cachedDefines;
  53593. private _camera;
  53594. /**
  53595. * Specifiess that the depth renderer will only be used within
  53596. * the camera it is created for.
  53597. * This can help forcing its rendering during the camera processing.
  53598. */
  53599. useOnlyInActiveCamera: boolean;
  53600. /** @hidden */
  53601. static _SceneComponentInitialization: (scene: Scene) => void;
  53602. /**
  53603. * Instantiates a depth renderer
  53604. * @param scene The scene the renderer belongs to
  53605. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53606. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53607. */
  53608. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53609. /**
  53610. * Creates the depth rendering effect and checks if the effect is ready.
  53611. * @param subMesh The submesh to be used to render the depth map of
  53612. * @param useInstances If multiple world instances should be used
  53613. * @returns if the depth renderer is ready to render the depth map
  53614. */
  53615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53616. /**
  53617. * Gets the texture which the depth map will be written to.
  53618. * @returns The depth map texture
  53619. */
  53620. getDepthMap(): RenderTargetTexture;
  53621. /**
  53622. * Disposes of the depth renderer.
  53623. */
  53624. dispose(): void;
  53625. }
  53626. }
  53627. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  53628. import { Nullable } from "babylonjs/types";
  53629. import { Scene } from "babylonjs/scene";
  53630. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  53631. import { Camera } from "babylonjs/Cameras/camera";
  53632. import { ISceneComponent } from "babylonjs/sceneComponent";
  53633. module "babylonjs/scene" {
  53634. interface Scene {
  53635. /** @hidden (Backing field) */
  53636. _depthRenderer: {
  53637. [id: string]: DepthRenderer;
  53638. };
  53639. /**
  53640. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53641. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53642. * @returns the created depth renderer
  53643. */
  53644. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53645. /**
  53646. * Disables a depth renderer for a given camera
  53647. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53648. */
  53649. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53650. }
  53651. }
  53652. /**
  53653. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53654. * in several rendering techniques.
  53655. */
  53656. export class DepthRendererSceneComponent implements ISceneComponent {
  53657. /**
  53658. * The component name helpfull to identify the component in the list of scene components.
  53659. */
  53660. readonly name: string;
  53661. /**
  53662. * The scene the component belongs to.
  53663. */
  53664. scene: Scene;
  53665. /**
  53666. * Creates a new instance of the component for the given scene
  53667. * @param scene Defines the scene to register the component in
  53668. */
  53669. constructor(scene: Scene);
  53670. /**
  53671. * Registers the component in a given scene
  53672. */
  53673. register(): void;
  53674. /**
  53675. * Rebuilds the elements related to this component in case of
  53676. * context lost for instance.
  53677. */
  53678. rebuild(): void;
  53679. /**
  53680. * Disposes the component and the associated ressources
  53681. */
  53682. dispose(): void;
  53683. private _gatherRenderTargets;
  53684. private _gatherActiveCameraRenderTargets;
  53685. }
  53686. }
  53687. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53688. import { Nullable } from "babylonjs/types";
  53689. import { Scene } from "babylonjs/scene";
  53690. import { ISceneComponent } from "babylonjs/sceneComponent";
  53691. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53692. module "babylonjs/scene" {
  53693. interface Scene {
  53694. /** @hidden (Backing field) */
  53695. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53696. /**
  53697. * Gets or Sets the current geometry buffer associated to the scene.
  53698. */
  53699. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53700. /**
  53701. * Enables a GeometryBufferRender and associates it with the scene
  53702. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53703. * @returns the GeometryBufferRenderer
  53704. */
  53705. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53706. /**
  53707. * Disables the GeometryBufferRender associated with the scene
  53708. */
  53709. disableGeometryBufferRenderer(): void;
  53710. }
  53711. }
  53712. /**
  53713. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53714. * in several rendering techniques.
  53715. */
  53716. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53717. /**
  53718. * The component name helpful to identify the component in the list of scene components.
  53719. */
  53720. readonly name: string;
  53721. /**
  53722. * The scene the component belongs to.
  53723. */
  53724. scene: Scene;
  53725. /**
  53726. * Creates a new instance of the component for the given scene
  53727. * @param scene Defines the scene to register the component in
  53728. */
  53729. constructor(scene: Scene);
  53730. /**
  53731. * Registers the component in a given scene
  53732. */
  53733. register(): void;
  53734. /**
  53735. * Rebuilds the elements related to this component in case of
  53736. * context lost for instance.
  53737. */
  53738. rebuild(): void;
  53739. /**
  53740. * Disposes the component and the associated ressources
  53741. */
  53742. dispose(): void;
  53743. private _gatherRenderTargets;
  53744. }
  53745. }
  53746. declare module "babylonjs/Shaders/outline.fragment" {
  53747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53748. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53749. /** @hidden */
  53750. export var outlinePixelShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module "babylonjs/Shaders/outline.vertex" {
  53756. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53757. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53758. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53759. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53760. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53761. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53762. /** @hidden */
  53763. export var outlineVertexShader: {
  53764. name: string;
  53765. shader: string;
  53766. };
  53767. }
  53768. declare module "babylonjs/Rendering/outlineRenderer" {
  53769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53770. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  53771. import { Scene } from "babylonjs/scene";
  53772. import { ISceneComponent } from "babylonjs/sceneComponent";
  53773. import "babylonjs/Shaders/outline.fragment";
  53774. import "babylonjs/Shaders/outline.vertex";
  53775. module "babylonjs/scene" {
  53776. interface Scene {
  53777. /** @hidden */
  53778. _outlineRenderer: OutlineRenderer;
  53779. /**
  53780. * Gets the outline renderer associated with the scene
  53781. * @returns a OutlineRenderer
  53782. */
  53783. getOutlineRenderer(): OutlineRenderer;
  53784. }
  53785. }
  53786. module "babylonjs/Meshes/abstractMesh" {
  53787. interface AbstractMesh {
  53788. /** @hidden (Backing field) */
  53789. _renderOutline: boolean;
  53790. /**
  53791. * Gets or sets a boolean indicating if the outline must be rendered as well
  53792. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53793. */
  53794. renderOutline: boolean;
  53795. /** @hidden (Backing field) */
  53796. _renderOverlay: boolean;
  53797. /**
  53798. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53799. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53800. */
  53801. renderOverlay: boolean;
  53802. }
  53803. }
  53804. /**
  53805. * This class is responsible to draw bothe outline/overlay of meshes.
  53806. * It should not be used directly but through the available method on mesh.
  53807. */
  53808. export class OutlineRenderer implements ISceneComponent {
  53809. /**
  53810. * The name of the component. Each component must have a unique name.
  53811. */
  53812. name: string;
  53813. /**
  53814. * The scene the component belongs to.
  53815. */
  53816. scene: Scene;
  53817. /**
  53818. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53819. */
  53820. zOffset: number;
  53821. private _engine;
  53822. private _effect;
  53823. private _cachedDefines;
  53824. private _savedDepthWrite;
  53825. /**
  53826. * Instantiates a new outline renderer. (There could be only one per scene).
  53827. * @param scene Defines the scene it belongs to
  53828. */
  53829. constructor(scene: Scene);
  53830. /**
  53831. * Register the component to one instance of a scene.
  53832. */
  53833. register(): void;
  53834. /**
  53835. * Rebuilds the elements related to this component in case of
  53836. * context lost for instance.
  53837. */
  53838. rebuild(): void;
  53839. /**
  53840. * Disposes the component and the associated ressources.
  53841. */
  53842. dispose(): void;
  53843. /**
  53844. * Renders the outline in the canvas.
  53845. * @param subMesh Defines the sumesh to render
  53846. * @param batch Defines the batch of meshes in case of instances
  53847. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53848. */
  53849. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53850. /**
  53851. * Returns whether or not the outline renderer is ready for a given submesh.
  53852. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53853. * @param subMesh Defines the submesh to check readyness for
  53854. * @param useInstances Defines wheter wee are trying to render instances or not
  53855. * @returns true if ready otherwise false
  53856. */
  53857. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53858. private _beforeRenderingMesh;
  53859. private _afterRenderingMesh;
  53860. }
  53861. }
  53862. declare module "babylonjs/Rendering/index" {
  53863. export * from "babylonjs/Rendering/boundingBoxRenderer";
  53864. export * from "babylonjs/Rendering/depthRenderer";
  53865. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  53866. export * from "babylonjs/Rendering/edgesRenderer";
  53867. export * from "babylonjs/Rendering/geometryBufferRenderer";
  53868. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53869. export * from "babylonjs/Rendering/outlineRenderer";
  53870. export * from "babylonjs/Rendering/renderingGroup";
  53871. export * from "babylonjs/Rendering/renderingManager";
  53872. export * from "babylonjs/Rendering/utilityLayerRenderer";
  53873. }
  53874. declare module "babylonjs/Sprites/index" {
  53875. export * from "babylonjs/Sprites/sprite";
  53876. export * from "babylonjs/Sprites/spriteManager";
  53877. export * from "babylonjs/Sprites/spriteSceneComponent";
  53878. }
  53879. declare module "babylonjs/Misc/assetsManager" {
  53880. import { Scene } from "babylonjs/scene";
  53881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53882. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53883. import { Skeleton } from "babylonjs/Bones/skeleton";
  53884. import { Observable } from "babylonjs/Misc/observable";
  53885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53886. import { Texture } from "babylonjs/Materials/Textures/texture";
  53887. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53888. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  53889. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53890. /**
  53891. * Defines the list of states available for a task inside a AssetsManager
  53892. */
  53893. export enum AssetTaskState {
  53894. /**
  53895. * Initialization
  53896. */
  53897. INIT = 0,
  53898. /**
  53899. * Running
  53900. */
  53901. RUNNING = 1,
  53902. /**
  53903. * Done
  53904. */
  53905. DONE = 2,
  53906. /**
  53907. * Error
  53908. */
  53909. ERROR = 3
  53910. }
  53911. /**
  53912. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53913. */
  53914. export abstract class AbstractAssetTask {
  53915. /**
  53916. * Task name
  53917. */ name: string;
  53918. /**
  53919. * Callback called when the task is successful
  53920. */
  53921. onSuccess: (task: any) => void;
  53922. /**
  53923. * Callback called when the task is not successful
  53924. */
  53925. onError: (task: any, message?: string, exception?: any) => void;
  53926. /**
  53927. * Creates a new AssetsManager
  53928. * @param name defines the name of the task
  53929. */
  53930. constructor(
  53931. /**
  53932. * Task name
  53933. */ name: string);
  53934. private _isCompleted;
  53935. private _taskState;
  53936. private _errorObject;
  53937. /**
  53938. * Get if the task is completed
  53939. */
  53940. readonly isCompleted: boolean;
  53941. /**
  53942. * Gets the current state of the task
  53943. */
  53944. readonly taskState: AssetTaskState;
  53945. /**
  53946. * Gets the current error object (if task is in error)
  53947. */
  53948. readonly errorObject: {
  53949. message?: string;
  53950. exception?: any;
  53951. };
  53952. /**
  53953. * Internal only
  53954. * @hidden
  53955. */
  53956. _setErrorObject(message?: string, exception?: any): void;
  53957. /**
  53958. * Execute the current task
  53959. * @param scene defines the scene where you want your assets to be loaded
  53960. * @param onSuccess is a callback called when the task is successfully executed
  53961. * @param onError is a callback called if an error occurs
  53962. */
  53963. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53964. /**
  53965. * Execute the current task
  53966. * @param scene defines the scene where you want your assets to be loaded
  53967. * @param onSuccess is a callback called when the task is successfully executed
  53968. * @param onError is a callback called if an error occurs
  53969. */
  53970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53971. /**
  53972. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53973. * This can be used with failed tasks that have the reason for failure fixed.
  53974. */
  53975. reset(): void;
  53976. private onErrorCallback;
  53977. private onDoneCallback;
  53978. }
  53979. /**
  53980. * Define the interface used by progress events raised during assets loading
  53981. */
  53982. export interface IAssetsProgressEvent {
  53983. /**
  53984. * Defines the number of remaining tasks to process
  53985. */
  53986. remainingCount: number;
  53987. /**
  53988. * Defines the total number of tasks
  53989. */
  53990. totalCount: number;
  53991. /**
  53992. * Defines the task that was just processed
  53993. */
  53994. task: AbstractAssetTask;
  53995. }
  53996. /**
  53997. * Class used to share progress information about assets loading
  53998. */
  53999. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54000. /**
  54001. * Defines the number of remaining tasks to process
  54002. */
  54003. remainingCount: number;
  54004. /**
  54005. * Defines the total number of tasks
  54006. */
  54007. totalCount: number;
  54008. /**
  54009. * Defines the task that was just processed
  54010. */
  54011. task: AbstractAssetTask;
  54012. /**
  54013. * Creates a AssetsProgressEvent
  54014. * @param remainingCount defines the number of remaining tasks to process
  54015. * @param totalCount defines the total number of tasks
  54016. * @param task defines the task that was just processed
  54017. */
  54018. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54019. }
  54020. /**
  54021. * Define a task used by AssetsManager to load meshes
  54022. */
  54023. export class MeshAssetTask extends AbstractAssetTask {
  54024. /**
  54025. * Defines the name of the task
  54026. */
  54027. name: string;
  54028. /**
  54029. * Defines the list of mesh's names you want to load
  54030. */
  54031. meshesNames: any;
  54032. /**
  54033. * Defines the root url to use as a base to load your meshes and associated resources
  54034. */
  54035. rootUrl: string;
  54036. /**
  54037. * Defines the filename of the scene to load from
  54038. */
  54039. sceneFilename: string;
  54040. /**
  54041. * Gets the list of loaded meshes
  54042. */
  54043. loadedMeshes: Array<AbstractMesh>;
  54044. /**
  54045. * Gets the list of loaded particle systems
  54046. */
  54047. loadedParticleSystems: Array<IParticleSystem>;
  54048. /**
  54049. * Gets the list of loaded skeletons
  54050. */
  54051. loadedSkeletons: Array<Skeleton>;
  54052. /**
  54053. * Gets the list of loaded animation groups
  54054. */
  54055. loadedAnimationGroups: Array<AnimationGroup>;
  54056. /**
  54057. * Callback called when the task is successful
  54058. */
  54059. onSuccess: (task: MeshAssetTask) => void;
  54060. /**
  54061. * Callback called when the task is successful
  54062. */
  54063. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54064. /**
  54065. * Creates a new MeshAssetTask
  54066. * @param name defines the name of the task
  54067. * @param meshesNames defines the list of mesh's names you want to load
  54068. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54069. * @param sceneFilename defines the filename of the scene to load from
  54070. */
  54071. constructor(
  54072. /**
  54073. * Defines the name of the task
  54074. */
  54075. name: string,
  54076. /**
  54077. * Defines the list of mesh's names you want to load
  54078. */
  54079. meshesNames: any,
  54080. /**
  54081. * Defines the root url to use as a base to load your meshes and associated resources
  54082. */
  54083. rootUrl: string,
  54084. /**
  54085. * Defines the filename of the scene to load from
  54086. */
  54087. sceneFilename: string);
  54088. /**
  54089. * Execute the current task
  54090. * @param scene defines the scene where you want your assets to be loaded
  54091. * @param onSuccess is a callback called when the task is successfully executed
  54092. * @param onError is a callback called if an error occurs
  54093. */
  54094. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54095. }
  54096. /**
  54097. * Define a task used by AssetsManager to load text content
  54098. */
  54099. export class TextFileAssetTask extends AbstractAssetTask {
  54100. /**
  54101. * Defines the name of the task
  54102. */
  54103. name: string;
  54104. /**
  54105. * Defines the location of the file to load
  54106. */
  54107. url: string;
  54108. /**
  54109. * Gets the loaded text string
  54110. */
  54111. text: string;
  54112. /**
  54113. * Callback called when the task is successful
  54114. */
  54115. onSuccess: (task: TextFileAssetTask) => void;
  54116. /**
  54117. * Callback called when the task is successful
  54118. */
  54119. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54120. /**
  54121. * Creates a new TextFileAssetTask object
  54122. * @param name defines the name of the task
  54123. * @param url defines the location of the file to load
  54124. */
  54125. constructor(
  54126. /**
  54127. * Defines the name of the task
  54128. */
  54129. name: string,
  54130. /**
  54131. * Defines the location of the file to load
  54132. */
  54133. url: string);
  54134. /**
  54135. * Execute the current task
  54136. * @param scene defines the scene where you want your assets to be loaded
  54137. * @param onSuccess is a callback called when the task is successfully executed
  54138. * @param onError is a callback called if an error occurs
  54139. */
  54140. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54141. }
  54142. /**
  54143. * Define a task used by AssetsManager to load binary data
  54144. */
  54145. export class BinaryFileAssetTask extends AbstractAssetTask {
  54146. /**
  54147. * Defines the name of the task
  54148. */
  54149. name: string;
  54150. /**
  54151. * Defines the location of the file to load
  54152. */
  54153. url: string;
  54154. /**
  54155. * Gets the lodaded data (as an array buffer)
  54156. */
  54157. data: ArrayBuffer;
  54158. /**
  54159. * Callback called when the task is successful
  54160. */
  54161. onSuccess: (task: BinaryFileAssetTask) => void;
  54162. /**
  54163. * Callback called when the task is successful
  54164. */
  54165. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54166. /**
  54167. * Creates a new BinaryFileAssetTask object
  54168. * @param name defines the name of the new task
  54169. * @param url defines the location of the file to load
  54170. */
  54171. constructor(
  54172. /**
  54173. * Defines the name of the task
  54174. */
  54175. name: string,
  54176. /**
  54177. * Defines the location of the file to load
  54178. */
  54179. url: string);
  54180. /**
  54181. * Execute the current task
  54182. * @param scene defines the scene where you want your assets to be loaded
  54183. * @param onSuccess is a callback called when the task is successfully executed
  54184. * @param onError is a callback called if an error occurs
  54185. */
  54186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54187. }
  54188. /**
  54189. * Define a task used by AssetsManager to load images
  54190. */
  54191. export class ImageAssetTask extends AbstractAssetTask {
  54192. /**
  54193. * Defines the name of the task
  54194. */
  54195. name: string;
  54196. /**
  54197. * Defines the location of the image to load
  54198. */
  54199. url: string;
  54200. /**
  54201. * Gets the loaded images
  54202. */
  54203. image: HTMLImageElement;
  54204. /**
  54205. * Callback called when the task is successful
  54206. */
  54207. onSuccess: (task: ImageAssetTask) => void;
  54208. /**
  54209. * Callback called when the task is successful
  54210. */
  54211. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54212. /**
  54213. * Creates a new ImageAssetTask
  54214. * @param name defines the name of the task
  54215. * @param url defines the location of the image to load
  54216. */
  54217. constructor(
  54218. /**
  54219. * Defines the name of the task
  54220. */
  54221. name: string,
  54222. /**
  54223. * Defines the location of the image to load
  54224. */
  54225. url: string);
  54226. /**
  54227. * Execute the current task
  54228. * @param scene defines the scene where you want your assets to be loaded
  54229. * @param onSuccess is a callback called when the task is successfully executed
  54230. * @param onError is a callback called if an error occurs
  54231. */
  54232. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54233. }
  54234. /**
  54235. * Defines the interface used by texture loading tasks
  54236. */
  54237. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54238. /**
  54239. * Gets the loaded texture
  54240. */
  54241. texture: TEX;
  54242. }
  54243. /**
  54244. * Define a task used by AssetsManager to load 2D textures
  54245. */
  54246. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54247. /**
  54248. * Defines the name of the task
  54249. */
  54250. name: string;
  54251. /**
  54252. * Defines the location of the file to load
  54253. */
  54254. url: string;
  54255. /**
  54256. * Defines if mipmap should not be generated (default is false)
  54257. */
  54258. noMipmap?: boolean | undefined;
  54259. /**
  54260. * Defines if texture must be inverted on Y axis (default is false)
  54261. */
  54262. invertY?: boolean | undefined;
  54263. /**
  54264. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54265. */
  54266. samplingMode: number;
  54267. /**
  54268. * Gets the loaded texture
  54269. */
  54270. texture: Texture;
  54271. /**
  54272. * Callback called when the task is successful
  54273. */
  54274. onSuccess: (task: TextureAssetTask) => void;
  54275. /**
  54276. * Callback called when the task is successful
  54277. */
  54278. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54279. /**
  54280. * Creates a new TextureAssetTask object
  54281. * @param name defines the name of the task
  54282. * @param url defines the location of the file to load
  54283. * @param noMipmap defines if mipmap should not be generated (default is false)
  54284. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54285. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54286. */
  54287. constructor(
  54288. /**
  54289. * Defines the name of the task
  54290. */
  54291. name: string,
  54292. /**
  54293. * Defines the location of the file to load
  54294. */
  54295. url: string,
  54296. /**
  54297. * Defines if mipmap should not be generated (default is false)
  54298. */
  54299. noMipmap?: boolean | undefined,
  54300. /**
  54301. * Defines if texture must be inverted on Y axis (default is false)
  54302. */
  54303. invertY?: boolean | undefined,
  54304. /**
  54305. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54306. */
  54307. samplingMode?: number);
  54308. /**
  54309. * Execute the current task
  54310. * @param scene defines the scene where you want your assets to be loaded
  54311. * @param onSuccess is a callback called when the task is successfully executed
  54312. * @param onError is a callback called if an error occurs
  54313. */
  54314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54315. }
  54316. /**
  54317. * Define a task used by AssetsManager to load cube textures
  54318. */
  54319. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54320. /**
  54321. * Defines the name of the task
  54322. */
  54323. name: string;
  54324. /**
  54325. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54326. */
  54327. url: string;
  54328. /**
  54329. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54330. */
  54331. extensions?: string[] | undefined;
  54332. /**
  54333. * Defines if mipmaps should not be generated (default is false)
  54334. */
  54335. noMipmap?: boolean | undefined;
  54336. /**
  54337. * Defines the explicit list of files (undefined by default)
  54338. */
  54339. files?: string[] | undefined;
  54340. /**
  54341. * Gets the loaded texture
  54342. */
  54343. texture: CubeTexture;
  54344. /**
  54345. * Callback called when the task is successful
  54346. */
  54347. onSuccess: (task: CubeTextureAssetTask) => void;
  54348. /**
  54349. * Callback called when the task is successful
  54350. */
  54351. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54352. /**
  54353. * Creates a new CubeTextureAssetTask
  54354. * @param name defines the name of the task
  54355. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54356. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54357. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54358. * @param files defines the explicit list of files (undefined by default)
  54359. */
  54360. constructor(
  54361. /**
  54362. * Defines the name of the task
  54363. */
  54364. name: string,
  54365. /**
  54366. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54367. */
  54368. url: string,
  54369. /**
  54370. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54371. */
  54372. extensions?: string[] | undefined,
  54373. /**
  54374. * Defines if mipmaps should not be generated (default is false)
  54375. */
  54376. noMipmap?: boolean | undefined,
  54377. /**
  54378. * Defines the explicit list of files (undefined by default)
  54379. */
  54380. files?: string[] | undefined);
  54381. /**
  54382. * Execute the current task
  54383. * @param scene defines the scene where you want your assets to be loaded
  54384. * @param onSuccess is a callback called when the task is successfully executed
  54385. * @param onError is a callback called if an error occurs
  54386. */
  54387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54388. }
  54389. /**
  54390. * Define a task used by AssetsManager to load HDR cube textures
  54391. */
  54392. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54393. /**
  54394. * Defines the name of the task
  54395. */
  54396. name: string;
  54397. /**
  54398. * Defines the location of the file to load
  54399. */
  54400. url: string;
  54401. /**
  54402. * Defines the desired size (the more it increases the longer the generation will be)
  54403. */
  54404. size: number;
  54405. /**
  54406. * Defines if mipmaps should not be generated (default is false)
  54407. */
  54408. noMipmap: boolean;
  54409. /**
  54410. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54411. */
  54412. generateHarmonics: boolean;
  54413. /**
  54414. * 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)
  54415. */
  54416. gammaSpace: boolean;
  54417. /**
  54418. * Internal Use Only
  54419. */
  54420. reserved: boolean;
  54421. /**
  54422. * Gets the loaded texture
  54423. */
  54424. texture: HDRCubeTexture;
  54425. /**
  54426. * Callback called when the task is successful
  54427. */
  54428. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54429. /**
  54430. * Callback called when the task is successful
  54431. */
  54432. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54433. /**
  54434. * Creates a new HDRCubeTextureAssetTask object
  54435. * @param name defines the name of the task
  54436. * @param url defines the location of the file to load
  54437. * @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.
  54438. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54439. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54440. * @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)
  54441. * @param reserved Internal use only
  54442. */
  54443. constructor(
  54444. /**
  54445. * Defines the name of the task
  54446. */
  54447. name: string,
  54448. /**
  54449. * Defines the location of the file to load
  54450. */
  54451. url: string,
  54452. /**
  54453. * Defines the desired size (the more it increases the longer the generation will be)
  54454. */
  54455. size: number,
  54456. /**
  54457. * Defines if mipmaps should not be generated (default is false)
  54458. */
  54459. noMipmap?: boolean,
  54460. /**
  54461. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54462. */
  54463. generateHarmonics?: boolean,
  54464. /**
  54465. * 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)
  54466. */
  54467. gammaSpace?: boolean,
  54468. /**
  54469. * Internal Use Only
  54470. */
  54471. reserved?: boolean);
  54472. /**
  54473. * Execute the current task
  54474. * @param scene defines the scene where you want your assets to be loaded
  54475. * @param onSuccess is a callback called when the task is successfully executed
  54476. * @param onError is a callback called if an error occurs
  54477. */
  54478. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54479. }
  54480. /**
  54481. * This class can be used to easily import assets into a scene
  54482. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54483. */
  54484. export class AssetsManager {
  54485. private _scene;
  54486. private _isLoading;
  54487. protected _tasks: AbstractAssetTask[];
  54488. protected _waitingTasksCount: number;
  54489. protected _totalTasksCount: number;
  54490. /**
  54491. * Callback called when all tasks are processed
  54492. */
  54493. onFinish: (tasks: AbstractAssetTask[]) => void;
  54494. /**
  54495. * Callback called when a task is successful
  54496. */
  54497. onTaskSuccess: (task: AbstractAssetTask) => void;
  54498. /**
  54499. * Callback called when a task had an error
  54500. */
  54501. onTaskError: (task: AbstractAssetTask) => void;
  54502. /**
  54503. * Callback called when a task is done (whatever the result is)
  54504. */
  54505. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54506. /**
  54507. * Observable called when all tasks are processed
  54508. */
  54509. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54510. /**
  54511. * Observable called when a task had an error
  54512. */
  54513. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54514. /**
  54515. * Observable called when a task is successful
  54516. */
  54517. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54518. /**
  54519. * Observable called when a task is done (whatever the result is)
  54520. */
  54521. onProgressObservable: Observable<IAssetsProgressEvent>;
  54522. /**
  54523. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54525. */
  54526. useDefaultLoadingScreen: boolean;
  54527. /**
  54528. * Creates a new AssetsManager
  54529. * @param scene defines the scene to work on
  54530. */
  54531. constructor(scene: Scene);
  54532. /**
  54533. * Add a MeshAssetTask to the list of active tasks
  54534. * @param taskName defines the name of the new task
  54535. * @param meshesNames defines the name of meshes to load
  54536. * @param rootUrl defines the root url to use to locate files
  54537. * @param sceneFilename defines the filename of the scene file
  54538. * @returns a new MeshAssetTask object
  54539. */
  54540. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54541. /**
  54542. * Add a TextFileAssetTask to the list of active tasks
  54543. * @param taskName defines the name of the new task
  54544. * @param url defines the url of the file to load
  54545. * @returns a new TextFileAssetTask object
  54546. */
  54547. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54548. /**
  54549. * Add a BinaryFileAssetTask to the list of active tasks
  54550. * @param taskName defines the name of the new task
  54551. * @param url defines the url of the file to load
  54552. * @returns a new BinaryFileAssetTask object
  54553. */
  54554. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54555. /**
  54556. * Add a ImageAssetTask to the list of active tasks
  54557. * @param taskName defines the name of the new task
  54558. * @param url defines the url of the file to load
  54559. * @returns a new ImageAssetTask object
  54560. */
  54561. addImageTask(taskName: string, url: string): ImageAssetTask;
  54562. /**
  54563. * Add a TextureAssetTask to the list of active tasks
  54564. * @param taskName defines the name of the new task
  54565. * @param url defines the url of the file to load
  54566. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54567. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54568. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54569. * @returns a new TextureAssetTask object
  54570. */
  54571. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54572. /**
  54573. * Add a CubeTextureAssetTask to the list of active tasks
  54574. * @param taskName defines the name of the new task
  54575. * @param url defines the url of the file to load
  54576. * @param extensions defines the extension to use to load the cube map (can be null)
  54577. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54578. * @param files defines the list of files to load (can be null)
  54579. * @returns a new CubeTextureAssetTask object
  54580. */
  54581. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54582. /**
  54583. *
  54584. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54585. * @param taskName defines the name of the new task
  54586. * @param url defines the url of the file to load
  54587. * @param size defines the size you want for the cubemap (can be null)
  54588. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54589. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54590. * @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)
  54591. * @param reserved Internal use only
  54592. * @returns a new HDRCubeTextureAssetTask object
  54593. */
  54594. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54595. /**
  54596. * Remove a task from the assets manager.
  54597. * @param task the task to remove
  54598. */
  54599. removeTask(task: AbstractAssetTask): void;
  54600. private _decreaseWaitingTasksCount;
  54601. private _runTask;
  54602. /**
  54603. * Reset the AssetsManager and remove all tasks
  54604. * @return the current instance of the AssetsManager
  54605. */
  54606. reset(): AssetsManager;
  54607. /**
  54608. * Start the loading process
  54609. * @return the current instance of the AssetsManager
  54610. */
  54611. load(): AssetsManager;
  54612. }
  54613. }
  54614. declare module "babylonjs/Misc/deferred" {
  54615. /**
  54616. * Wrapper class for promise with external resolve and reject.
  54617. */
  54618. export class Deferred<T> {
  54619. /**
  54620. * The promise associated with this deferred object.
  54621. */
  54622. readonly promise: Promise<T>;
  54623. private _resolve;
  54624. private _reject;
  54625. /**
  54626. * The resolve method of the promise associated with this deferred object.
  54627. */
  54628. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54629. /**
  54630. * The reject method of the promise associated with this deferred object.
  54631. */
  54632. readonly reject: (reason?: any) => void;
  54633. /**
  54634. * Constructor for this deferred object.
  54635. */
  54636. constructor();
  54637. }
  54638. }
  54639. declare module "babylonjs/Misc/filesInput" {
  54640. import { Engine } from "babylonjs/Engines/engine";
  54641. import { Scene } from "babylonjs/scene";
  54642. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  54643. /**
  54644. * Class used to help managing file picking and drag'n'drop
  54645. */
  54646. export class FilesInput {
  54647. /**
  54648. * List of files ready to be loaded
  54649. */
  54650. static readonly FilesToLoad: {
  54651. [key: string]: File;
  54652. };
  54653. /**
  54654. * Callback called when a file is processed
  54655. */
  54656. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54657. private _engine;
  54658. private _currentScene;
  54659. private _sceneLoadedCallback;
  54660. private _progressCallback;
  54661. private _additionalRenderLoopLogicCallback;
  54662. private _textureLoadingCallback;
  54663. private _startingProcessingFilesCallback;
  54664. private _onReloadCallback;
  54665. private _errorCallback;
  54666. private _elementToMonitor;
  54667. private _sceneFileToLoad;
  54668. private _filesToLoad;
  54669. /**
  54670. * Creates a new FilesInput
  54671. * @param engine defines the rendering engine
  54672. * @param scene defines the hosting scene
  54673. * @param sceneLoadedCallback callback called when scene is loaded
  54674. * @param progressCallback callback called to track progress
  54675. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54676. * @param textureLoadingCallback callback called when a texture is loading
  54677. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54678. * @param onReloadCallback callback called when a reload is requested
  54679. * @param errorCallback callback call if an error occurs
  54680. */
  54681. 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);
  54682. private _dragEnterHandler;
  54683. private _dragOverHandler;
  54684. private _dropHandler;
  54685. /**
  54686. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54687. * @param elementToMonitor defines the DOM element to track
  54688. */
  54689. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54690. /**
  54691. * Release all associated resources
  54692. */
  54693. dispose(): void;
  54694. private renderFunction;
  54695. private drag;
  54696. private drop;
  54697. private _traverseFolder;
  54698. private _processFiles;
  54699. /**
  54700. * Load files from a drop event
  54701. * @param event defines the drop event to use as source
  54702. */
  54703. loadFiles(event: any): void;
  54704. private _processReload;
  54705. /**
  54706. * Reload the current scene from the loaded files
  54707. */
  54708. reload(): void;
  54709. }
  54710. }
  54711. declare module "babylonjs/Misc/HighDynamicRange/index" {
  54712. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  54713. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  54714. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54715. }
  54716. declare module "babylonjs/Misc/sceneOptimizer" {
  54717. import { Scene, IDisposable } from "babylonjs/scene";
  54718. import { Observable } from "babylonjs/Misc/observable";
  54719. /**
  54720. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54722. */
  54723. export class SceneOptimization {
  54724. /**
  54725. * Defines the priority of this optimization (0 by default which means first in the list)
  54726. */
  54727. priority: number;
  54728. /**
  54729. * Gets a string describing the action executed by the current optimization
  54730. * @returns description string
  54731. */
  54732. getDescription(): string;
  54733. /**
  54734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54735. * @param scene defines the current scene where to apply this optimization
  54736. * @param optimizer defines the current optimizer
  54737. * @returns true if everything that can be done was applied
  54738. */
  54739. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54740. /**
  54741. * Creates the SceneOptimization object
  54742. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54743. * @param desc defines the description associated with the optimization
  54744. */
  54745. constructor(
  54746. /**
  54747. * Defines the priority of this optimization (0 by default which means first in the list)
  54748. */
  54749. priority?: number);
  54750. }
  54751. /**
  54752. * Defines an optimization used to reduce the size of render target textures
  54753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54754. */
  54755. export class TextureOptimization extends SceneOptimization {
  54756. /**
  54757. * Defines the priority of this optimization (0 by default which means first in the list)
  54758. */
  54759. priority: number;
  54760. /**
  54761. * 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
  54762. */
  54763. maximumSize: number;
  54764. /**
  54765. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54766. */
  54767. step: number;
  54768. /**
  54769. * Gets a string describing the action executed by the current optimization
  54770. * @returns description string
  54771. */
  54772. getDescription(): string;
  54773. /**
  54774. * Creates the TextureOptimization object
  54775. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54776. * @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
  54777. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54778. */
  54779. constructor(
  54780. /**
  54781. * Defines the priority of this optimization (0 by default which means first in the list)
  54782. */
  54783. priority?: number,
  54784. /**
  54785. * 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
  54786. */
  54787. maximumSize?: number,
  54788. /**
  54789. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54790. */
  54791. step?: number);
  54792. /**
  54793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54794. * @param scene defines the current scene where to apply this optimization
  54795. * @param optimizer defines the current optimizer
  54796. * @returns true if everything that can be done was applied
  54797. */
  54798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54799. }
  54800. /**
  54801. * Defines an optimization used to increase or decrease the rendering resolution
  54802. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54803. */
  54804. export class HardwareScalingOptimization extends SceneOptimization {
  54805. /**
  54806. * Defines the priority of this optimization (0 by default which means first in the list)
  54807. */
  54808. priority: number;
  54809. /**
  54810. * Defines the maximum scale to use (2 by default)
  54811. */
  54812. maximumScale: number;
  54813. /**
  54814. * Defines the step to use between two passes (0.5 by default)
  54815. */
  54816. step: number;
  54817. private _currentScale;
  54818. private _directionOffset;
  54819. /**
  54820. * Gets a string describing the action executed by the current optimization
  54821. * @return description string
  54822. */
  54823. getDescription(): string;
  54824. /**
  54825. * Creates the HardwareScalingOptimization object
  54826. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54827. * @param maximumScale defines the maximum scale to use (2 by default)
  54828. * @param step defines the step to use between two passes (0.5 by default)
  54829. */
  54830. constructor(
  54831. /**
  54832. * Defines the priority of this optimization (0 by default which means first in the list)
  54833. */
  54834. priority?: number,
  54835. /**
  54836. * Defines the maximum scale to use (2 by default)
  54837. */
  54838. maximumScale?: number,
  54839. /**
  54840. * Defines the step to use between two passes (0.5 by default)
  54841. */
  54842. step?: number);
  54843. /**
  54844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54845. * @param scene defines the current scene where to apply this optimization
  54846. * @param optimizer defines the current optimizer
  54847. * @returns true if everything that can be done was applied
  54848. */
  54849. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54850. }
  54851. /**
  54852. * Defines an optimization used to remove shadows
  54853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54854. */
  54855. export class ShadowsOptimization extends SceneOptimization {
  54856. /**
  54857. * Gets a string describing the action executed by the current optimization
  54858. * @return description string
  54859. */
  54860. getDescription(): string;
  54861. /**
  54862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54863. * @param scene defines the current scene where to apply this optimization
  54864. * @param optimizer defines the current optimizer
  54865. * @returns true if everything that can be done was applied
  54866. */
  54867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54868. }
  54869. /**
  54870. * Defines an optimization used to turn post-processes off
  54871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54872. */
  54873. export class PostProcessesOptimization extends SceneOptimization {
  54874. /**
  54875. * Gets a string describing the action executed by the current optimization
  54876. * @return description string
  54877. */
  54878. getDescription(): string;
  54879. /**
  54880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54881. * @param scene defines the current scene where to apply this optimization
  54882. * @param optimizer defines the current optimizer
  54883. * @returns true if everything that can be done was applied
  54884. */
  54885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54886. }
  54887. /**
  54888. * Defines an optimization used to turn lens flares off
  54889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54890. */
  54891. export class LensFlaresOptimization extends SceneOptimization {
  54892. /**
  54893. * Gets a string describing the action executed by the current optimization
  54894. * @return description string
  54895. */
  54896. getDescription(): string;
  54897. /**
  54898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54899. * @param scene defines the current scene where to apply this optimization
  54900. * @param optimizer defines the current optimizer
  54901. * @returns true if everything that can be done was applied
  54902. */
  54903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54904. }
  54905. /**
  54906. * Defines an optimization based on user defined callback.
  54907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54908. */
  54909. export class CustomOptimization extends SceneOptimization {
  54910. /**
  54911. * Callback called to apply the custom optimization.
  54912. */
  54913. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54914. /**
  54915. * Callback called to get custom description
  54916. */
  54917. onGetDescription: () => string;
  54918. /**
  54919. * Gets a string describing the action executed by the current optimization
  54920. * @returns description string
  54921. */
  54922. getDescription(): string;
  54923. /**
  54924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54925. * @param scene defines the current scene where to apply this optimization
  54926. * @param optimizer defines the current optimizer
  54927. * @returns true if everything that can be done was applied
  54928. */
  54929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54930. }
  54931. /**
  54932. * Defines an optimization used to turn particles off
  54933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54934. */
  54935. export class ParticlesOptimization extends SceneOptimization {
  54936. /**
  54937. * Gets a string describing the action executed by the current optimization
  54938. * @return description string
  54939. */
  54940. getDescription(): string;
  54941. /**
  54942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54943. * @param scene defines the current scene where to apply this optimization
  54944. * @param optimizer defines the current optimizer
  54945. * @returns true if everything that can be done was applied
  54946. */
  54947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54948. }
  54949. /**
  54950. * Defines an optimization used to turn render targets off
  54951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54952. */
  54953. export class RenderTargetsOptimization extends SceneOptimization {
  54954. /**
  54955. * Gets a string describing the action executed by the current optimization
  54956. * @return description string
  54957. */
  54958. getDescription(): string;
  54959. /**
  54960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54961. * @param scene defines the current scene where to apply this optimization
  54962. * @param optimizer defines the current optimizer
  54963. * @returns true if everything that can be done was applied
  54964. */
  54965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54966. }
  54967. /**
  54968. * Defines an optimization used to merge meshes with compatible materials
  54969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54970. */
  54971. export class MergeMeshesOptimization extends SceneOptimization {
  54972. private static _UpdateSelectionTree;
  54973. /**
  54974. * Gets or sets a boolean which defines if optimization octree has to be updated
  54975. */
  54976. /**
  54977. * Gets or sets a boolean which defines if optimization octree has to be updated
  54978. */
  54979. static UpdateSelectionTree: boolean;
  54980. /**
  54981. * Gets a string describing the action executed by the current optimization
  54982. * @return description string
  54983. */
  54984. getDescription(): string;
  54985. private _canBeMerged;
  54986. /**
  54987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54988. * @param scene defines the current scene where to apply this optimization
  54989. * @param optimizer defines the current optimizer
  54990. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54991. * @returns true if everything that can be done was applied
  54992. */
  54993. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54994. }
  54995. /**
  54996. * Defines a list of options used by SceneOptimizer
  54997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54998. */
  54999. export class SceneOptimizerOptions {
  55000. /**
  55001. * Defines the target frame rate to reach (60 by default)
  55002. */
  55003. targetFrameRate: number;
  55004. /**
  55005. * Defines the interval between two checkes (2000ms by default)
  55006. */
  55007. trackerDuration: number;
  55008. /**
  55009. * Gets the list of optimizations to apply
  55010. */
  55011. optimizations: SceneOptimization[];
  55012. /**
  55013. * Creates a new list of options used by SceneOptimizer
  55014. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55015. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55016. */
  55017. constructor(
  55018. /**
  55019. * Defines the target frame rate to reach (60 by default)
  55020. */
  55021. targetFrameRate?: number,
  55022. /**
  55023. * Defines the interval between two checkes (2000ms by default)
  55024. */
  55025. trackerDuration?: number);
  55026. /**
  55027. * Add a new optimization
  55028. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55029. * @returns the current SceneOptimizerOptions
  55030. */
  55031. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55032. /**
  55033. * Add a new custom optimization
  55034. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55035. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55037. * @returns the current SceneOptimizerOptions
  55038. */
  55039. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55040. /**
  55041. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55042. * @param targetFrameRate defines the target frame rate (60 by default)
  55043. * @returns a SceneOptimizerOptions object
  55044. */
  55045. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55046. /**
  55047. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55048. * @param targetFrameRate defines the target frame rate (60 by default)
  55049. * @returns a SceneOptimizerOptions object
  55050. */
  55051. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55052. /**
  55053. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55054. * @param targetFrameRate defines the target frame rate (60 by default)
  55055. * @returns a SceneOptimizerOptions object
  55056. */
  55057. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55058. }
  55059. /**
  55060. * Class used to run optimizations in order to reach a target frame rate
  55061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55062. */
  55063. export class SceneOptimizer implements IDisposable {
  55064. private _isRunning;
  55065. private _options;
  55066. private _scene;
  55067. private _currentPriorityLevel;
  55068. private _targetFrameRate;
  55069. private _trackerDuration;
  55070. private _currentFrameRate;
  55071. private _sceneDisposeObserver;
  55072. private _improvementMode;
  55073. /**
  55074. * Defines an observable called when the optimizer reaches the target frame rate
  55075. */
  55076. onSuccessObservable: Observable<SceneOptimizer>;
  55077. /**
  55078. * Defines an observable called when the optimizer enables an optimization
  55079. */
  55080. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55081. /**
  55082. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55083. */
  55084. onFailureObservable: Observable<SceneOptimizer>;
  55085. /**
  55086. * Gets a boolean indicating if the optimizer is in improvement mode
  55087. */
  55088. readonly isInImprovementMode: boolean;
  55089. /**
  55090. * Gets the current priority level (0 at start)
  55091. */
  55092. readonly currentPriorityLevel: number;
  55093. /**
  55094. * Gets the current frame rate checked by the SceneOptimizer
  55095. */
  55096. readonly currentFrameRate: number;
  55097. /**
  55098. * Gets or sets the current target frame rate (60 by default)
  55099. */
  55100. /**
  55101. * Gets or sets the current target frame rate (60 by default)
  55102. */
  55103. targetFrameRate: number;
  55104. /**
  55105. * Gets or sets the current interval between two checks (every 2000ms by default)
  55106. */
  55107. /**
  55108. * Gets or sets the current interval between two checks (every 2000ms by default)
  55109. */
  55110. trackerDuration: number;
  55111. /**
  55112. * Gets the list of active optimizations
  55113. */
  55114. readonly optimizations: SceneOptimization[];
  55115. /**
  55116. * Creates a new SceneOptimizer
  55117. * @param scene defines the scene to work on
  55118. * @param options defines the options to use with the SceneOptimizer
  55119. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55120. * @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)
  55121. */
  55122. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55123. /**
  55124. * Stops the current optimizer
  55125. */
  55126. stop(): void;
  55127. /**
  55128. * Reset the optimizer to initial step (current priority level = 0)
  55129. */
  55130. reset(): void;
  55131. /**
  55132. * Start the optimizer. By default it will try to reach a specific framerate
  55133. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55134. */
  55135. start(): void;
  55136. private _checkCurrentState;
  55137. /**
  55138. * Release all resources
  55139. */
  55140. dispose(): void;
  55141. /**
  55142. * Helper function to create a SceneOptimizer with one single line of code
  55143. * @param scene defines the scene to work on
  55144. * @param options defines the options to use with the SceneOptimizer
  55145. * @param onSuccess defines a callback to call on success
  55146. * @param onFailure defines a callback to call on failure
  55147. * @returns the new SceneOptimizer object
  55148. */
  55149. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55150. }
  55151. }
  55152. declare module "babylonjs/Misc/sceneSerializer" {
  55153. import { Scene } from "babylonjs/scene";
  55154. /**
  55155. * Class used to serialize a scene into a string
  55156. */
  55157. export class SceneSerializer {
  55158. /**
  55159. * Clear cache used by a previous serialization
  55160. */
  55161. static ClearCache(): void;
  55162. /**
  55163. * Serialize a scene into a JSON compatible object
  55164. * @param scene defines the scene to serialize
  55165. * @returns a JSON compatible object
  55166. */
  55167. static Serialize(scene: Scene): any;
  55168. /**
  55169. * Serialize a mesh into a JSON compatible object
  55170. * @param toSerialize defines the mesh to serialize
  55171. * @param withParents defines if parents must be serialized as well
  55172. * @param withChildren defines if children must be serialized as well
  55173. * @returns a JSON compatible object
  55174. */
  55175. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55176. }
  55177. }
  55178. declare module "babylonjs/Misc/videoRecorder" {
  55179. import { Nullable } from "babylonjs/types";
  55180. import { Engine } from "babylonjs/Engines/engine";
  55181. /**
  55182. * This represents the different options avilable for the video capture.
  55183. */
  55184. export interface VideoRecorderOptions {
  55185. /** Defines the mime type of the video */
  55186. mimeType: string;
  55187. /** Defines the video the video should be recorded at */
  55188. fps: number;
  55189. /** Defines the chunk size for the recording data */
  55190. recordChunckSize: number;
  55191. }
  55192. /**
  55193. * This can helps recording videos from BabylonJS.
  55194. * This is based on the available WebRTC functionalities of the browser.
  55195. *
  55196. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55197. */
  55198. export class VideoRecorder {
  55199. private static readonly _defaultOptions;
  55200. /**
  55201. * Returns wehther or not the VideoRecorder is available in your browser.
  55202. * @param engine Defines the Babylon Engine to check the support for
  55203. * @returns true if supported otherwise false
  55204. */
  55205. static IsSupported(engine: Engine): boolean;
  55206. private readonly _options;
  55207. private _canvas;
  55208. private _mediaRecorder;
  55209. private _recordedChunks;
  55210. private _fileName;
  55211. private _resolve;
  55212. private _reject;
  55213. /**
  55214. * True wether a recording is already in progress.
  55215. */
  55216. readonly isRecording: boolean;
  55217. /**
  55218. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55219. * a video file.
  55220. * @param engine Defines the BabylonJS Engine you wish to record
  55221. * @param options Defines options that can be used to customized the capture
  55222. */
  55223. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55224. /**
  55225. * Stops the current recording before the default capture timeout passed in the startRecording
  55226. * functions.
  55227. */
  55228. stopRecording(): void;
  55229. /**
  55230. * Starts recording the canvas for a max duration specified in parameters.
  55231. * @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.
  55232. * @param maxDuration Defines the maximum recording time in seconds.
  55233. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55234. * @return a promise callback at the end of the recording with the video data in Blob.
  55235. */
  55236. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55237. /**
  55238. * Releases internal resources used during the recording.
  55239. */
  55240. dispose(): void;
  55241. private _handleDataAvailable;
  55242. private _handleError;
  55243. private _handleStop;
  55244. }
  55245. }
  55246. declare module "babylonjs/Misc/workerPool" {
  55247. import { IDisposable } from "babylonjs/scene";
  55248. /**
  55249. * Helper class to push actions to a pool of workers.
  55250. */
  55251. export class WorkerPool implements IDisposable {
  55252. private _workerInfos;
  55253. private _pendingActions;
  55254. /**
  55255. * Constructor
  55256. * @param workers Array of workers to use for actions
  55257. */
  55258. constructor(workers: Array<Worker>);
  55259. /**
  55260. * Terminates all workers and clears any pending actions.
  55261. */
  55262. dispose(): void;
  55263. /**
  55264. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55265. * pended until a worker has completed its action.
  55266. * @param action The action to perform. Call onComplete when the action is complete.
  55267. */
  55268. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55269. private _execute;
  55270. }
  55271. }
  55272. declare module "babylonjs/Misc/screenshotTools" {
  55273. import { Camera } from "babylonjs/Cameras/camera";
  55274. import { Engine } from "babylonjs/Engines/engine";
  55275. /**
  55276. * Class containing a set of static utilities functions for screenshots
  55277. */
  55278. export class ScreenshotTools {
  55279. /**
  55280. * Captures a screenshot of the current rendering
  55281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55282. * @param engine defines the rendering engine
  55283. * @param camera defines the source camera
  55284. * @param size This parameter can be set to a single number or to an object with the
  55285. * following (optional) properties: precision, width, height. If a single number is passed,
  55286. * it will be used for both width and height. If an object is passed, the screenshot size
  55287. * will be derived from the parameters. The precision property is a multiplier allowing
  55288. * rendering at a higher or lower resolution
  55289. * @param successCallback defines the callback receives a single parameter which contains the
  55290. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55291. * src parameter of an <img> to display it
  55292. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55293. * Check your browser for supported MIME types
  55294. */
  55295. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55296. /**
  55297. * Generates an image screenshot from the specified camera.
  55298. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55299. * @param engine The engine to use for rendering
  55300. * @param camera The camera to use for rendering
  55301. * @param size This parameter can be set to a single number or to an object with the
  55302. * following (optional) properties: precision, width, height. If a single number is passed,
  55303. * it will be used for both width and height. If an object is passed, the screenshot size
  55304. * will be derived from the parameters. The precision property is a multiplier allowing
  55305. * rendering at a higher or lower resolution
  55306. * @param successCallback The callback receives a single parameter which contains the
  55307. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55308. * src parameter of an <img> to display it
  55309. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55310. * Check your browser for supported MIME types
  55311. * @param samples Texture samples (default: 1)
  55312. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55313. * @param fileName A name for for the downloaded file.
  55314. */
  55315. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55316. }
  55317. }
  55318. declare module "babylonjs/Misc/index" {
  55319. export * from "babylonjs/Misc/andOrNotEvaluator";
  55320. export * from "babylonjs/Misc/assetsManager";
  55321. export * from "babylonjs/Misc/dds";
  55322. export * from "babylonjs/Misc/decorators";
  55323. export * from "babylonjs/Misc/deferred";
  55324. export * from "babylonjs/Misc/environmentTextureTools";
  55325. export * from "babylonjs/Misc/filesInput";
  55326. export * from "babylonjs/Misc/HighDynamicRange/index";
  55327. export * from "babylonjs/Misc/khronosTextureContainer";
  55328. export * from "babylonjs/Misc/observable";
  55329. export * from "babylonjs/Misc/performanceMonitor";
  55330. export * from "babylonjs/Misc/promise";
  55331. export * from "babylonjs/Misc/sceneOptimizer";
  55332. export * from "babylonjs/Misc/sceneSerializer";
  55333. export * from "babylonjs/Misc/smartArray";
  55334. export * from "babylonjs/Misc/stringDictionary";
  55335. export * from "babylonjs/Misc/tags";
  55336. export * from "babylonjs/Misc/textureTools";
  55337. export * from "babylonjs/Misc/tga";
  55338. export * from "babylonjs/Misc/tools";
  55339. export * from "babylonjs/Misc/videoRecorder";
  55340. export * from "babylonjs/Misc/virtualJoystick";
  55341. export * from "babylonjs/Misc/workerPool";
  55342. export * from "babylonjs/Misc/logger";
  55343. export * from "babylonjs/Misc/typeStore";
  55344. export * from "babylonjs/Misc/filesInputStore";
  55345. export * from "babylonjs/Misc/deepCopier";
  55346. export * from "babylonjs/Misc/pivotTools";
  55347. export * from "babylonjs/Misc/precisionDate";
  55348. export * from "babylonjs/Misc/screenshotTools";
  55349. export * from "babylonjs/Misc/typeStore";
  55350. }
  55351. declare module "babylonjs/index" {
  55352. export * from "babylonjs/abstractScene";
  55353. export * from "babylonjs/Actions/index";
  55354. export * from "babylonjs/Animations/index";
  55355. export * from "babylonjs/assetContainer";
  55356. export * from "babylonjs/Audio/index";
  55357. export * from "babylonjs/Behaviors/index";
  55358. export * from "babylonjs/Bones/index";
  55359. export * from "babylonjs/Cameras/index";
  55360. export * from "babylonjs/Collisions/index";
  55361. export * from "babylonjs/Culling/index";
  55362. export * from "babylonjs/Debug/index";
  55363. export * from "babylonjs/Engines/index";
  55364. export * from "babylonjs/Events/index";
  55365. export * from "babylonjs/Gamepads/index";
  55366. export * from "babylonjs/Gizmos/index";
  55367. export * from "babylonjs/Helpers/index";
  55368. export * from "babylonjs/Instrumentation/index";
  55369. export * from "babylonjs/Layers/index";
  55370. export * from "babylonjs/LensFlares/index";
  55371. export * from "babylonjs/Lights/index";
  55372. export * from "babylonjs/Loading/index";
  55373. export * from "babylonjs/Materials/index";
  55374. export * from "babylonjs/Maths/index";
  55375. export * from "babylonjs/Meshes/index";
  55376. export * from "babylonjs/Morph/index";
  55377. export * from "babylonjs/node";
  55378. export * from "babylonjs/Offline/index";
  55379. export * from "babylonjs/Particles/index";
  55380. export * from "babylonjs/Physics/index";
  55381. export * from "babylonjs/PostProcesses/index";
  55382. export * from "babylonjs/Probes/index";
  55383. export * from "babylonjs/Rendering/index";
  55384. export * from "babylonjs/scene";
  55385. export * from "babylonjs/sceneComponent";
  55386. export * from "babylonjs/Sprites/index";
  55387. export * from "babylonjs/States/index";
  55388. export * from "babylonjs/Misc/index";
  55389. export * from "babylonjs/types";
  55390. }
  55391. declare module "babylonjs/Legacy/legacy" {
  55392. export * from "babylonjs/index";
  55393. }
  55394. declare module "babylonjs/Shaders/blur.fragment" {
  55395. /** @hidden */
  55396. export var blurPixelShader: {
  55397. name: string;
  55398. shader: string;
  55399. };
  55400. }
  55401. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55402. /** @hidden */
  55403. export var bones300Declaration: {
  55404. name: string;
  55405. shader: string;
  55406. };
  55407. }
  55408. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55409. /** @hidden */
  55410. export var instances300Declaration: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55416. /** @hidden */
  55417. export var pointCloudVertexDeclaration: {
  55418. name: string;
  55419. shader: string;
  55420. };
  55421. }
  55422. // Mixins
  55423. interface Window {
  55424. mozIndexedDB: IDBFactory;
  55425. webkitIndexedDB: IDBFactory;
  55426. msIndexedDB: IDBFactory;
  55427. webkitURL: typeof URL;
  55428. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55429. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55430. WebGLRenderingContext: WebGLRenderingContext;
  55431. MSGesture: MSGesture;
  55432. CANNON: any;
  55433. AudioContext: AudioContext;
  55434. webkitAudioContext: AudioContext;
  55435. PointerEvent: any;
  55436. Math: Math;
  55437. Uint8Array: Uint8ArrayConstructor;
  55438. Float32Array: Float32ArrayConstructor;
  55439. mozURL: typeof URL;
  55440. msURL: typeof URL;
  55441. VRFrameData: any; // WebVR, from specs 1.1
  55442. DracoDecoderModule: any;
  55443. setImmediate(handler: (...args: any[]) => void): number;
  55444. }
  55445. interface Document {
  55446. mozCancelFullScreen(): void;
  55447. msCancelFullScreen(): void;
  55448. webkitCancelFullScreen(): void;
  55449. requestPointerLock(): void;
  55450. exitPointerLock(): void;
  55451. mozFullScreen: boolean;
  55452. msIsFullScreen: boolean;
  55453. readonly webkitIsFullScreen: boolean;
  55454. readonly pointerLockElement: Element;
  55455. mozPointerLockElement: HTMLElement;
  55456. msPointerLockElement: HTMLElement;
  55457. webkitPointerLockElement: HTMLElement;
  55458. }
  55459. interface HTMLCanvasElement {
  55460. requestPointerLock(): void;
  55461. msRequestPointerLock?(): void;
  55462. mozRequestPointerLock?(): void;
  55463. webkitRequestPointerLock?(): void;
  55464. /** Track wether a record is in progress */
  55465. isRecording: boolean;
  55466. /** Capture Stream method defined by some browsers */
  55467. captureStream(fps?: number): MediaStream;
  55468. }
  55469. interface CanvasRenderingContext2D {
  55470. msImageSmoothingEnabled: boolean;
  55471. }
  55472. interface MouseEvent {
  55473. mozMovementX: number;
  55474. mozMovementY: number;
  55475. webkitMovementX: number;
  55476. webkitMovementY: number;
  55477. msMovementX: number;
  55478. msMovementY: number;
  55479. }
  55480. interface Navigator {
  55481. mozGetVRDevices: (any: any) => any;
  55482. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55483. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55484. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55485. webkitGetGamepads(): Gamepad[];
  55486. msGetGamepads(): Gamepad[];
  55487. webkitGamepads(): Gamepad[];
  55488. }
  55489. interface HTMLVideoElement {
  55490. mozSrcObject: any;
  55491. }
  55492. interface Math {
  55493. fround(x: number): number;
  55494. imul(a: number, b: number): number;
  55495. }
  55496. interface WebGLProgram {
  55497. context?: WebGLRenderingContext;
  55498. vertexShader?: WebGLShader;
  55499. fragmentShader?: WebGLShader;
  55500. isParallelCompiled: boolean;
  55501. onCompiled?: () => void;
  55502. }
  55503. interface WebGLRenderingContext {
  55504. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55505. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55506. vertexAttribDivisor(index: number, divisor: number): void;
  55507. createVertexArray(): any;
  55508. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55509. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55510. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55511. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55512. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55513. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55514. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55515. // Queries
  55516. createQuery(): WebGLQuery;
  55517. deleteQuery(query: WebGLQuery): void;
  55518. beginQuery(target: number, query: WebGLQuery): void;
  55519. endQuery(target: number): void;
  55520. getQueryParameter(query: WebGLQuery, pname: number): any;
  55521. getQuery(target: number, pname: number): any;
  55522. MAX_SAMPLES: number;
  55523. RGBA8: number;
  55524. READ_FRAMEBUFFER: number;
  55525. DRAW_FRAMEBUFFER: number;
  55526. UNIFORM_BUFFER: number;
  55527. HALF_FLOAT_OES: number;
  55528. RGBA16F: number;
  55529. RGBA32F: number;
  55530. R32F: number;
  55531. RG32F: number;
  55532. RGB32F: number;
  55533. R16F: number;
  55534. RG16F: number;
  55535. RGB16F: number;
  55536. RED: number;
  55537. RG: number;
  55538. R8: number;
  55539. RG8: number;
  55540. UNSIGNED_INT_24_8: number;
  55541. DEPTH24_STENCIL8: number;
  55542. /* Multiple Render Targets */
  55543. drawBuffers(buffers: number[]): void;
  55544. readBuffer(src: number): void;
  55545. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55546. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55547. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55548. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55549. // Occlusion Query
  55550. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55551. ANY_SAMPLES_PASSED: number;
  55552. QUERY_RESULT_AVAILABLE: number;
  55553. QUERY_RESULT: number;
  55554. }
  55555. interface WebGLBuffer {
  55556. references: number;
  55557. capacity: number;
  55558. is32Bits: boolean;
  55559. }
  55560. interface WebGLProgram {
  55561. transformFeedback?: WebGLTransformFeedback | null;
  55562. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55563. }
  55564. interface EXT_disjoint_timer_query {
  55565. QUERY_COUNTER_BITS_EXT: number;
  55566. TIME_ELAPSED_EXT: number;
  55567. TIMESTAMP_EXT: number;
  55568. GPU_DISJOINT_EXT: number;
  55569. QUERY_RESULT_EXT: number;
  55570. QUERY_RESULT_AVAILABLE_EXT: number;
  55571. queryCounterEXT(query: WebGLQuery, target: number): void;
  55572. createQueryEXT(): WebGLQuery;
  55573. beginQueryEXT(target: number, query: WebGLQuery): void;
  55574. endQueryEXT(target: number): void;
  55575. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55576. deleteQueryEXT(query: WebGLQuery): void;
  55577. }
  55578. interface WebGLUniformLocation {
  55579. _currentState: any;
  55580. }
  55581. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55582. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55583. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55584. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55585. interface WebGLRenderingContext {
  55586. readonly RASTERIZER_DISCARD: number;
  55587. readonly DEPTH_COMPONENT24: number;
  55588. readonly TEXTURE_3D: number;
  55589. readonly TEXTURE_2D_ARRAY: number;
  55590. readonly TEXTURE_COMPARE_FUNC: number;
  55591. readonly TEXTURE_COMPARE_MODE: number;
  55592. readonly COMPARE_REF_TO_TEXTURE: number;
  55593. readonly TEXTURE_WRAP_R: number;
  55594. readonly HALF_FLOAT: number;
  55595. readonly RGB8: number;
  55596. readonly RED_INTEGER: number;
  55597. readonly RG_INTEGER: number;
  55598. readonly RGB_INTEGER: number;
  55599. readonly RGBA_INTEGER: number;
  55600. readonly R8_SNORM: number;
  55601. readonly RG8_SNORM: number;
  55602. readonly RGB8_SNORM: number;
  55603. readonly RGBA8_SNORM: number;
  55604. readonly R8I: number;
  55605. readonly RG8I: number;
  55606. readonly RGB8I: number;
  55607. readonly RGBA8I: number;
  55608. readonly R8UI: number;
  55609. readonly RG8UI: number;
  55610. readonly RGB8UI: number;
  55611. readonly RGBA8UI: number;
  55612. readonly R16I: number;
  55613. readonly RG16I: number;
  55614. readonly RGB16I: number;
  55615. readonly RGBA16I: number;
  55616. readonly R16UI: number;
  55617. readonly RG16UI: number;
  55618. readonly RGB16UI: number;
  55619. readonly RGBA16UI: number;
  55620. readonly R32I: number;
  55621. readonly RG32I: number;
  55622. readonly RGB32I: number;
  55623. readonly RGBA32I: number;
  55624. readonly R32UI: number;
  55625. readonly RG32UI: number;
  55626. readonly RGB32UI: number;
  55627. readonly RGBA32UI: number;
  55628. readonly RGB10_A2UI: number;
  55629. readonly R11F_G11F_B10F: number;
  55630. readonly RGB9_E5: number;
  55631. readonly RGB10_A2: number;
  55632. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55633. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55634. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55635. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55636. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55637. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55638. 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;
  55639. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55640. readonly TRANSFORM_FEEDBACK: number;
  55641. readonly INTERLEAVED_ATTRIBS: number;
  55642. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55643. createTransformFeedback(): WebGLTransformFeedback;
  55644. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55645. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55646. beginTransformFeedback(primitiveMode: number): void;
  55647. endTransformFeedback(): void;
  55648. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55649. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55650. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55651. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55652. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55653. }
  55654. interface ImageBitmap {
  55655. readonly width: number;
  55656. readonly height: number;
  55657. close(): void;
  55658. }
  55659. interface WebGLQuery extends WebGLObject {
  55660. }
  55661. declare var WebGLQuery: {
  55662. prototype: WebGLQuery;
  55663. new(): WebGLQuery;
  55664. };
  55665. interface WebGLSampler extends WebGLObject {
  55666. }
  55667. declare var WebGLSampler: {
  55668. prototype: WebGLSampler;
  55669. new(): WebGLSampler;
  55670. };
  55671. interface WebGLSync extends WebGLObject {
  55672. }
  55673. declare var WebGLSync: {
  55674. prototype: WebGLSync;
  55675. new(): WebGLSync;
  55676. };
  55677. interface WebGLTransformFeedback extends WebGLObject {
  55678. }
  55679. declare var WebGLTransformFeedback: {
  55680. prototype: WebGLTransformFeedback;
  55681. new(): WebGLTransformFeedback;
  55682. };
  55683. interface WebGLVertexArrayObject extends WebGLObject {
  55684. }
  55685. declare var WebGLVertexArrayObject: {
  55686. prototype: WebGLVertexArrayObject;
  55687. new(): WebGLVertexArrayObject;
  55688. };
  55689. // Type definitions for WebVR API
  55690. // Project: https://w3c.github.io/webvr/
  55691. // Definitions by: six a <https://github.com/lostfictions>
  55692. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55693. interface VRDisplay extends EventTarget {
  55694. /**
  55695. * Dictionary of capabilities describing the VRDisplay.
  55696. */
  55697. readonly capabilities: VRDisplayCapabilities;
  55698. /**
  55699. * z-depth defining the far plane of the eye view frustum
  55700. * enables mapping of values in the render target depth
  55701. * attachment to scene coordinates. Initially set to 10000.0.
  55702. */
  55703. depthFar: number;
  55704. /**
  55705. * z-depth defining the near plane of the eye view frustum
  55706. * enables mapping of values in the render target depth
  55707. * attachment to scene coordinates. Initially set to 0.01.
  55708. */
  55709. depthNear: number;
  55710. /**
  55711. * An identifier for this distinct VRDisplay. Used as an
  55712. * association point in the Gamepad API.
  55713. */
  55714. readonly displayId: number;
  55715. /**
  55716. * A display name, a user-readable name identifying it.
  55717. */
  55718. readonly displayName: string;
  55719. readonly isConnected: boolean;
  55720. readonly isPresenting: boolean;
  55721. /**
  55722. * If this VRDisplay supports room-scale experiences, the optional
  55723. * stage attribute contains details on the room-scale parameters.
  55724. */
  55725. readonly stageParameters: VRStageParameters | null;
  55726. /**
  55727. * Passing the value returned by `requestAnimationFrame` to
  55728. * `cancelAnimationFrame` will unregister the callback.
  55729. * @param handle Define the hanle of the request to cancel
  55730. */
  55731. cancelAnimationFrame(handle: number): void;
  55732. /**
  55733. * Stops presenting to the VRDisplay.
  55734. * @returns a promise to know when it stopped
  55735. */
  55736. exitPresent(): Promise<void>;
  55737. /**
  55738. * Return the current VREyeParameters for the given eye.
  55739. * @param whichEye Define the eye we want the parameter for
  55740. * @returns the eye parameters
  55741. */
  55742. getEyeParameters(whichEye: string): VREyeParameters;
  55743. /**
  55744. * Populates the passed VRFrameData with the information required to render
  55745. * the current frame.
  55746. * @param frameData Define the data structure to populate
  55747. * @returns true if ok otherwise false
  55748. */
  55749. getFrameData(frameData: VRFrameData): boolean;
  55750. /**
  55751. * Get the layers currently being presented.
  55752. * @returns the list of VR layers
  55753. */
  55754. getLayers(): VRLayer[];
  55755. /**
  55756. * Return a VRPose containing the future predicted pose of the VRDisplay
  55757. * when the current frame will be presented. The value returned will not
  55758. * change until JavaScript has returned control to the browser.
  55759. *
  55760. * The VRPose will contain the position, orientation, velocity,
  55761. * and acceleration of each of these properties.
  55762. * @returns the pose object
  55763. */
  55764. getPose(): VRPose;
  55765. /**
  55766. * Return the current instantaneous pose of the VRDisplay, with no
  55767. * prediction applied.
  55768. * @returns the current instantaneous pose
  55769. */
  55770. getImmediatePose(): VRPose;
  55771. /**
  55772. * The callback passed to `requestAnimationFrame` will be called
  55773. * any time a new frame should be rendered. When the VRDisplay is
  55774. * presenting the callback will be called at the native refresh
  55775. * rate of the HMD. When not presenting this function acts
  55776. * identically to how window.requestAnimationFrame acts. Content should
  55777. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55778. * asynchronously from other displays and at differing refresh rates.
  55779. * @param callback Define the eaction to run next frame
  55780. * @returns the request handle it
  55781. */
  55782. requestAnimationFrame(callback: FrameRequestCallback): number;
  55783. /**
  55784. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55785. * Repeat calls while already presenting will update the VRLayers being displayed.
  55786. * @param layers Define the list of layer to present
  55787. * @returns a promise to know when the request has been fulfilled
  55788. */
  55789. requestPresent(layers: VRLayer[]): Promise<void>;
  55790. /**
  55791. * Reset the pose for this display, treating its current position and
  55792. * orientation as the "origin/zero" values. VRPose.position,
  55793. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55794. * updated when calling resetPose(). This should be called in only
  55795. * sitting-space experiences.
  55796. */
  55797. resetPose(): void;
  55798. /**
  55799. * The VRLayer provided to the VRDisplay will be captured and presented
  55800. * in the HMD. Calling this function has the same effect on the source
  55801. * canvas as any other operation that uses its source image, and canvases
  55802. * created without preserveDrawingBuffer set to true will be cleared.
  55803. * @param pose Define the pose to submit
  55804. */
  55805. submitFrame(pose?: VRPose): void;
  55806. }
  55807. declare var VRDisplay: {
  55808. prototype: VRDisplay;
  55809. new(): VRDisplay;
  55810. };
  55811. interface VRLayer {
  55812. leftBounds?: number[] | Float32Array | null;
  55813. rightBounds?: number[] | Float32Array | null;
  55814. source?: HTMLCanvasElement | null;
  55815. }
  55816. interface VRDisplayCapabilities {
  55817. readonly canPresent: boolean;
  55818. readonly hasExternalDisplay: boolean;
  55819. readonly hasOrientation: boolean;
  55820. readonly hasPosition: boolean;
  55821. readonly maxLayers: number;
  55822. }
  55823. interface VREyeParameters {
  55824. /** @deprecated */
  55825. readonly fieldOfView: VRFieldOfView;
  55826. readonly offset: Float32Array;
  55827. readonly renderHeight: number;
  55828. readonly renderWidth: number;
  55829. }
  55830. interface VRFieldOfView {
  55831. readonly downDegrees: number;
  55832. readonly leftDegrees: number;
  55833. readonly rightDegrees: number;
  55834. readonly upDegrees: number;
  55835. }
  55836. interface VRFrameData {
  55837. readonly leftProjectionMatrix: Float32Array;
  55838. readonly leftViewMatrix: Float32Array;
  55839. readonly pose: VRPose;
  55840. readonly rightProjectionMatrix: Float32Array;
  55841. readonly rightViewMatrix: Float32Array;
  55842. readonly timestamp: number;
  55843. }
  55844. interface VRPose {
  55845. readonly angularAcceleration: Float32Array | null;
  55846. readonly angularVelocity: Float32Array | null;
  55847. readonly linearAcceleration: Float32Array | null;
  55848. readonly linearVelocity: Float32Array | null;
  55849. readonly orientation: Float32Array | null;
  55850. readonly position: Float32Array | null;
  55851. readonly timestamp: number;
  55852. }
  55853. interface VRStageParameters {
  55854. sittingToStandingTransform?: Float32Array;
  55855. sizeX?: number;
  55856. sizeY?: number;
  55857. }
  55858. interface Navigator {
  55859. getVRDisplays(): Promise<VRDisplay[]>;
  55860. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55861. }
  55862. interface Window {
  55863. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55864. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55865. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55866. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55867. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55868. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55869. }
  55870. interface Gamepad {
  55871. readonly displayId: number;
  55872. }
  55873. interface XRDevice {
  55874. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55875. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55876. }
  55877. interface XRSession {
  55878. getInputSources(): Array<any>;
  55879. baseLayer: XRWebGLLayer;
  55880. requestFrameOfReference(type: string): Promise<void>;
  55881. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55882. end(): Promise<void>;
  55883. requestAnimationFrame: Function;
  55884. addEventListener: Function;
  55885. }
  55886. interface XRSessionCreationOptions {
  55887. outputContext?: WebGLRenderingContext | null;
  55888. immersive?: boolean;
  55889. environmentIntegration?: boolean;
  55890. }
  55891. interface XRLayer {
  55892. getViewport: Function;
  55893. framebufferWidth: number;
  55894. framebufferHeight: number;
  55895. }
  55896. interface XRView {
  55897. projectionMatrix: Float32Array;
  55898. }
  55899. interface XRFrame {
  55900. getDevicePose: Function;
  55901. getInputPose: Function;
  55902. views: Array<XRView>;
  55903. baseLayer: XRLayer;
  55904. }
  55905. interface XRFrameOfReference {
  55906. }
  55907. interface XRWebGLLayer extends XRLayer {
  55908. framebuffer: WebGLFramebuffer;
  55909. }
  55910. declare var XRWebGLLayer: {
  55911. prototype: XRWebGLLayer;
  55912. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55913. };
  55914. declare module "babylonjs" {
  55915. export * from "babylonjs/Legacy/legacy";
  55916. }
  55917. declare module BABYLON {
  55918. /** Alias type for value that can be null */
  55919. export type Nullable<T> = T | null;
  55920. /**
  55921. * Alias type for number that are floats
  55922. * @ignorenaming
  55923. */
  55924. export type float = number;
  55925. /**
  55926. * Alias type for number that are doubles.
  55927. * @ignorenaming
  55928. */
  55929. export type double = number;
  55930. /**
  55931. * Alias type for number that are integer
  55932. * @ignorenaming
  55933. */
  55934. export type int = number;
  55935. /** Alias type for number array or Float32Array */
  55936. export type FloatArray = number[] | Float32Array;
  55937. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  55938. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  55939. /**
  55940. * Alias for types that can be used by a Buffer or VertexBuffer.
  55941. */
  55942. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  55943. /**
  55944. * Alias type for primitive types
  55945. * @ignorenaming
  55946. */
  55947. type Primitive = undefined | null | boolean | string | number | Function;
  55948. /**
  55949. * Type modifier to make all the properties of an object Readonly
  55950. */
  55951. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  55952. /**
  55953. * Type modifier to make all the properties of an object Readonly recursively
  55954. */
  55955. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  55956. /** @hidden */
  55957. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  55958. }
  55959. /** @hidden */
  55960. /** @hidden */
  55961. type DeepImmutableObject<T> = {
  55962. readonly [K in keyof T]: DeepImmutable<T[K]>;
  55963. };
  55964. }
  55965. declare module BABYLON {
  55966. /**
  55967. * Class containing a set of static utilities functions for arrays.
  55968. */
  55969. export class ArrayTools {
  55970. /**
  55971. * Returns an array of the given size filled with element built from the given constructor and the paramters
  55972. * @param size the number of element to construct and put in the array
  55973. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  55974. * @returns a new array filled with new objects
  55975. */
  55976. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  55977. }
  55978. }
  55979. declare module BABYLON {
  55980. /**
  55981. * Scalar computation library
  55982. */
  55983. export class Scalar {
  55984. /**
  55985. * Two pi constants convenient for computation.
  55986. */
  55987. static TwoPi: number;
  55988. /**
  55989. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  55990. * @param a number
  55991. * @param b number
  55992. * @param epsilon (default = 1.401298E-45)
  55993. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  55994. */
  55995. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  55996. /**
  55997. * Returns a string : the upper case translation of the number i to hexadecimal.
  55998. * @param i number
  55999. * @returns the upper case translation of the number i to hexadecimal.
  56000. */
  56001. static ToHex(i: number): string;
  56002. /**
  56003. * Returns -1 if value is negative and +1 is value is positive.
  56004. * @param value the value
  56005. * @returns the value itself if it's equal to zero.
  56006. */
  56007. static Sign(value: number): number;
  56008. /**
  56009. * Returns the value itself if it's between min and max.
  56010. * Returns min if the value is lower than min.
  56011. * Returns max if the value is greater than max.
  56012. * @param value the value to clmap
  56013. * @param min the min value to clamp to (default: 0)
  56014. * @param max the max value to clamp to (default: 1)
  56015. * @returns the clamped value
  56016. */
  56017. static Clamp(value: number, min?: number, max?: number): number;
  56018. /**
  56019. * the log2 of value.
  56020. * @param value the value to compute log2 of
  56021. * @returns the log2 of value.
  56022. */
  56023. static Log2(value: number): number;
  56024. /**
  56025. * Loops the value, so that it is never larger than length and never smaller than 0.
  56026. *
  56027. * This is similar to the modulo operator but it works with floating point numbers.
  56028. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56029. * With t = 5 and length = 2.5, the result would be 0.0.
  56030. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56031. * @param value the value
  56032. * @param length the length
  56033. * @returns the looped value
  56034. */
  56035. static Repeat(value: number, length: number): number;
  56036. /**
  56037. * Normalize the value between 0.0 and 1.0 using min and max values
  56038. * @param value value to normalize
  56039. * @param min max to normalize between
  56040. * @param max min to normalize between
  56041. * @returns the normalized value
  56042. */
  56043. static Normalize(value: number, min: number, max: number): number;
  56044. /**
  56045. * Denormalize the value from 0.0 and 1.0 using min and max values
  56046. * @param normalized value to denormalize
  56047. * @param min max to denormalize between
  56048. * @param max min to denormalize between
  56049. * @returns the denormalized value
  56050. */
  56051. static Denormalize(normalized: number, min: number, max: number): number;
  56052. /**
  56053. * Calculates the shortest difference between two given angles given in degrees.
  56054. * @param current current angle in degrees
  56055. * @param target target angle in degrees
  56056. * @returns the delta
  56057. */
  56058. static DeltaAngle(current: number, target: number): number;
  56059. /**
  56060. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56061. * @param tx value
  56062. * @param length length
  56063. * @returns The returned value will move back and forth between 0 and length
  56064. */
  56065. static PingPong(tx: number, length: number): number;
  56066. /**
  56067. * Interpolates between min and max with smoothing at the limits.
  56068. *
  56069. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56070. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56071. * @param from from
  56072. * @param to to
  56073. * @param tx value
  56074. * @returns the smooth stepped value
  56075. */
  56076. static SmoothStep(from: number, to: number, tx: number): number;
  56077. /**
  56078. * Moves a value current towards target.
  56079. *
  56080. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56081. * Negative values of maxDelta pushes the value away from target.
  56082. * @param current current value
  56083. * @param target target value
  56084. * @param maxDelta max distance to move
  56085. * @returns resulting value
  56086. */
  56087. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56088. /**
  56089. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56090. *
  56091. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56092. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56093. * @param current current value
  56094. * @param target target value
  56095. * @param maxDelta max distance to move
  56096. * @returns resulting angle
  56097. */
  56098. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56099. /**
  56100. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56101. * @param start start value
  56102. * @param end target value
  56103. * @param amount amount to lerp between
  56104. * @returns the lerped value
  56105. */
  56106. static Lerp(start: number, end: number, amount: number): number;
  56107. /**
  56108. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56109. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56110. * @param start start value
  56111. * @param end target value
  56112. * @param amount amount to lerp between
  56113. * @returns the lerped value
  56114. */
  56115. static LerpAngle(start: number, end: number, amount: number): number;
  56116. /**
  56117. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56118. * @param a start value
  56119. * @param b target value
  56120. * @param value value between a and b
  56121. * @returns the inverseLerp value
  56122. */
  56123. static InverseLerp(a: number, b: number, value: number): number;
  56124. /**
  56125. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56126. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56127. * @param value1 spline value
  56128. * @param tangent1 spline value
  56129. * @param value2 spline value
  56130. * @param tangent2 spline value
  56131. * @param amount input value
  56132. * @returns hermite result
  56133. */
  56134. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56135. /**
  56136. * Returns a random float number between and min and max values
  56137. * @param min min value of random
  56138. * @param max max value of random
  56139. * @returns random value
  56140. */
  56141. static RandomRange(min: number, max: number): number;
  56142. /**
  56143. * This function returns percentage of a number in a given range.
  56144. *
  56145. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56146. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56147. * @param number to convert to percentage
  56148. * @param min min range
  56149. * @param max max range
  56150. * @returns the percentage
  56151. */
  56152. static RangeToPercent(number: number, min: number, max: number): number;
  56153. /**
  56154. * This function returns number that corresponds to the percentage in a given range.
  56155. *
  56156. * PercentToRange(0.34,0,100) will return 34.
  56157. * @param percent to convert to number
  56158. * @param min min range
  56159. * @param max max range
  56160. * @returns the number
  56161. */
  56162. static PercentToRange(percent: number, min: number, max: number): number;
  56163. /**
  56164. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56165. * @param angle The angle to normalize in radian.
  56166. * @return The converted angle.
  56167. */
  56168. static NormalizeRadians(angle: number): number;
  56169. }
  56170. }
  56171. declare module BABYLON {
  56172. /**
  56173. * Constant used to convert a value to gamma space
  56174. * @ignorenaming
  56175. */
  56176. export const ToGammaSpace: number;
  56177. /**
  56178. * Constant used to convert a value to linear space
  56179. * @ignorenaming
  56180. */
  56181. export const ToLinearSpace = 2.2;
  56182. /**
  56183. * Constant used to define the minimal number value in Babylon.js
  56184. * @ignorenaming
  56185. */
  56186. export const Epsilon = 0.001;
  56187. /**
  56188. * Class used to hold a RBG color
  56189. */
  56190. export class Color3 {
  56191. /**
  56192. * Defines the red component (between 0 and 1, default is 0)
  56193. */
  56194. r: number;
  56195. /**
  56196. * Defines the green component (between 0 and 1, default is 0)
  56197. */
  56198. g: number;
  56199. /**
  56200. * Defines the blue component (between 0 and 1, default is 0)
  56201. */
  56202. b: number;
  56203. /**
  56204. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56205. * @param r defines the red component (between 0 and 1, default is 0)
  56206. * @param g defines the green component (between 0 and 1, default is 0)
  56207. * @param b defines the blue component (between 0 and 1, default is 0)
  56208. */
  56209. constructor(
  56210. /**
  56211. * Defines the red component (between 0 and 1, default is 0)
  56212. */
  56213. r?: number,
  56214. /**
  56215. * Defines the green component (between 0 and 1, default is 0)
  56216. */
  56217. g?: number,
  56218. /**
  56219. * Defines the blue component (between 0 and 1, default is 0)
  56220. */
  56221. b?: number);
  56222. /**
  56223. * Creates a string with the Color3 current values
  56224. * @returns the string representation of the Color3 object
  56225. */
  56226. toString(): string;
  56227. /**
  56228. * Returns the string "Color3"
  56229. * @returns "Color3"
  56230. */
  56231. getClassName(): string;
  56232. /**
  56233. * Compute the Color3 hash code
  56234. * @returns an unique number that can be used to hash Color3 objects
  56235. */
  56236. getHashCode(): number;
  56237. /**
  56238. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56239. * @param array defines the array where to store the r,g,b components
  56240. * @param index defines an optional index in the target array to define where to start storing values
  56241. * @returns the current Color3 object
  56242. */
  56243. toArray(array: FloatArray, index?: number): Color3;
  56244. /**
  56245. * Returns a new Color4 object from the current Color3 and the given alpha
  56246. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56247. * @returns a new Color4 object
  56248. */
  56249. toColor4(alpha?: number): Color4;
  56250. /**
  56251. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56252. * @returns the new array
  56253. */
  56254. asArray(): number[];
  56255. /**
  56256. * Returns the luminance value
  56257. * @returns a float value
  56258. */
  56259. toLuminance(): number;
  56260. /**
  56261. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56262. * @param otherColor defines the second operand
  56263. * @returns the new Color3 object
  56264. */
  56265. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56266. /**
  56267. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56268. * @param otherColor defines the second operand
  56269. * @param result defines the Color3 object where to store the result
  56270. * @returns the current Color3
  56271. */
  56272. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56273. /**
  56274. * Determines equality between Color3 objects
  56275. * @param otherColor defines the second operand
  56276. * @returns true if the rgb values are equal to the given ones
  56277. */
  56278. equals(otherColor: DeepImmutable<Color3>): boolean;
  56279. /**
  56280. * Determines equality between the current Color3 object and a set of r,b,g values
  56281. * @param r defines the red component to check
  56282. * @param g defines the green component to check
  56283. * @param b defines the blue component to check
  56284. * @returns true if the rgb values are equal to the given ones
  56285. */
  56286. equalsFloats(r: number, g: number, b: number): boolean;
  56287. /**
  56288. * Multiplies in place each rgb value by scale
  56289. * @param scale defines the scaling factor
  56290. * @returns the updated Color3
  56291. */
  56292. scale(scale: number): Color3;
  56293. /**
  56294. * Multiplies the rgb values by scale and stores the result into "result"
  56295. * @param scale defines the scaling factor
  56296. * @param result defines the Color3 object where to store the result
  56297. * @returns the unmodified current Color3
  56298. */
  56299. scaleToRef(scale: number, result: Color3): Color3;
  56300. /**
  56301. * Scale the current Color3 values by a factor and add the result to a given Color3
  56302. * @param scale defines the scale factor
  56303. * @param result defines color to store the result into
  56304. * @returns the unmodified current Color3
  56305. */
  56306. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56307. /**
  56308. * Clamps the rgb values by the min and max values and stores the result into "result"
  56309. * @param min defines minimum clamping value (default is 0)
  56310. * @param max defines maximum clamping value (default is 1)
  56311. * @param result defines color to store the result into
  56312. * @returns the original Color3
  56313. */
  56314. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56315. /**
  56316. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56317. * @param otherColor defines the second operand
  56318. * @returns the new Color3
  56319. */
  56320. add(otherColor: DeepImmutable<Color3>): Color3;
  56321. /**
  56322. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56323. * @param otherColor defines the second operand
  56324. * @param result defines Color3 object to store the result into
  56325. * @returns the unmodified current Color3
  56326. */
  56327. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56328. /**
  56329. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56330. * @param otherColor defines the second operand
  56331. * @returns the new Color3
  56332. */
  56333. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56334. /**
  56335. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56336. * @param otherColor defines the second operand
  56337. * @param result defines Color3 object to store the result into
  56338. * @returns the unmodified current Color3
  56339. */
  56340. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56341. /**
  56342. * Copy the current object
  56343. * @returns a new Color3 copied the current one
  56344. */
  56345. clone(): Color3;
  56346. /**
  56347. * Copies the rgb values from the source in the current Color3
  56348. * @param source defines the source Color3 object
  56349. * @returns the updated Color3 object
  56350. */
  56351. copyFrom(source: DeepImmutable<Color3>): Color3;
  56352. /**
  56353. * Updates the Color3 rgb values from the given floats
  56354. * @param r defines the red component to read from
  56355. * @param g defines the green component to read from
  56356. * @param b defines the blue component to read from
  56357. * @returns the current Color3 object
  56358. */
  56359. copyFromFloats(r: number, g: number, b: number): Color3;
  56360. /**
  56361. * Updates the Color3 rgb values from the given floats
  56362. * @param r defines the red component to read from
  56363. * @param g defines the green component to read from
  56364. * @param b defines the blue component to read from
  56365. * @returns the current Color3 object
  56366. */
  56367. set(r: number, g: number, b: number): Color3;
  56368. /**
  56369. * Compute the Color3 hexadecimal code as a string
  56370. * @returns a string containing the hexadecimal representation of the Color3 object
  56371. */
  56372. toHexString(): string;
  56373. /**
  56374. * Computes a new Color3 converted from the current one to linear space
  56375. * @returns a new Color3 object
  56376. */
  56377. toLinearSpace(): Color3;
  56378. /**
  56379. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56380. * @param convertedColor defines the Color3 object where to store the linear space version
  56381. * @returns the unmodified Color3
  56382. */
  56383. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56384. /**
  56385. * Computes a new Color3 converted from the current one to gamma space
  56386. * @returns a new Color3 object
  56387. */
  56388. toGammaSpace(): Color3;
  56389. /**
  56390. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56391. * @param convertedColor defines the Color3 object where to store the gamma space version
  56392. * @returns the unmodified Color3
  56393. */
  56394. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56395. private static _BlackReadOnly;
  56396. /**
  56397. * Creates a new Color3 from the string containing valid hexadecimal values
  56398. * @param hex defines a string containing valid hexadecimal values
  56399. * @returns a new Color3 object
  56400. */
  56401. static FromHexString(hex: string): Color3;
  56402. /**
  56403. * Creates a new Vector3 from the starting index of the given array
  56404. * @param array defines the source array
  56405. * @param offset defines an offset in the source array
  56406. * @returns a new Color3 object
  56407. */
  56408. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56409. /**
  56410. * Creates a new Color3 from integer values (< 256)
  56411. * @param r defines the red component to read from (value between 0 and 255)
  56412. * @param g defines the green component to read from (value between 0 and 255)
  56413. * @param b defines the blue component to read from (value between 0 and 255)
  56414. * @returns a new Color3 object
  56415. */
  56416. static FromInts(r: number, g: number, b: number): Color3;
  56417. /**
  56418. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56419. * @param start defines the start Color3 value
  56420. * @param end defines the end Color3 value
  56421. * @param amount defines the gradient value between start and end
  56422. * @returns a new Color3 object
  56423. */
  56424. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56425. /**
  56426. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56427. * @param left defines the start value
  56428. * @param right defines the end value
  56429. * @param amount defines the gradient factor
  56430. * @param result defines the Color3 object where to store the result
  56431. */
  56432. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  56433. /**
  56434. * Returns a Color3 value containing a red color
  56435. * @returns a new Color3 object
  56436. */
  56437. static Red(): Color3;
  56438. /**
  56439. * Returns a Color3 value containing a green color
  56440. * @returns a new Color3 object
  56441. */
  56442. static Green(): Color3;
  56443. /**
  56444. * Returns a Color3 value containing a blue color
  56445. * @returns a new Color3 object
  56446. */
  56447. static Blue(): Color3;
  56448. /**
  56449. * Returns a Color3 value containing a black color
  56450. * @returns a new Color3 object
  56451. */
  56452. static Black(): Color3;
  56453. /**
  56454. * Gets a Color3 value containing a black color that must not be updated
  56455. */
  56456. static readonly BlackReadOnly: DeepImmutable<Color3>;
  56457. /**
  56458. * Returns a Color3 value containing a white color
  56459. * @returns a new Color3 object
  56460. */
  56461. static White(): Color3;
  56462. /**
  56463. * Returns a Color3 value containing a purple color
  56464. * @returns a new Color3 object
  56465. */
  56466. static Purple(): Color3;
  56467. /**
  56468. * Returns a Color3 value containing a magenta color
  56469. * @returns a new Color3 object
  56470. */
  56471. static Magenta(): Color3;
  56472. /**
  56473. * Returns a Color3 value containing a yellow color
  56474. * @returns a new Color3 object
  56475. */
  56476. static Yellow(): Color3;
  56477. /**
  56478. * Returns a Color3 value containing a gray color
  56479. * @returns a new Color3 object
  56480. */
  56481. static Gray(): Color3;
  56482. /**
  56483. * Returns a Color3 value containing a teal color
  56484. * @returns a new Color3 object
  56485. */
  56486. static Teal(): Color3;
  56487. /**
  56488. * Returns a Color3 value containing a random color
  56489. * @returns a new Color3 object
  56490. */
  56491. static Random(): Color3;
  56492. }
  56493. /**
  56494. * Class used to hold a RBGA color
  56495. */
  56496. export class Color4 {
  56497. /**
  56498. * Defines the red component (between 0 and 1, default is 0)
  56499. */
  56500. r: number;
  56501. /**
  56502. * Defines the green component (between 0 and 1, default is 0)
  56503. */
  56504. g: number;
  56505. /**
  56506. * Defines the blue component (between 0 and 1, default is 0)
  56507. */
  56508. b: number;
  56509. /**
  56510. * Defines the alpha component (between 0 and 1, default is 1)
  56511. */
  56512. a: number;
  56513. /**
  56514. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  56515. * @param r defines the red component (between 0 and 1, default is 0)
  56516. * @param g defines the green component (between 0 and 1, default is 0)
  56517. * @param b defines the blue component (between 0 and 1, default is 0)
  56518. * @param a defines the alpha component (between 0 and 1, default is 1)
  56519. */
  56520. constructor(
  56521. /**
  56522. * Defines the red component (between 0 and 1, default is 0)
  56523. */
  56524. r?: number,
  56525. /**
  56526. * Defines the green component (between 0 and 1, default is 0)
  56527. */
  56528. g?: number,
  56529. /**
  56530. * Defines the blue component (between 0 and 1, default is 0)
  56531. */
  56532. b?: number,
  56533. /**
  56534. * Defines the alpha component (between 0 and 1, default is 1)
  56535. */
  56536. a?: number);
  56537. /**
  56538. * Adds in place the given Color4 values to the current Color4 object
  56539. * @param right defines the second operand
  56540. * @returns the current updated Color4 object
  56541. */
  56542. addInPlace(right: DeepImmutable<Color4>): Color4;
  56543. /**
  56544. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  56545. * @returns the new array
  56546. */
  56547. asArray(): number[];
  56548. /**
  56549. * Stores from the starting index in the given array the Color4 successive values
  56550. * @param array defines the array where to store the r,g,b components
  56551. * @param index defines an optional index in the target array to define where to start storing values
  56552. * @returns the current Color4 object
  56553. */
  56554. toArray(array: number[], index?: number): Color4;
  56555. /**
  56556. * Determines equality between Color4 objects
  56557. * @param otherColor defines the second operand
  56558. * @returns true if the rgba values are equal to the given ones
  56559. */
  56560. equals(otherColor: DeepImmutable<Color4>): boolean;
  56561. /**
  56562. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  56563. * @param right defines the second operand
  56564. * @returns a new Color4 object
  56565. */
  56566. add(right: DeepImmutable<Color4>): Color4;
  56567. /**
  56568. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  56569. * @param right defines the second operand
  56570. * @returns a new Color4 object
  56571. */
  56572. subtract(right: DeepImmutable<Color4>): Color4;
  56573. /**
  56574. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  56575. * @param right defines the second operand
  56576. * @param result defines the Color4 object where to store the result
  56577. * @returns the current Color4 object
  56578. */
  56579. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  56580. /**
  56581. * Creates a new Color4 with the current Color4 values multiplied by scale
  56582. * @param scale defines the scaling factor to apply
  56583. * @returns a new Color4 object
  56584. */
  56585. scale(scale: number): Color4;
  56586. /**
  56587. * Multiplies the current Color4 values by scale and stores the result in "result"
  56588. * @param scale defines the scaling factor to apply
  56589. * @param result defines the Color4 object where to store the result
  56590. * @returns the current unmodified Color4
  56591. */
  56592. scaleToRef(scale: number, result: Color4): Color4;
  56593. /**
  56594. * Scale the current Color4 values by a factor and add the result to a given Color4
  56595. * @param scale defines the scale factor
  56596. * @param result defines the Color4 object where to store the result
  56597. * @returns the unmodified current Color4
  56598. */
  56599. scaleAndAddToRef(scale: number, result: Color4): Color4;
  56600. /**
  56601. * Clamps the rgb values by the min and max values and stores the result into "result"
  56602. * @param min defines minimum clamping value (default is 0)
  56603. * @param max defines maximum clamping value (default is 1)
  56604. * @param result defines color to store the result into.
  56605. * @returns the cuurent Color4
  56606. */
  56607. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  56608. /**
  56609. * Multipy an Color4 value by another and return a new Color4 object
  56610. * @param color defines the Color4 value to multiply by
  56611. * @returns a new Color4 object
  56612. */
  56613. multiply(color: Color4): Color4;
  56614. /**
  56615. * Multipy a Color4 value by another and push the result in a reference value
  56616. * @param color defines the Color4 value to multiply by
  56617. * @param result defines the Color4 to fill the result in
  56618. * @returns the result Color4
  56619. */
  56620. multiplyToRef(color: Color4, result: Color4): Color4;
  56621. /**
  56622. * Creates a string with the Color4 current values
  56623. * @returns the string representation of the Color4 object
  56624. */
  56625. toString(): string;
  56626. /**
  56627. * Returns the string "Color4"
  56628. * @returns "Color4"
  56629. */
  56630. getClassName(): string;
  56631. /**
  56632. * Compute the Color4 hash code
  56633. * @returns an unique number that can be used to hash Color4 objects
  56634. */
  56635. getHashCode(): number;
  56636. /**
  56637. * Creates a new Color4 copied from the current one
  56638. * @returns a new Color4 object
  56639. */
  56640. clone(): Color4;
  56641. /**
  56642. * Copies the given Color4 values into the current one
  56643. * @param source defines the source Color4 object
  56644. * @returns the current updated Color4 object
  56645. */
  56646. copyFrom(source: Color4): Color4;
  56647. /**
  56648. * Copies the given float values into the current one
  56649. * @param r defines the red component to read from
  56650. * @param g defines the green component to read from
  56651. * @param b defines the blue component to read from
  56652. * @param a defines the alpha component to read from
  56653. * @returns the current updated Color4 object
  56654. */
  56655. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  56656. /**
  56657. * Copies the given float values into the current one
  56658. * @param r defines the red component to read from
  56659. * @param g defines the green component to read from
  56660. * @param b defines the blue component to read from
  56661. * @param a defines the alpha component to read from
  56662. * @returns the current updated Color4 object
  56663. */
  56664. set(r: number, g: number, b: number, a: number): Color4;
  56665. /**
  56666. * Compute the Color4 hexadecimal code as a string
  56667. * @returns a string containing the hexadecimal representation of the Color4 object
  56668. */
  56669. toHexString(): string;
  56670. /**
  56671. * Computes a new Color4 converted from the current one to linear space
  56672. * @returns a new Color4 object
  56673. */
  56674. toLinearSpace(): Color4;
  56675. /**
  56676. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  56677. * @param convertedColor defines the Color4 object where to store the linear space version
  56678. * @returns the unmodified Color4
  56679. */
  56680. toLinearSpaceToRef(convertedColor: Color4): Color4;
  56681. /**
  56682. * Computes a new Color4 converted from the current one to gamma space
  56683. * @returns a new Color4 object
  56684. */
  56685. toGammaSpace(): Color4;
  56686. /**
  56687. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  56688. * @param convertedColor defines the Color4 object where to store the gamma space version
  56689. * @returns the unmodified Color4
  56690. */
  56691. toGammaSpaceToRef(convertedColor: Color4): Color4;
  56692. /**
  56693. * Creates a new Color4 from the string containing valid hexadecimal values
  56694. * @param hex defines a string containing valid hexadecimal values
  56695. * @returns a new Color4 object
  56696. */
  56697. static FromHexString(hex: string): Color4;
  56698. /**
  56699. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  56700. * @param left defines the start value
  56701. * @param right defines the end value
  56702. * @param amount defines the gradient factor
  56703. * @returns a new Color4 object
  56704. */
  56705. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  56706. /**
  56707. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  56708. * @param left defines the start value
  56709. * @param right defines the end value
  56710. * @param amount defines the gradient factor
  56711. * @param result defines the Color4 object where to store data
  56712. */
  56713. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  56714. /**
  56715. * Creates a new Color4 from a Color3 and an alpha value
  56716. * @param color3 defines the source Color3 to read from
  56717. * @param alpha defines the alpha component (1.0 by default)
  56718. * @returns a new Color4 object
  56719. */
  56720. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  56721. /**
  56722. * Creates a new Color4 from the starting index element of the given array
  56723. * @param array defines the source array to read from
  56724. * @param offset defines the offset in the source array
  56725. * @returns a new Color4 object
  56726. */
  56727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  56728. /**
  56729. * Creates a new Color3 from integer values (< 256)
  56730. * @param r defines the red component to read from (value between 0 and 255)
  56731. * @param g defines the green component to read from (value between 0 and 255)
  56732. * @param b defines the blue component to read from (value between 0 and 255)
  56733. * @param a defines the alpha component to read from (value between 0 and 255)
  56734. * @returns a new Color3 object
  56735. */
  56736. static FromInts(r: number, g: number, b: number, a: number): Color4;
  56737. /**
  56738. * Check the content of a given array and convert it to an array containing RGBA data
  56739. * If the original array was already containing count * 4 values then it is returned directly
  56740. * @param colors defines the array to check
  56741. * @param count defines the number of RGBA data to expect
  56742. * @returns an array containing count * 4 values (RGBA)
  56743. */
  56744. static CheckColors4(colors: number[], count: number): number[];
  56745. }
  56746. /**
  56747. * Class representing a vector containing 2 coordinates
  56748. */
  56749. export class Vector2 {
  56750. /** defines the first coordinate */
  56751. x: number;
  56752. /** defines the second coordinate */
  56753. y: number;
  56754. /**
  56755. * Creates a new Vector2 from the given x and y coordinates
  56756. * @param x defines the first coordinate
  56757. * @param y defines the second coordinate
  56758. */
  56759. constructor(
  56760. /** defines the first coordinate */
  56761. x?: number,
  56762. /** defines the second coordinate */
  56763. y?: number);
  56764. /**
  56765. * Gets a string with the Vector2 coordinates
  56766. * @returns a string with the Vector2 coordinates
  56767. */
  56768. toString(): string;
  56769. /**
  56770. * Gets class name
  56771. * @returns the string "Vector2"
  56772. */
  56773. getClassName(): string;
  56774. /**
  56775. * Gets current vector hash code
  56776. * @returns the Vector2 hash code as a number
  56777. */
  56778. getHashCode(): number;
  56779. /**
  56780. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  56781. * @param array defines the source array
  56782. * @param index defines the offset in source array
  56783. * @returns the current Vector2
  56784. */
  56785. toArray(array: FloatArray, index?: number): Vector2;
  56786. /**
  56787. * Copy the current vector to an array
  56788. * @returns a new array with 2 elements: the Vector2 coordinates.
  56789. */
  56790. asArray(): number[];
  56791. /**
  56792. * Sets the Vector2 coordinates with the given Vector2 coordinates
  56793. * @param source defines the source Vector2
  56794. * @returns the current updated Vector2
  56795. */
  56796. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  56797. /**
  56798. * Sets the Vector2 coordinates with the given floats
  56799. * @param x defines the first coordinate
  56800. * @param y defines the second coordinate
  56801. * @returns the current updated Vector2
  56802. */
  56803. copyFromFloats(x: number, y: number): Vector2;
  56804. /**
  56805. * Sets the Vector2 coordinates with the given floats
  56806. * @param x defines the first coordinate
  56807. * @param y defines the second coordinate
  56808. * @returns the current updated Vector2
  56809. */
  56810. set(x: number, y: number): Vector2;
  56811. /**
  56812. * Add another vector with the current one
  56813. * @param otherVector defines the other vector
  56814. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  56815. */
  56816. add(otherVector: DeepImmutable<Vector2>): Vector2;
  56817. /**
  56818. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  56819. * @param otherVector defines the other vector
  56820. * @param result defines the target vector
  56821. * @returns the unmodified current Vector2
  56822. */
  56823. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  56824. /**
  56825. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  56826. * @param otherVector defines the other vector
  56827. * @returns the current updated Vector2
  56828. */
  56829. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  56830. /**
  56831. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  56832. * @param otherVector defines the other vector
  56833. * @returns a new Vector2
  56834. */
  56835. addVector3(otherVector: Vector3): Vector2;
  56836. /**
  56837. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  56838. * @param otherVector defines the other vector
  56839. * @returns a new Vector2
  56840. */
  56841. subtract(otherVector: Vector2): Vector2;
  56842. /**
  56843. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  56844. * @param otherVector defines the other vector
  56845. * @param result defines the target vector
  56846. * @returns the unmodified current Vector2
  56847. */
  56848. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  56849. /**
  56850. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  56851. * @param otherVector defines the other vector
  56852. * @returns the current updated Vector2
  56853. */
  56854. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  56855. /**
  56856. * Multiplies in place the current Vector2 coordinates by the given ones
  56857. * @param otherVector defines the other vector
  56858. * @returns the current updated Vector2
  56859. */
  56860. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  56861. /**
  56862. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  56863. * @param otherVector defines the other vector
  56864. * @returns a new Vector2
  56865. */
  56866. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  56867. /**
  56868. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  56869. * @param otherVector defines the other vector
  56870. * @param result defines the target vector
  56871. * @returns the unmodified current Vector2
  56872. */
  56873. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  56874. /**
  56875. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  56876. * @param x defines the first coordinate
  56877. * @param y defines the second coordinate
  56878. * @returns a new Vector2
  56879. */
  56880. multiplyByFloats(x: number, y: number): Vector2;
  56881. /**
  56882. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  56883. * @param otherVector defines the other vector
  56884. * @returns a new Vector2
  56885. */
  56886. divide(otherVector: Vector2): Vector2;
  56887. /**
  56888. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  56889. * @param otherVector defines the other vector
  56890. * @param result defines the target vector
  56891. * @returns the unmodified current Vector2
  56892. */
  56893. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  56894. /**
  56895. * Divides the current Vector2 coordinates by the given ones
  56896. * @param otherVector defines the other vector
  56897. * @returns the current updated Vector2
  56898. */
  56899. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  56900. /**
  56901. * Gets a new Vector2 with current Vector2 negated coordinates
  56902. * @returns a new Vector2
  56903. */
  56904. negate(): Vector2;
  56905. /**
  56906. * Multiply the Vector2 coordinates by scale
  56907. * @param scale defines the scaling factor
  56908. * @returns the current updated Vector2
  56909. */
  56910. scaleInPlace(scale: number): Vector2;
  56911. /**
  56912. * Returns a new Vector2 scaled by "scale" from the current Vector2
  56913. * @param scale defines the scaling factor
  56914. * @returns a new Vector2
  56915. */
  56916. scale(scale: number): Vector2;
  56917. /**
  56918. * Scale the current Vector2 values by a factor to a given Vector2
  56919. * @param scale defines the scale factor
  56920. * @param result defines the Vector2 object where to store the result
  56921. * @returns the unmodified current Vector2
  56922. */
  56923. scaleToRef(scale: number, result: Vector2): Vector2;
  56924. /**
  56925. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  56926. * @param scale defines the scale factor
  56927. * @param result defines the Vector2 object where to store the result
  56928. * @returns the unmodified current Vector2
  56929. */
  56930. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  56931. /**
  56932. * Gets a boolean if two vectors are equals
  56933. * @param otherVector defines the other vector
  56934. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  56935. */
  56936. equals(otherVector: DeepImmutable<Vector2>): boolean;
  56937. /**
  56938. * Gets a boolean if two vectors are equals (using an epsilon value)
  56939. * @param otherVector defines the other vector
  56940. * @param epsilon defines the minimal distance to consider equality
  56941. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  56942. */
  56943. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  56944. /**
  56945. * Gets a new Vector2 from current Vector2 floored values
  56946. * @returns a new Vector2
  56947. */
  56948. floor(): Vector2;
  56949. /**
  56950. * Gets a new Vector2 from current Vector2 floored values
  56951. * @returns a new Vector2
  56952. */
  56953. fract(): Vector2;
  56954. /**
  56955. * Gets the length of the vector
  56956. * @returns the vector length (float)
  56957. */
  56958. length(): number;
  56959. /**
  56960. * Gets the vector squared length
  56961. * @returns the vector squared length (float)
  56962. */
  56963. lengthSquared(): number;
  56964. /**
  56965. * Normalize the vector
  56966. * @returns the current updated Vector2
  56967. */
  56968. normalize(): Vector2;
  56969. /**
  56970. * Gets a new Vector2 copied from the Vector2
  56971. * @returns a new Vector2
  56972. */
  56973. clone(): Vector2;
  56974. /**
  56975. * Gets a new Vector2(0, 0)
  56976. * @returns a new Vector2
  56977. */
  56978. static Zero(): Vector2;
  56979. /**
  56980. * Gets a new Vector2(1, 1)
  56981. * @returns a new Vector2
  56982. */
  56983. static One(): Vector2;
  56984. /**
  56985. * Gets a new Vector2 set from the given index element of the given array
  56986. * @param array defines the data source
  56987. * @param offset defines the offset in the data source
  56988. * @returns a new Vector2
  56989. */
  56990. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  56991. /**
  56992. * Sets "result" from the given index element of the given array
  56993. * @param array defines the data source
  56994. * @param offset defines the offset in the data source
  56995. * @param result defines the target vector
  56996. */
  56997. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  56998. /**
  56999. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57000. * @param value1 defines 1st point of control
  57001. * @param value2 defines 2nd point of control
  57002. * @param value3 defines 3rd point of control
  57003. * @param value4 defines 4th point of control
  57004. * @param amount defines the interpolation factor
  57005. * @returns a new Vector2
  57006. */
  57007. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57008. /**
  57009. * 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".
  57010. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57011. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57012. * @param value defines the value to clamp
  57013. * @param min defines the lower limit
  57014. * @param max defines the upper limit
  57015. * @returns a new Vector2
  57016. */
  57017. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57018. /**
  57019. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57020. * @param value1 defines the 1st control point
  57021. * @param tangent1 defines the outgoing tangent
  57022. * @param value2 defines the 2nd control point
  57023. * @param tangent2 defines the incoming tangent
  57024. * @param amount defines the interpolation factor
  57025. * @returns a new Vector2
  57026. */
  57027. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57028. /**
  57029. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57030. * @param start defines the start vector
  57031. * @param end defines the end vector
  57032. * @param amount defines the interpolation factor
  57033. * @returns a new Vector2
  57034. */
  57035. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57036. /**
  57037. * Gets the dot product of the vector "left" and the vector "right"
  57038. * @param left defines first vector
  57039. * @param right defines second vector
  57040. * @returns the dot product (float)
  57041. */
  57042. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57043. /**
  57044. * Returns a new Vector2 equal to the normalized given vector
  57045. * @param vector defines the vector to normalize
  57046. * @returns a new Vector2
  57047. */
  57048. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57049. /**
  57050. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57051. * @param left defines 1st vector
  57052. * @param right defines 2nd vector
  57053. * @returns a new Vector2
  57054. */
  57055. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57056. /**
  57057. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57058. * @param left defines 1st vector
  57059. * @param right defines 2nd vector
  57060. * @returns a new Vector2
  57061. */
  57062. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57063. /**
  57064. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57065. * @param vector defines the vector to transform
  57066. * @param transformation defines the matrix to apply
  57067. * @returns a new Vector2
  57068. */
  57069. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57070. /**
  57071. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57072. * @param vector defines the vector to transform
  57073. * @param transformation defines the matrix to apply
  57074. * @param result defines the target vector
  57075. */
  57076. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57077. /**
  57078. * Determines if a given vector is included in a triangle
  57079. * @param p defines the vector to test
  57080. * @param p0 defines 1st triangle point
  57081. * @param p1 defines 2nd triangle point
  57082. * @param p2 defines 3rd triangle point
  57083. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57084. */
  57085. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57086. /**
  57087. * Gets the distance between the vectors "value1" and "value2"
  57088. * @param value1 defines first vector
  57089. * @param value2 defines second vector
  57090. * @returns the distance between vectors
  57091. */
  57092. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57093. /**
  57094. * Returns the squared distance between the vectors "value1" and "value2"
  57095. * @param value1 defines first vector
  57096. * @param value2 defines second vector
  57097. * @returns the squared distance between vectors
  57098. */
  57099. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57100. /**
  57101. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57102. * @param value1 defines first vector
  57103. * @param value2 defines second vector
  57104. * @returns a new Vector2
  57105. */
  57106. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57107. /**
  57108. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57109. * @param p defines the middle point
  57110. * @param segA defines one point of the segment
  57111. * @param segB defines the other point of the segment
  57112. * @returns the shortest distance
  57113. */
  57114. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57115. }
  57116. /**
  57117. * Classed used to store (x,y,z) vector representation
  57118. * A Vector3 is the main object used in 3D geometry
  57119. * It can represent etiher the coordinates of a point the space, either a direction
  57120. * Reminder: js uses a left handed forward facing system
  57121. */
  57122. export class Vector3 {
  57123. /**
  57124. * Defines the first coordinates (on X axis)
  57125. */
  57126. x: number;
  57127. /**
  57128. * Defines the second coordinates (on Y axis)
  57129. */
  57130. y: number;
  57131. /**
  57132. * Defines the third coordinates (on Z axis)
  57133. */
  57134. z: number;
  57135. private static _UpReadOnly;
  57136. /**
  57137. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57138. * @param x defines the first coordinates (on X axis)
  57139. * @param y defines the second coordinates (on Y axis)
  57140. * @param z defines the third coordinates (on Z axis)
  57141. */
  57142. constructor(
  57143. /**
  57144. * Defines the first coordinates (on X axis)
  57145. */
  57146. x?: number,
  57147. /**
  57148. * Defines the second coordinates (on Y axis)
  57149. */
  57150. y?: number,
  57151. /**
  57152. * Defines the third coordinates (on Z axis)
  57153. */
  57154. z?: number);
  57155. /**
  57156. * Creates a string representation of the Vector3
  57157. * @returns a string with the Vector3 coordinates.
  57158. */
  57159. toString(): string;
  57160. /**
  57161. * Gets the class name
  57162. * @returns the string "Vector3"
  57163. */
  57164. getClassName(): string;
  57165. /**
  57166. * Creates the Vector3 hash code
  57167. * @returns a number which tends to be unique between Vector3 instances
  57168. */
  57169. getHashCode(): number;
  57170. /**
  57171. * Creates an array containing three elements : the coordinates of the Vector3
  57172. * @returns a new array of numbers
  57173. */
  57174. asArray(): number[];
  57175. /**
  57176. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57177. * @param array defines the destination array
  57178. * @param index defines the offset in the destination array
  57179. * @returns the current Vector3
  57180. */
  57181. toArray(array: FloatArray, index?: number): Vector3;
  57182. /**
  57183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57185. */
  57186. toQuaternion(): Quaternion;
  57187. /**
  57188. * Adds the given vector to the current Vector3
  57189. * @param otherVector defines the second operand
  57190. * @returns the current updated Vector3
  57191. */
  57192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57193. /**
  57194. * Adds the given coordinates to the current Vector3
  57195. * @param x defines the x coordinate of the operand
  57196. * @param y defines the y coordinate of the operand
  57197. * @param z defines the z coordinate of the operand
  57198. * @returns the current updated Vector3
  57199. */
  57200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57201. /**
  57202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57203. * @param otherVector defines the second operand
  57204. * @returns the resulting Vector3
  57205. */
  57206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57207. /**
  57208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57209. * @param otherVector defines the second operand
  57210. * @param result defines the Vector3 object where to store the result
  57211. * @returns the current Vector3
  57212. */
  57213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57214. /**
  57215. * Subtract the given vector from the current Vector3
  57216. * @param otherVector defines the second operand
  57217. * @returns the current updated Vector3
  57218. */
  57219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57220. /**
  57221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57222. * @param otherVector defines the second operand
  57223. * @returns the resulting Vector3
  57224. */
  57225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57226. /**
  57227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57228. * @param otherVector defines the second operand
  57229. * @param result defines the Vector3 object where to store the result
  57230. * @returns the current Vector3
  57231. */
  57232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57233. /**
  57234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57235. * @param x defines the x coordinate of the operand
  57236. * @param y defines the y coordinate of the operand
  57237. * @param z defines the z coordinate of the operand
  57238. * @returns the resulting Vector3
  57239. */
  57240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57241. /**
  57242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57243. * @param x defines the x coordinate of the operand
  57244. * @param y defines the y coordinate of the operand
  57245. * @param z defines the z coordinate of the operand
  57246. * @param result defines the Vector3 object where to store the result
  57247. * @returns the current Vector3
  57248. */
  57249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57250. /**
  57251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57252. * @returns a new Vector3
  57253. */
  57254. negate(): Vector3;
  57255. /**
  57256. * Multiplies the Vector3 coordinates by the float "scale"
  57257. * @param scale defines the multiplier factor
  57258. * @returns the current updated Vector3
  57259. */
  57260. scaleInPlace(scale: number): Vector3;
  57261. /**
  57262. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57263. * @param scale defines the multiplier factor
  57264. * @returns a new Vector3
  57265. */
  57266. scale(scale: number): Vector3;
  57267. /**
  57268. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57269. * @param scale defines the multiplier factor
  57270. * @param result defines the Vector3 object where to store the result
  57271. * @returns the current Vector3
  57272. */
  57273. scaleToRef(scale: number, result: Vector3): Vector3;
  57274. /**
  57275. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57276. * @param scale defines the scale factor
  57277. * @param result defines the Vector3 object where to store the result
  57278. * @returns the unmodified current Vector3
  57279. */
  57280. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57281. /**
  57282. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57283. * @param otherVector defines the second operand
  57284. * @returns true if both vectors are equals
  57285. */
  57286. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57287. /**
  57288. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57289. * @param otherVector defines the second operand
  57290. * @param epsilon defines the minimal distance to define values as equals
  57291. * @returns true if both vectors are distant less than epsilon
  57292. */
  57293. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57294. /**
  57295. * Returns true if the current Vector3 coordinates equals the given floats
  57296. * @param x defines the x coordinate of the operand
  57297. * @param y defines the y coordinate of the operand
  57298. * @param z defines the z coordinate of the operand
  57299. * @returns true if both vectors are equals
  57300. */
  57301. equalsToFloats(x: number, y: number, z: number): boolean;
  57302. /**
  57303. * Multiplies the current Vector3 coordinates by the given ones
  57304. * @param otherVector defines the second operand
  57305. * @returns the current updated Vector3
  57306. */
  57307. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57308. /**
  57309. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57310. * @param otherVector defines the second operand
  57311. * @returns the new Vector3
  57312. */
  57313. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57314. /**
  57315. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57316. * @param otherVector defines the second operand
  57317. * @param result defines the Vector3 object where to store the result
  57318. * @returns the current Vector3
  57319. */
  57320. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57321. /**
  57322. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57323. * @param x defines the x coordinate of the operand
  57324. * @param y defines the y coordinate of the operand
  57325. * @param z defines the z coordinate of the operand
  57326. * @returns the new Vector3
  57327. */
  57328. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57329. /**
  57330. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57331. * @param otherVector defines the second operand
  57332. * @returns the new Vector3
  57333. */
  57334. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57335. /**
  57336. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57337. * @param otherVector defines the second operand
  57338. * @param result defines the Vector3 object where to store the result
  57339. * @returns the current Vector3
  57340. */
  57341. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57342. /**
  57343. * Divides the current Vector3 coordinates by the given ones.
  57344. * @param otherVector defines the second operand
  57345. * @returns the current updated Vector3
  57346. */
  57347. divideInPlace(otherVector: Vector3): Vector3;
  57348. /**
  57349. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57350. * @param other defines the second operand
  57351. * @returns the current updated Vector3
  57352. */
  57353. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57354. /**
  57355. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57356. * @param other defines the second operand
  57357. * @returns the current updated Vector3
  57358. */
  57359. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57360. /**
  57361. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57362. * @param x defines the x coordinate of the operand
  57363. * @param y defines the y coordinate of the operand
  57364. * @param z defines the z coordinate of the operand
  57365. * @returns the current updated Vector3
  57366. */
  57367. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57368. /**
  57369. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57370. * @param x defines the x coordinate of the operand
  57371. * @param y defines the y coordinate of the operand
  57372. * @param z defines the z coordinate of the operand
  57373. * @returns the current updated Vector3
  57374. */
  57375. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57376. /**
  57377. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57378. * Check if is non uniform within a certain amount of decimal places to account for this
  57379. * @param epsilon the amount the values can differ
  57380. * @returns if the the vector is non uniform to a certain number of decimal places
  57381. */
  57382. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57383. /**
  57384. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57385. */
  57386. readonly isNonUniform: boolean;
  57387. /**
  57388. * Gets a new Vector3 from current Vector3 floored values
  57389. * @returns a new Vector3
  57390. */
  57391. floor(): Vector3;
  57392. /**
  57393. * Gets a new Vector3 from current Vector3 floored values
  57394. * @returns a new Vector3
  57395. */
  57396. fract(): Vector3;
  57397. /**
  57398. * Gets the length of the Vector3
  57399. * @returns the length of the Vecto3
  57400. */
  57401. length(): number;
  57402. /**
  57403. * Gets the squared length of the Vector3
  57404. * @returns squared length of the Vector3
  57405. */
  57406. lengthSquared(): number;
  57407. /**
  57408. * Normalize the current Vector3.
  57409. * Please note that this is an in place operation.
  57410. * @returns the current updated Vector3
  57411. */
  57412. normalize(): Vector3;
  57413. /**
  57414. * Reorders the x y z properties of the vector in place
  57415. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57416. * @returns the current updated vector
  57417. */
  57418. reorderInPlace(order: string): this;
  57419. /**
  57420. * Rotates the vector around 0,0,0 by a quaternion
  57421. * @param quaternion the rotation quaternion
  57422. * @param result vector to store the result
  57423. * @returns the resulting vector
  57424. */
  57425. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57426. /**
  57427. * Rotates a vector around a given point
  57428. * @param quaternion the rotation quaternion
  57429. * @param point the point to rotate around
  57430. * @param result vector to store the result
  57431. * @returns the resulting vector
  57432. */
  57433. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  57434. /**
  57435. * Normalize the current Vector3 with the given input length.
  57436. * Please note that this is an in place operation.
  57437. * @param len the length of the vector
  57438. * @returns the current updated Vector3
  57439. */
  57440. normalizeFromLength(len: number): Vector3;
  57441. /**
  57442. * Normalize the current Vector3 to a new vector
  57443. * @returns the new Vector3
  57444. */
  57445. normalizeToNew(): Vector3;
  57446. /**
  57447. * Normalize the current Vector3 to the reference
  57448. * @param reference define the Vector3 to update
  57449. * @returns the updated Vector3
  57450. */
  57451. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  57452. /**
  57453. * Creates a new Vector3 copied from the current Vector3
  57454. * @returns the new Vector3
  57455. */
  57456. clone(): Vector3;
  57457. /**
  57458. * Copies the given vector coordinates to the current Vector3 ones
  57459. * @param source defines the source Vector3
  57460. * @returns the current updated Vector3
  57461. */
  57462. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  57463. /**
  57464. * Copies the given floats to the current Vector3 coordinates
  57465. * @param x defines the x coordinate of the operand
  57466. * @param y defines the y coordinate of the operand
  57467. * @param z defines the z coordinate of the operand
  57468. * @returns the current updated Vector3
  57469. */
  57470. copyFromFloats(x: number, y: number, z: number): Vector3;
  57471. /**
  57472. * Copies the given floats to the current Vector3 coordinates
  57473. * @param x defines the x coordinate of the operand
  57474. * @param y defines the y coordinate of the operand
  57475. * @param z defines the z coordinate of the operand
  57476. * @returns the current updated Vector3
  57477. */
  57478. set(x: number, y: number, z: number): Vector3;
  57479. /**
  57480. * Copies the given float to the current Vector3 coordinates
  57481. * @param v defines the x, y and z coordinates of the operand
  57482. * @returns the current updated Vector3
  57483. */
  57484. setAll(v: number): Vector3;
  57485. /**
  57486. * Get the clip factor between two vectors
  57487. * @param vector0 defines the first operand
  57488. * @param vector1 defines the second operand
  57489. * @param axis defines the axis to use
  57490. * @param size defines the size along the axis
  57491. * @returns the clip factor
  57492. */
  57493. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  57494. /**
  57495. * Get angle between two vectors
  57496. * @param vector0 angle between vector0 and vector1
  57497. * @param vector1 angle between vector0 and vector1
  57498. * @param normal direction of the normal
  57499. * @return the angle between vector0 and vector1
  57500. */
  57501. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  57502. /**
  57503. * Returns a new Vector3 set from the index "offset" of the given array
  57504. * @param array defines the source array
  57505. * @param offset defines the offset in the source array
  57506. * @returns the new Vector3
  57507. */
  57508. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  57509. /**
  57510. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  57511. * This function is deprecated. Use FromArray instead
  57512. * @param array defines the source array
  57513. * @param offset defines the offset in the source array
  57514. * @returns the new Vector3
  57515. */
  57516. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  57517. /**
  57518. * Sets the given vector "result" with the element values from the index "offset" of the given array
  57519. * @param array defines the source array
  57520. * @param offset defines the offset in the source array
  57521. * @param result defines the Vector3 where to store the result
  57522. */
  57523. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  57524. /**
  57525. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  57526. * This function is deprecated. Use FromArrayToRef instead.
  57527. * @param array defines the source array
  57528. * @param offset defines the offset in the source array
  57529. * @param result defines the Vector3 where to store the result
  57530. */
  57531. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  57532. /**
  57533. * Sets the given vector "result" with the given floats.
  57534. * @param x defines the x coordinate of the source
  57535. * @param y defines the y coordinate of the source
  57536. * @param z defines the z coordinate of the source
  57537. * @param result defines the Vector3 where to store the result
  57538. */
  57539. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  57540. /**
  57541. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  57542. * @returns a new empty Vector3
  57543. */
  57544. static Zero(): Vector3;
  57545. /**
  57546. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  57547. * @returns a new unit Vector3
  57548. */
  57549. static One(): Vector3;
  57550. /**
  57551. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  57552. * @returns a new up Vector3
  57553. */
  57554. static Up(): Vector3;
  57555. /**
  57556. * Gets a up Vector3 that must not be updated
  57557. */
  57558. static readonly UpReadOnly: DeepImmutable<Vector3>;
  57559. /**
  57560. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  57561. * @returns a new down Vector3
  57562. */
  57563. static Down(): Vector3;
  57564. /**
  57565. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  57566. * @returns a new forward Vector3
  57567. */
  57568. static Forward(): Vector3;
  57569. /**
  57570. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  57571. * @returns a new forward Vector3
  57572. */
  57573. static Backward(): Vector3;
  57574. /**
  57575. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  57576. * @returns a new right Vector3
  57577. */
  57578. static Right(): Vector3;
  57579. /**
  57580. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  57581. * @returns a new left Vector3
  57582. */
  57583. static Left(): Vector3;
  57584. /**
  57585. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  57586. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  57587. * @param vector defines the Vector3 to transform
  57588. * @param transformation defines the transformation matrix
  57589. * @returns the transformed Vector3
  57590. */
  57591. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  57592. /**
  57593. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  57594. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  57595. * @param vector defines the Vector3 to transform
  57596. * @param transformation defines the transformation matrix
  57597. * @param result defines the Vector3 where to store the result
  57598. */
  57599. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  57600. /**
  57601. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  57602. * This method computes tranformed coordinates only, not transformed direction vectors
  57603. * @param x define the x coordinate of the source vector
  57604. * @param y define the y coordinate of the source vector
  57605. * @param z define the z coordinate of the source vector
  57606. * @param transformation defines the transformation matrix
  57607. * @param result defines the Vector3 where to store the result
  57608. */
  57609. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  57610. /**
  57611. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  57612. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  57613. * @param vector defines the Vector3 to transform
  57614. * @param transformation defines the transformation matrix
  57615. * @returns the new Vector3
  57616. */
  57617. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  57618. /**
  57619. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  57620. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  57621. * @param vector defines the Vector3 to transform
  57622. * @param transformation defines the transformation matrix
  57623. * @param result defines the Vector3 where to store the result
  57624. */
  57625. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  57626. /**
  57627. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  57628. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  57629. * @param x define the x coordinate of the source vector
  57630. * @param y define the y coordinate of the source vector
  57631. * @param z define the z coordinate of the source vector
  57632. * @param transformation defines the transformation matrix
  57633. * @param result defines the Vector3 where to store the result
  57634. */
  57635. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  57636. /**
  57637. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  57638. * @param value1 defines the first control point
  57639. * @param value2 defines the second control point
  57640. * @param value3 defines the third control point
  57641. * @param value4 defines the fourth control point
  57642. * @param amount defines the amount on the spline to use
  57643. * @returns the new Vector3
  57644. */
  57645. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  57646. /**
  57647. * 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"
  57648. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  57649. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  57650. * @param value defines the current value
  57651. * @param min defines the lower range value
  57652. * @param max defines the upper range value
  57653. * @returns the new Vector3
  57654. */
  57655. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  57656. /**
  57657. * 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"
  57658. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  57659. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  57660. * @param value defines the current value
  57661. * @param min defines the lower range value
  57662. * @param max defines the upper range value
  57663. * @param result defines the Vector3 where to store the result
  57664. */
  57665. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  57666. /**
  57667. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  57668. * @param value1 defines the first control point
  57669. * @param tangent1 defines the first tangent vector
  57670. * @param value2 defines the second control point
  57671. * @param tangent2 defines the second tangent vector
  57672. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  57673. * @returns the new Vector3
  57674. */
  57675. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  57676. /**
  57677. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  57678. * @param start defines the start value
  57679. * @param end defines the end value
  57680. * @param amount max defines amount between both (between 0 and 1)
  57681. * @returns the new Vector3
  57682. */
  57683. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  57684. /**
  57685. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  57686. * @param start defines the start value
  57687. * @param end defines the end value
  57688. * @param amount max defines amount between both (between 0 and 1)
  57689. * @param result defines the Vector3 where to store the result
  57690. */
  57691. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  57692. /**
  57693. * Returns the dot product (float) between the vectors "left" and "right"
  57694. * @param left defines the left operand
  57695. * @param right defines the right operand
  57696. * @returns the dot product
  57697. */
  57698. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  57699. /**
  57700. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  57701. * The cross product is then orthogonal to both "left" and "right"
  57702. * @param left defines the left operand
  57703. * @param right defines the right operand
  57704. * @returns the cross product
  57705. */
  57706. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  57707. /**
  57708. * Sets the given vector "result" with the cross product of "left" and "right"
  57709. * The cross product is then orthogonal to both "left" and "right"
  57710. * @param left defines the left operand
  57711. * @param right defines the right operand
  57712. * @param result defines the Vector3 where to store the result
  57713. */
  57714. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  57715. /**
  57716. * Returns a new Vector3 as the normalization of the given vector
  57717. * @param vector defines the Vector3 to normalize
  57718. * @returns the new Vector3
  57719. */
  57720. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  57721. /**
  57722. * Sets the given vector "result" with the normalization of the given first vector
  57723. * @param vector defines the Vector3 to normalize
  57724. * @param result defines the Vector3 where to store the result
  57725. */
  57726. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  57727. /**
  57728. * Project a Vector3 onto screen space
  57729. * @param vector defines the Vector3 to project
  57730. * @param world defines the world matrix to use
  57731. * @param transform defines the transform (view x projection) matrix to use
  57732. * @param viewport defines the screen viewport to use
  57733. * @returns the new Vector3
  57734. */
  57735. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  57736. /** @hidden */
  57737. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  57738. /**
  57739. * Unproject from screen space to object space
  57740. * @param source defines the screen space Vector3 to use
  57741. * @param viewportWidth defines the current width of the viewport
  57742. * @param viewportHeight defines the current height of the viewport
  57743. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  57744. * @param transform defines the transform (view x projection) matrix to use
  57745. * @returns the new Vector3
  57746. */
  57747. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  57748. /**
  57749. * Unproject from screen space to object space
  57750. * @param source defines the screen space Vector3 to use
  57751. * @param viewportWidth defines the current width of the viewport
  57752. * @param viewportHeight defines the current height of the viewport
  57753. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  57754. * @param view defines the view matrix to use
  57755. * @param projection defines the projection matrix to use
  57756. * @returns the new Vector3
  57757. */
  57758. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  57759. /**
  57760. * Unproject from screen space to object space
  57761. * @param source defines the screen space Vector3 to use
  57762. * @param viewportWidth defines the current width of the viewport
  57763. * @param viewportHeight defines the current height of the viewport
  57764. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  57765. * @param view defines the view matrix to use
  57766. * @param projection defines the projection matrix to use
  57767. * @param result defines the Vector3 where to store the result
  57768. */
  57769. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  57770. /**
  57771. * Unproject from screen space to object space
  57772. * @param sourceX defines the screen space x coordinate to use
  57773. * @param sourceY defines the screen space y coordinate to use
  57774. * @param sourceZ defines the screen space z coordinate to use
  57775. * @param viewportWidth defines the current width of the viewport
  57776. * @param viewportHeight defines the current height of the viewport
  57777. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  57778. * @param view defines the view matrix to use
  57779. * @param projection defines the projection matrix to use
  57780. * @param result defines the Vector3 where to store the result
  57781. */
  57782. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  57783. /**
  57784. * Gets the minimal coordinate values between two Vector3
  57785. * @param left defines the first operand
  57786. * @param right defines the second operand
  57787. * @returns the new Vector3
  57788. */
  57789. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  57790. /**
  57791. * Gets the maximal coordinate values between two Vector3
  57792. * @param left defines the first operand
  57793. * @param right defines the second operand
  57794. * @returns the new Vector3
  57795. */
  57796. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  57797. /**
  57798. * Returns the distance between the vectors "value1" and "value2"
  57799. * @param value1 defines the first operand
  57800. * @param value2 defines the second operand
  57801. * @returns the distance
  57802. */
  57803. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  57804. /**
  57805. * Returns the squared distance between the vectors "value1" and "value2"
  57806. * @param value1 defines the first operand
  57807. * @param value2 defines the second operand
  57808. * @returns the squared distance
  57809. */
  57810. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  57811. /**
  57812. * Returns a new Vector3 located at the center between "value1" and "value2"
  57813. * @param value1 defines the first operand
  57814. * @param value2 defines the second operand
  57815. * @returns the new Vector3
  57816. */
  57817. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  57818. /**
  57819. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  57820. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  57821. * to something in order to rotate it from its local system to the given target system
  57822. * Note: axis1, axis2 and axis3 are normalized during this operation
  57823. * @param axis1 defines the first axis
  57824. * @param axis2 defines the second axis
  57825. * @param axis3 defines the third axis
  57826. * @returns a new Vector3
  57827. */
  57828. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  57829. /**
  57830. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  57831. * @param axis1 defines the first axis
  57832. * @param axis2 defines the second axis
  57833. * @param axis3 defines the third axis
  57834. * @param ref defines the Vector3 where to store the result
  57835. */
  57836. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  57837. }
  57838. /**
  57839. * Vector4 class created for EulerAngle class conversion to Quaternion
  57840. */
  57841. export class Vector4 {
  57842. /** x value of the vector */
  57843. x: number;
  57844. /** y value of the vector */
  57845. y: number;
  57846. /** z value of the vector */
  57847. z: number;
  57848. /** w value of the vector */
  57849. w: number;
  57850. /**
  57851. * Creates a Vector4 object from the given floats.
  57852. * @param x x value of the vector
  57853. * @param y y value of the vector
  57854. * @param z z value of the vector
  57855. * @param w w value of the vector
  57856. */
  57857. constructor(
  57858. /** x value of the vector */
  57859. x: number,
  57860. /** y value of the vector */
  57861. y: number,
  57862. /** z value of the vector */
  57863. z: number,
  57864. /** w value of the vector */
  57865. w: number);
  57866. /**
  57867. * Returns the string with the Vector4 coordinates.
  57868. * @returns a string containing all the vector values
  57869. */
  57870. toString(): string;
  57871. /**
  57872. * Returns the string "Vector4".
  57873. * @returns "Vector4"
  57874. */
  57875. getClassName(): string;
  57876. /**
  57877. * Returns the Vector4 hash code.
  57878. * @returns a unique hash code
  57879. */
  57880. getHashCode(): number;
  57881. /**
  57882. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  57883. * @returns the resulting array
  57884. */
  57885. asArray(): number[];
  57886. /**
  57887. * Populates the given array from the given index with the Vector4 coordinates.
  57888. * @param array array to populate
  57889. * @param index index of the array to start at (default: 0)
  57890. * @returns the Vector4.
  57891. */
  57892. toArray(array: FloatArray, index?: number): Vector4;
  57893. /**
  57894. * Adds the given vector to the current Vector4.
  57895. * @param otherVector the vector to add
  57896. * @returns the updated Vector4.
  57897. */
  57898. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  57899. /**
  57900. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  57901. * @param otherVector the vector to add
  57902. * @returns the resulting vector
  57903. */
  57904. add(otherVector: DeepImmutable<Vector4>): Vector4;
  57905. /**
  57906. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  57907. * @param otherVector the vector to add
  57908. * @param result the vector to store the result
  57909. * @returns the current Vector4.
  57910. */
  57911. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  57912. /**
  57913. * Subtract in place the given vector from the current Vector4.
  57914. * @param otherVector the vector to subtract
  57915. * @returns the updated Vector4.
  57916. */
  57917. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  57918. /**
  57919. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  57920. * @param otherVector the vector to add
  57921. * @returns the new vector with the result
  57922. */
  57923. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  57924. /**
  57925. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  57926. * @param otherVector the vector to subtract
  57927. * @param result the vector to store the result
  57928. * @returns the current Vector4.
  57929. */
  57930. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  57931. /**
  57932. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  57933. */
  57934. /**
  57935. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  57936. * @param x value to subtract
  57937. * @param y value to subtract
  57938. * @param z value to subtract
  57939. * @param w value to subtract
  57940. * @returns new vector containing the result
  57941. */
  57942. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  57943. /**
  57944. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  57945. * @param x value to subtract
  57946. * @param y value to subtract
  57947. * @param z value to subtract
  57948. * @param w value to subtract
  57949. * @param result the vector to store the result in
  57950. * @returns the current Vector4.
  57951. */
  57952. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  57953. /**
  57954. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  57955. * @returns a new vector with the negated values
  57956. */
  57957. negate(): Vector4;
  57958. /**
  57959. * Multiplies the current Vector4 coordinates by scale (float).
  57960. * @param scale the number to scale with
  57961. * @returns the updated Vector4.
  57962. */
  57963. scaleInPlace(scale: number): Vector4;
  57964. /**
  57965. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  57966. * @param scale the number to scale with
  57967. * @returns a new vector with the result
  57968. */
  57969. scale(scale: number): Vector4;
  57970. /**
  57971. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  57972. * @param scale the number to scale with
  57973. * @param result a vector to store the result in
  57974. * @returns the current Vector4.
  57975. */
  57976. scaleToRef(scale: number, result: Vector4): Vector4;
  57977. /**
  57978. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  57979. * @param scale defines the scale factor
  57980. * @param result defines the Vector4 object where to store the result
  57981. * @returns the unmodified current Vector4
  57982. */
  57983. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  57984. /**
  57985. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  57986. * @param otherVector the vector to compare against
  57987. * @returns true if they are equal
  57988. */
  57989. equals(otherVector: DeepImmutable<Vector4>): boolean;
  57990. /**
  57991. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  57992. * @param otherVector vector to compare against
  57993. * @param epsilon (Default: very small number)
  57994. * @returns true if they are equal
  57995. */
  57996. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  57997. /**
  57998. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  57999. * @param x x value to compare against
  58000. * @param y y value to compare against
  58001. * @param z z value to compare against
  58002. * @param w w value to compare against
  58003. * @returns true if equal
  58004. */
  58005. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58006. /**
  58007. * Multiplies in place the current Vector4 by the given one.
  58008. * @param otherVector vector to multiple with
  58009. * @returns the updated Vector4.
  58010. */
  58011. multiplyInPlace(otherVector: Vector4): Vector4;
  58012. /**
  58013. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58014. * @param otherVector vector to multiple with
  58015. * @returns resulting new vector
  58016. */
  58017. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58018. /**
  58019. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58020. * @param otherVector vector to multiple with
  58021. * @param result vector to store the result
  58022. * @returns the current Vector4.
  58023. */
  58024. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58025. /**
  58026. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58027. * @param x x value multiply with
  58028. * @param y y value multiply with
  58029. * @param z z value multiply with
  58030. * @param w w value multiply with
  58031. * @returns resulting new vector
  58032. */
  58033. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58034. /**
  58035. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58036. * @param otherVector vector to devide with
  58037. * @returns resulting new vector
  58038. */
  58039. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58040. /**
  58041. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58042. * @param otherVector vector to devide with
  58043. * @param result vector to store the result
  58044. * @returns the current Vector4.
  58045. */
  58046. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58047. /**
  58048. * Divides the current Vector3 coordinates by the given ones.
  58049. * @param otherVector vector to devide with
  58050. * @returns the updated Vector3.
  58051. */
  58052. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58053. /**
  58054. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58055. * @param other defines the second operand
  58056. * @returns the current updated Vector4
  58057. */
  58058. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58059. /**
  58060. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58061. * @param other defines the second operand
  58062. * @returns the current updated Vector4
  58063. */
  58064. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58065. /**
  58066. * Gets a new Vector4 from current Vector4 floored values
  58067. * @returns a new Vector4
  58068. */
  58069. floor(): Vector4;
  58070. /**
  58071. * Gets a new Vector4 from current Vector3 floored values
  58072. * @returns a new Vector4
  58073. */
  58074. fract(): Vector4;
  58075. /**
  58076. * Returns the Vector4 length (float).
  58077. * @returns the length
  58078. */
  58079. length(): number;
  58080. /**
  58081. * Returns the Vector4 squared length (float).
  58082. * @returns the length squared
  58083. */
  58084. lengthSquared(): number;
  58085. /**
  58086. * Normalizes in place the Vector4.
  58087. * @returns the updated Vector4.
  58088. */
  58089. normalize(): Vector4;
  58090. /**
  58091. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58092. * @returns this converted to a new vector3
  58093. */
  58094. toVector3(): Vector3;
  58095. /**
  58096. * Returns a new Vector4 copied from the current one.
  58097. * @returns the new cloned vector
  58098. */
  58099. clone(): Vector4;
  58100. /**
  58101. * Updates the current Vector4 with the given one coordinates.
  58102. * @param source the source vector to copy from
  58103. * @returns the updated Vector4.
  58104. */
  58105. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58106. /**
  58107. * Updates the current Vector4 coordinates with the given floats.
  58108. * @param x float to copy from
  58109. * @param y float to copy from
  58110. * @param z float to copy from
  58111. * @param w float to copy from
  58112. * @returns the updated Vector4.
  58113. */
  58114. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58115. /**
  58116. * Updates the current Vector4 coordinates with the given floats.
  58117. * @param x float to set from
  58118. * @param y float to set from
  58119. * @param z float to set from
  58120. * @param w float to set from
  58121. * @returns the updated Vector4.
  58122. */
  58123. set(x: number, y: number, z: number, w: number): Vector4;
  58124. /**
  58125. * Copies the given float to the current Vector3 coordinates
  58126. * @param v defines the x, y, z and w coordinates of the operand
  58127. * @returns the current updated Vector3
  58128. */
  58129. setAll(v: number): Vector4;
  58130. /**
  58131. * Returns a new Vector4 set from the starting index of the given array.
  58132. * @param array the array to pull values from
  58133. * @param offset the offset into the array to start at
  58134. * @returns the new vector
  58135. */
  58136. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58137. /**
  58138. * Updates the given vector "result" from the starting index of the given array.
  58139. * @param array the array to pull values from
  58140. * @param offset the offset into the array to start at
  58141. * @param result the vector to store the result in
  58142. */
  58143. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58144. /**
  58145. * Updates the given vector "result" from the starting index of the given Float32Array.
  58146. * @param array the array to pull values from
  58147. * @param offset the offset into the array to start at
  58148. * @param result the vector to store the result in
  58149. */
  58150. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58151. /**
  58152. * Updates the given vector "result" coordinates from the given floats.
  58153. * @param x float to set from
  58154. * @param y float to set from
  58155. * @param z float to set from
  58156. * @param w float to set from
  58157. * @param result the vector to the floats in
  58158. */
  58159. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58160. /**
  58161. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58162. * @returns the new vector
  58163. */
  58164. static Zero(): Vector4;
  58165. /**
  58166. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58167. * @returns the new vector
  58168. */
  58169. static One(): Vector4;
  58170. /**
  58171. * Returns a new normalized Vector4 from the given one.
  58172. * @param vector the vector to normalize
  58173. * @returns the vector
  58174. */
  58175. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58176. /**
  58177. * Updates the given vector "result" from the normalization of the given one.
  58178. * @param vector the vector to normalize
  58179. * @param result the vector to store the result in
  58180. */
  58181. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58182. /**
  58183. * Returns a vector with the minimum values from the left and right vectors
  58184. * @param left left vector to minimize
  58185. * @param right right vector to minimize
  58186. * @returns a new vector with the minimum of the left and right vector values
  58187. */
  58188. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58189. /**
  58190. * Returns a vector with the maximum values from the left and right vectors
  58191. * @param left left vector to maximize
  58192. * @param right right vector to maximize
  58193. * @returns a new vector with the maximum of the left and right vector values
  58194. */
  58195. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58196. /**
  58197. * Returns the distance (float) between the vectors "value1" and "value2".
  58198. * @param value1 value to calulate the distance between
  58199. * @param value2 value to calulate the distance between
  58200. * @return the distance between the two vectors
  58201. */
  58202. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58203. /**
  58204. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58205. * @param value1 value to calulate the distance between
  58206. * @param value2 value to calulate the distance between
  58207. * @return the distance between the two vectors squared
  58208. */
  58209. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58210. /**
  58211. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58212. * @param value1 value to calulate the center between
  58213. * @param value2 value to calulate the center between
  58214. * @return the center between the two vectors
  58215. */
  58216. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58217. /**
  58218. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58219. * This methods computes transformed normalized direction vectors only.
  58220. * @param vector the vector to transform
  58221. * @param transformation the transformation matrix to apply
  58222. * @returns the new vector
  58223. */
  58224. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58225. /**
  58226. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58227. * This methods computes transformed normalized direction vectors only.
  58228. * @param vector the vector to transform
  58229. * @param transformation the transformation matrix to apply
  58230. * @param result the vector to store the result in
  58231. */
  58232. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58233. /**
  58234. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58235. * This methods computes transformed normalized direction vectors only.
  58236. * @param x value to transform
  58237. * @param y value to transform
  58238. * @param z value to transform
  58239. * @param w value to transform
  58240. * @param transformation the transformation matrix to apply
  58241. * @param result the vector to store the results in
  58242. */
  58243. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58244. /**
  58245. * Creates a new Vector4 from a Vector3
  58246. * @param source defines the source data
  58247. * @param w defines the 4th component (default is 0)
  58248. * @returns a new Vector4
  58249. */
  58250. static FromVector3(source: Vector3, w?: number): Vector4;
  58251. }
  58252. /**
  58253. * Interface for the size containing width and height
  58254. */
  58255. export interface ISize {
  58256. /**
  58257. * Width
  58258. */
  58259. width: number;
  58260. /**
  58261. * Heighht
  58262. */
  58263. height: number;
  58264. }
  58265. /**
  58266. * Size containing widht and height
  58267. */
  58268. export class Size implements ISize {
  58269. /**
  58270. * Width
  58271. */
  58272. width: number;
  58273. /**
  58274. * Height
  58275. */
  58276. height: number;
  58277. /**
  58278. * Creates a Size object from the given width and height (floats).
  58279. * @param width width of the new size
  58280. * @param height height of the new size
  58281. */
  58282. constructor(width: number, height: number);
  58283. /**
  58284. * Returns a string with the Size width and height
  58285. * @returns a string with the Size width and height
  58286. */
  58287. toString(): string;
  58288. /**
  58289. * "Size"
  58290. * @returns the string "Size"
  58291. */
  58292. getClassName(): string;
  58293. /**
  58294. * Returns the Size hash code.
  58295. * @returns a hash code for a unique width and height
  58296. */
  58297. getHashCode(): number;
  58298. /**
  58299. * Updates the current size from the given one.
  58300. * @param src the given size
  58301. */
  58302. copyFrom(src: Size): void;
  58303. /**
  58304. * Updates in place the current Size from the given floats.
  58305. * @param width width of the new size
  58306. * @param height height of the new size
  58307. * @returns the updated Size.
  58308. */
  58309. copyFromFloats(width: number, height: number): Size;
  58310. /**
  58311. * Updates in place the current Size from the given floats.
  58312. * @param width width to set
  58313. * @param height height to set
  58314. * @returns the updated Size.
  58315. */
  58316. set(width: number, height: number): Size;
  58317. /**
  58318. * Multiplies the width and height by numbers
  58319. * @param w factor to multiple the width by
  58320. * @param h factor to multiple the height by
  58321. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58322. */
  58323. multiplyByFloats(w: number, h: number): Size;
  58324. /**
  58325. * Clones the size
  58326. * @returns a new Size copied from the given one.
  58327. */
  58328. clone(): Size;
  58329. /**
  58330. * True if the current Size and the given one width and height are strictly equal.
  58331. * @param other the other size to compare against
  58332. * @returns True if the current Size and the given one width and height are strictly equal.
  58333. */
  58334. equals(other: Size): boolean;
  58335. /**
  58336. * The surface of the Size : width * height (float).
  58337. */
  58338. readonly surface: number;
  58339. /**
  58340. * Create a new size of zero
  58341. * @returns a new Size set to (0.0, 0.0)
  58342. */
  58343. static Zero(): Size;
  58344. /**
  58345. * Sums the width and height of two sizes
  58346. * @param otherSize size to add to this size
  58347. * @returns a new Size set as the addition result of the current Size and the given one.
  58348. */
  58349. add(otherSize: Size): Size;
  58350. /**
  58351. * Subtracts the width and height of two
  58352. * @param otherSize size to subtract to this size
  58353. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58354. */
  58355. subtract(otherSize: Size): Size;
  58356. /**
  58357. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58358. * @param start starting size to lerp between
  58359. * @param end end size to lerp between
  58360. * @param amount amount to lerp between the start and end values
  58361. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58362. */
  58363. static Lerp(start: Size, end: Size, amount: number): Size;
  58364. }
  58365. /**
  58366. * Class used to store quaternion data
  58367. * @see https://en.wikipedia.org/wiki/Quaternion
  58368. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58369. */
  58370. export class Quaternion {
  58371. /** defines the first component (0 by default) */
  58372. x: number;
  58373. /** defines the second component (0 by default) */
  58374. y: number;
  58375. /** defines the third component (0 by default) */
  58376. z: number;
  58377. /** defines the fourth component (1.0 by default) */
  58378. w: number;
  58379. /**
  58380. * Creates a new Quaternion from the given floats
  58381. * @param x defines the first component (0 by default)
  58382. * @param y defines the second component (0 by default)
  58383. * @param z defines the third component (0 by default)
  58384. * @param w defines the fourth component (1.0 by default)
  58385. */
  58386. constructor(
  58387. /** defines the first component (0 by default) */
  58388. x?: number,
  58389. /** defines the second component (0 by default) */
  58390. y?: number,
  58391. /** defines the third component (0 by default) */
  58392. z?: number,
  58393. /** defines the fourth component (1.0 by default) */
  58394. w?: number);
  58395. /**
  58396. * Gets a string representation for the current quaternion
  58397. * @returns a string with the Quaternion coordinates
  58398. */
  58399. toString(): string;
  58400. /**
  58401. * Gets the class name of the quaternion
  58402. * @returns the string "Quaternion"
  58403. */
  58404. getClassName(): string;
  58405. /**
  58406. * Gets a hash code for this quaternion
  58407. * @returns the quaternion hash code
  58408. */
  58409. getHashCode(): number;
  58410. /**
  58411. * Copy the quaternion to an array
  58412. * @returns a new array populated with 4 elements from the quaternion coordinates
  58413. */
  58414. asArray(): number[];
  58415. /**
  58416. * Check if two quaternions are equals
  58417. * @param otherQuaternion defines the second operand
  58418. * @return true if the current quaternion and the given one coordinates are strictly equals
  58419. */
  58420. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58421. /**
  58422. * Clone the current quaternion
  58423. * @returns a new quaternion copied from the current one
  58424. */
  58425. clone(): Quaternion;
  58426. /**
  58427. * Copy a quaternion to the current one
  58428. * @param other defines the other quaternion
  58429. * @returns the updated current quaternion
  58430. */
  58431. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58432. /**
  58433. * Updates the current quaternion with the given float coordinates
  58434. * @param x defines the x coordinate
  58435. * @param y defines the y coordinate
  58436. * @param z defines the z coordinate
  58437. * @param w defines the w coordinate
  58438. * @returns the updated current quaternion
  58439. */
  58440. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  58441. /**
  58442. * Updates the current quaternion from the given float coordinates
  58443. * @param x defines the x coordinate
  58444. * @param y defines the y coordinate
  58445. * @param z defines the z coordinate
  58446. * @param w defines the w coordinate
  58447. * @returns the updated current quaternion
  58448. */
  58449. set(x: number, y: number, z: number, w: number): Quaternion;
  58450. /**
  58451. * Adds two quaternions
  58452. * @param other defines the second operand
  58453. * @returns a new quaternion as the addition result of the given one and the current quaternion
  58454. */
  58455. add(other: DeepImmutable<Quaternion>): Quaternion;
  58456. /**
  58457. * Add a quaternion to the current one
  58458. * @param other defines the quaternion to add
  58459. * @returns the current quaternion
  58460. */
  58461. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  58462. /**
  58463. * Subtract two quaternions
  58464. * @param other defines the second operand
  58465. * @returns a new quaternion as the subtraction result of the given one from the current one
  58466. */
  58467. subtract(other: Quaternion): Quaternion;
  58468. /**
  58469. * Multiplies the current quaternion by a scale factor
  58470. * @param value defines the scale factor
  58471. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  58472. */
  58473. scale(value: number): Quaternion;
  58474. /**
  58475. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  58476. * @param scale defines the scale factor
  58477. * @param result defines the Quaternion object where to store the result
  58478. * @returns the unmodified current quaternion
  58479. */
  58480. scaleToRef(scale: number, result: Quaternion): Quaternion;
  58481. /**
  58482. * Multiplies in place the current quaternion by a scale factor
  58483. * @param value defines the scale factor
  58484. * @returns the current modified quaternion
  58485. */
  58486. scaleInPlace(value: number): Quaternion;
  58487. /**
  58488. * Scale the current quaternion values by a factor and add the result to a given quaternion
  58489. * @param scale defines the scale factor
  58490. * @param result defines the Quaternion object where to store the result
  58491. * @returns the unmodified current quaternion
  58492. */
  58493. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  58494. /**
  58495. * Multiplies two quaternions
  58496. * @param q1 defines the second operand
  58497. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  58498. */
  58499. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  58500. /**
  58501. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  58502. * @param q1 defines the second operand
  58503. * @param result defines the target quaternion
  58504. * @returns the current quaternion
  58505. */
  58506. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  58507. /**
  58508. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  58509. * @param q1 defines the second operand
  58510. * @returns the currentupdated quaternion
  58511. */
  58512. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  58513. /**
  58514. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  58515. * @param ref defines the target quaternion
  58516. * @returns the current quaternion
  58517. */
  58518. conjugateToRef(ref: Quaternion): Quaternion;
  58519. /**
  58520. * Conjugates in place (1-q) the current quaternion
  58521. * @returns the current updated quaternion
  58522. */
  58523. conjugateInPlace(): Quaternion;
  58524. /**
  58525. * Conjugates in place (1-q) the current quaternion
  58526. * @returns a new quaternion
  58527. */
  58528. conjugate(): Quaternion;
  58529. /**
  58530. * Gets length of current quaternion
  58531. * @returns the quaternion length (float)
  58532. */
  58533. length(): number;
  58534. /**
  58535. * Normalize in place the current quaternion
  58536. * @returns the current updated quaternion
  58537. */
  58538. normalize(): Quaternion;
  58539. /**
  58540. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  58541. * @param order is a reserved parameter and is ignore for now
  58542. * @returns a new Vector3 containing the Euler angles
  58543. */
  58544. toEulerAngles(order?: string): Vector3;
  58545. /**
  58546. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  58547. * @param result defines the vector which will be filled with the Euler angles
  58548. * @param order is a reserved parameter and is ignore for now
  58549. * @returns the current unchanged quaternion
  58550. */
  58551. toEulerAnglesToRef(result: Vector3): Quaternion;
  58552. /**
  58553. * Updates the given rotation matrix with the current quaternion values
  58554. * @param result defines the target matrix
  58555. * @returns the current unchanged quaternion
  58556. */
  58557. toRotationMatrix(result: Matrix): Quaternion;
  58558. /**
  58559. * Updates the current quaternion from the given rotation matrix values
  58560. * @param matrix defines the source matrix
  58561. * @returns the current updated quaternion
  58562. */
  58563. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  58564. /**
  58565. * Creates a new quaternion from a rotation matrix
  58566. * @param matrix defines the source matrix
  58567. * @returns a new quaternion created from the given rotation matrix values
  58568. */
  58569. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  58570. /**
  58571. * Updates the given quaternion with the given rotation matrix values
  58572. * @param matrix defines the source matrix
  58573. * @param result defines the target quaternion
  58574. */
  58575. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  58576. /**
  58577. * Returns the dot product (float) between the quaternions "left" and "right"
  58578. * @param left defines the left operand
  58579. * @param right defines the right operand
  58580. * @returns the dot product
  58581. */
  58582. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  58583. /**
  58584. * Checks if the two quaternions are close to each other
  58585. * @param quat0 defines the first quaternion to check
  58586. * @param quat1 defines the second quaternion to check
  58587. * @returns true if the two quaternions are close to each other
  58588. */
  58589. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  58590. /**
  58591. * Creates an empty quaternion
  58592. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  58593. */
  58594. static Zero(): Quaternion;
  58595. /**
  58596. * Inverse a given quaternion
  58597. * @param q defines the source quaternion
  58598. * @returns a new quaternion as the inverted current quaternion
  58599. */
  58600. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  58601. /**
  58602. * Inverse a given quaternion
  58603. * @param q defines the source quaternion
  58604. * @param result the quaternion the result will be stored in
  58605. * @returns the result quaternion
  58606. */
  58607. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  58608. /**
  58609. * Creates an identity quaternion
  58610. * @returns the identity quaternion
  58611. */
  58612. static Identity(): Quaternion;
  58613. /**
  58614. * Gets a boolean indicating if the given quaternion is identity
  58615. * @param quaternion defines the quaternion to check
  58616. * @returns true if the quaternion is identity
  58617. */
  58618. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  58619. /**
  58620. * Creates a quaternion from a rotation around an axis
  58621. * @param axis defines the axis to use
  58622. * @param angle defines the angle to use
  58623. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  58624. */
  58625. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  58626. /**
  58627. * Creates a rotation around an axis and stores it into the given quaternion
  58628. * @param axis defines the axis to use
  58629. * @param angle defines the angle to use
  58630. * @param result defines the target quaternion
  58631. * @returns the target quaternion
  58632. */
  58633. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  58634. /**
  58635. * Creates a new quaternion from data stored into an array
  58636. * @param array defines the data source
  58637. * @param offset defines the offset in the source array where the data starts
  58638. * @returns a new quaternion
  58639. */
  58640. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  58641. /**
  58642. * Create a quaternion from Euler rotation angles
  58643. * @param x Pitch
  58644. * @param y Yaw
  58645. * @param z Roll
  58646. * @returns the new Quaternion
  58647. */
  58648. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  58649. /**
  58650. * Updates a quaternion from Euler rotation angles
  58651. * @param x Pitch
  58652. * @param y Yaw
  58653. * @param z Roll
  58654. * @param result the quaternion to store the result
  58655. * @returns the updated quaternion
  58656. */
  58657. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  58658. /**
  58659. * Create a quaternion from Euler rotation vector
  58660. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  58661. * @returns the new Quaternion
  58662. */
  58663. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  58664. /**
  58665. * Updates a quaternion from Euler rotation vector
  58666. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  58667. * @param result the quaternion to store the result
  58668. * @returns the updated quaternion
  58669. */
  58670. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  58671. /**
  58672. * Creates a new quaternion from the given Euler float angles (y, x, z)
  58673. * @param yaw defines the rotation around Y axis
  58674. * @param pitch defines the rotation around X axis
  58675. * @param roll defines the rotation around Z axis
  58676. * @returns the new quaternion
  58677. */
  58678. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  58679. /**
  58680. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  58681. * @param yaw defines the rotation around Y axis
  58682. * @param pitch defines the rotation around X axis
  58683. * @param roll defines the rotation around Z axis
  58684. * @param result defines the target quaternion
  58685. */
  58686. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  58687. /**
  58688. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  58689. * @param alpha defines the rotation around first axis
  58690. * @param beta defines the rotation around second axis
  58691. * @param gamma defines the rotation around third axis
  58692. * @returns the new quaternion
  58693. */
  58694. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  58695. /**
  58696. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  58697. * @param alpha defines the rotation around first axis
  58698. * @param beta defines the rotation around second axis
  58699. * @param gamma defines the rotation around third axis
  58700. * @param result defines the target quaternion
  58701. */
  58702. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  58703. /**
  58704. * 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)
  58705. * @param axis1 defines the first axis
  58706. * @param axis2 defines the second axis
  58707. * @param axis3 defines the third axis
  58708. * @returns the new quaternion
  58709. */
  58710. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  58711. /**
  58712. * 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
  58713. * @param axis1 defines the first axis
  58714. * @param axis2 defines the second axis
  58715. * @param axis3 defines the third axis
  58716. * @param ref defines the target quaternion
  58717. */
  58718. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  58719. /**
  58720. * Interpolates between two quaternions
  58721. * @param left defines first quaternion
  58722. * @param right defines second quaternion
  58723. * @param amount defines the gradient to use
  58724. * @returns the new interpolated quaternion
  58725. */
  58726. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  58727. /**
  58728. * Interpolates between two quaternions and stores it into a target quaternion
  58729. * @param left defines first quaternion
  58730. * @param right defines second quaternion
  58731. * @param amount defines the gradient to use
  58732. * @param result defines the target quaternion
  58733. */
  58734. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  58735. /**
  58736. * Interpolate between two quaternions using Hermite interpolation
  58737. * @param value1 defines first quaternion
  58738. * @param tangent1 defines the incoming tangent
  58739. * @param value2 defines second quaternion
  58740. * @param tangent2 defines the outgoing tangent
  58741. * @param amount defines the target quaternion
  58742. * @returns the new interpolated quaternion
  58743. */
  58744. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  58745. }
  58746. /**
  58747. * Class used to store matrix data (4x4)
  58748. */
  58749. export class Matrix {
  58750. private static _updateFlagSeed;
  58751. private static _identityReadOnly;
  58752. private _isIdentity;
  58753. private _isIdentityDirty;
  58754. private _isIdentity3x2;
  58755. private _isIdentity3x2Dirty;
  58756. /**
  58757. * Gets the update flag of the matrix which is an unique number for the matrix.
  58758. * It will be incremented every time the matrix data change.
  58759. * You can use it to speed the comparison between two versions of the same matrix.
  58760. */
  58761. updateFlag: number;
  58762. private readonly _m;
  58763. /**
  58764. * Gets the internal data of the matrix
  58765. */
  58766. readonly m: DeepImmutable<Float32Array>;
  58767. /** @hidden */
  58768. _markAsUpdated(): void;
  58769. /** @hidden */
  58770. private _updateIdentityStatus;
  58771. /**
  58772. * Creates an empty matrix (filled with zeros)
  58773. */
  58774. constructor();
  58775. /**
  58776. * Check if the current matrix is identity
  58777. * @returns true is the matrix is the identity matrix
  58778. */
  58779. isIdentity(): boolean;
  58780. /**
  58781. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  58782. * @returns true is the matrix is the identity matrix
  58783. */
  58784. isIdentityAs3x2(): boolean;
  58785. /**
  58786. * Gets the determinant of the matrix
  58787. * @returns the matrix determinant
  58788. */
  58789. determinant(): number;
  58790. /**
  58791. * Returns the matrix as a Float32Array
  58792. * @returns the matrix underlying array
  58793. */
  58794. toArray(): DeepImmutable<Float32Array>;
  58795. /**
  58796. * Returns the matrix as a Float32Array
  58797. * @returns the matrix underlying array.
  58798. */
  58799. asArray(): DeepImmutable<Float32Array>;
  58800. /**
  58801. * Inverts the current matrix in place
  58802. * @returns the current inverted matrix
  58803. */
  58804. invert(): Matrix;
  58805. /**
  58806. * Sets all the matrix elements to zero
  58807. * @returns the current matrix
  58808. */
  58809. reset(): Matrix;
  58810. /**
  58811. * Adds the current matrix with a second one
  58812. * @param other defines the matrix to add
  58813. * @returns a new matrix as the addition of the current matrix and the given one
  58814. */
  58815. add(other: DeepImmutable<Matrix>): Matrix;
  58816. /**
  58817. * Sets the given matrix "result" to the addition of the current matrix and the given one
  58818. * @param other defines the matrix to add
  58819. * @param result defines the target matrix
  58820. * @returns the current matrix
  58821. */
  58822. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  58823. /**
  58824. * Adds in place the given matrix to the current matrix
  58825. * @param other defines the second operand
  58826. * @returns the current updated matrix
  58827. */
  58828. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  58829. /**
  58830. * Sets the given matrix to the current inverted Matrix
  58831. * @param other defines the target matrix
  58832. * @returns the unmodified current matrix
  58833. */
  58834. invertToRef(other: Matrix): Matrix;
  58835. /**
  58836. * add a value at the specified position in the current Matrix
  58837. * @param index the index of the value within the matrix. between 0 and 15.
  58838. * @param value the value to be added
  58839. * @returns the current updated matrix
  58840. */
  58841. addAtIndex(index: number, value: number): Matrix;
  58842. /**
  58843. * mutiply the specified position in the current Matrix by a value
  58844. * @param index the index of the value within the matrix. between 0 and 15.
  58845. * @param value the value to be added
  58846. * @returns the current updated matrix
  58847. */
  58848. multiplyAtIndex(index: number, value: number): Matrix;
  58849. /**
  58850. * Inserts the translation vector (using 3 floats) in the current matrix
  58851. * @param x defines the 1st component of the translation
  58852. * @param y defines the 2nd component of the translation
  58853. * @param z defines the 3rd component of the translation
  58854. * @returns the current updated matrix
  58855. */
  58856. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  58857. /**
  58858. * Inserts the translation vector in the current matrix
  58859. * @param vector3 defines the translation to insert
  58860. * @returns the current updated matrix
  58861. */
  58862. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  58863. /**
  58864. * Gets the translation value of the current matrix
  58865. * @returns a new Vector3 as the extracted translation from the matrix
  58866. */
  58867. getTranslation(): Vector3;
  58868. /**
  58869. * Fill a Vector3 with the extracted translation from the matrix
  58870. * @param result defines the Vector3 where to store the translation
  58871. * @returns the current matrix
  58872. */
  58873. getTranslationToRef(result: Vector3): Matrix;
  58874. /**
  58875. * Remove rotation and scaling part from the matrix
  58876. * @returns the updated matrix
  58877. */
  58878. removeRotationAndScaling(): Matrix;
  58879. /**
  58880. * Multiply two matrices
  58881. * @param other defines the second operand
  58882. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  58883. */
  58884. multiply(other: DeepImmutable<Matrix>): Matrix;
  58885. /**
  58886. * Copy the current matrix from the given one
  58887. * @param other defines the source matrix
  58888. * @returns the current updated matrix
  58889. */
  58890. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  58891. /**
  58892. * Populates the given array from the starting index with the current matrix values
  58893. * @param array defines the target array
  58894. * @param offset defines the offset in the target array where to start storing values
  58895. * @returns the current matrix
  58896. */
  58897. copyToArray(array: Float32Array, offset?: number): Matrix;
  58898. /**
  58899. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  58900. * @param other defines the second operand
  58901. * @param result defines the matrix where to store the multiplication
  58902. * @returns the current matrix
  58903. */
  58904. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  58905. /**
  58906. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  58907. * @param other defines the second operand
  58908. * @param result defines the array where to store the multiplication
  58909. * @param offset defines the offset in the target array where to start storing values
  58910. * @returns the current matrix
  58911. */
  58912. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  58913. /**
  58914. * Check equality between this matrix and a second one
  58915. * @param value defines the second matrix to compare
  58916. * @returns true is the current matrix and the given one values are strictly equal
  58917. */
  58918. equals(value: DeepImmutable<Matrix>): boolean;
  58919. /**
  58920. * Clone the current matrix
  58921. * @returns a new matrix from the current matrix
  58922. */
  58923. clone(): Matrix;
  58924. /**
  58925. * Returns the name of the current matrix class
  58926. * @returns the string "Matrix"
  58927. */
  58928. getClassName(): string;
  58929. /**
  58930. * Gets the hash code of the current matrix
  58931. * @returns the hash code
  58932. */
  58933. getHashCode(): number;
  58934. /**
  58935. * Decomposes the current Matrix into a translation, rotation and scaling components
  58936. * @param scale defines the scale vector3 given as a reference to update
  58937. * @param rotation defines the rotation quaternion given as a reference to update
  58938. * @param translation defines the translation vector3 given as a reference to update
  58939. * @returns true if operation was successful
  58940. */
  58941. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  58942. /**
  58943. * Gets specific row of the matrix
  58944. * @param index defines the number of the row to get
  58945. * @returns the index-th row of the current matrix as a new Vector4
  58946. */
  58947. getRow(index: number): Nullable<Vector4>;
  58948. /**
  58949. * Sets the index-th row of the current matrix to the vector4 values
  58950. * @param index defines the number of the row to set
  58951. * @param row defines the target vector4
  58952. * @returns the updated current matrix
  58953. */
  58954. setRow(index: number, row: Vector4): Matrix;
  58955. /**
  58956. * Compute the transpose of the matrix
  58957. * @returns the new transposed matrix
  58958. */
  58959. transpose(): Matrix;
  58960. /**
  58961. * Compute the transpose of the matrix and store it in a given matrix
  58962. * @param result defines the target matrix
  58963. * @returns the current matrix
  58964. */
  58965. transposeToRef(result: Matrix): Matrix;
  58966. /**
  58967. * Sets the index-th row of the current matrix with the given 4 x float values
  58968. * @param index defines the row index
  58969. * @param x defines the x component to set
  58970. * @param y defines the y component to set
  58971. * @param z defines the z component to set
  58972. * @param w defines the w component to set
  58973. * @returns the updated current matrix
  58974. */
  58975. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  58976. /**
  58977. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  58978. * @param scale defines the scale factor
  58979. * @returns a new matrix
  58980. */
  58981. scale(scale: number): Matrix;
  58982. /**
  58983. * Scale the current matrix values by a factor to a given result matrix
  58984. * @param scale defines the scale factor
  58985. * @param result defines the matrix to store the result
  58986. * @returns the current matrix
  58987. */
  58988. scaleToRef(scale: number, result: Matrix): Matrix;
  58989. /**
  58990. * Scale the current matrix values by a factor and add the result to a given matrix
  58991. * @param scale defines the scale factor
  58992. * @param result defines the Matrix to store the result
  58993. * @returns the current matrix
  58994. */
  58995. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  58996. /**
  58997. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  58998. * @param ref matrix to store the result
  58999. */
  59000. toNormalMatrix(ref: Matrix): void;
  59001. /**
  59002. * Gets only rotation part of the current matrix
  59003. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59004. */
  59005. getRotationMatrix(): Matrix;
  59006. /**
  59007. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59008. * @param result defines the target matrix to store data to
  59009. * @returns the current matrix
  59010. */
  59011. getRotationMatrixToRef(result: Matrix): Matrix;
  59012. /**
  59013. * Toggles model matrix from being right handed to left handed in place and vice versa
  59014. */
  59015. toggleModelMatrixHandInPlace(): void;
  59016. /**
  59017. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59018. */
  59019. toggleProjectionMatrixHandInPlace(): void;
  59020. /**
  59021. * Creates a matrix from an array
  59022. * @param array defines the source array
  59023. * @param offset defines an offset in the source array
  59024. * @returns a new Matrix set from the starting index of the given array
  59025. */
  59026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59027. /**
  59028. * Copy the content of an array into a given matrix
  59029. * @param array defines the source array
  59030. * @param offset defines an offset in the source array
  59031. * @param result defines the target matrix
  59032. */
  59033. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59034. /**
  59035. * Stores an array into a matrix after having multiplied each component by a given factor
  59036. * @param array defines the source array
  59037. * @param offset defines the offset in the source array
  59038. * @param scale defines the scaling factor
  59039. * @param result defines the target matrix
  59040. */
  59041. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59042. /**
  59043. * Gets an identity matrix that must not be updated
  59044. */
  59045. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59046. /**
  59047. * Stores a list of values (16) inside a given matrix
  59048. * @param initialM11 defines 1st value of 1st row
  59049. * @param initialM12 defines 2nd value of 1st row
  59050. * @param initialM13 defines 3rd value of 1st row
  59051. * @param initialM14 defines 4th value of 1st row
  59052. * @param initialM21 defines 1st value of 2nd row
  59053. * @param initialM22 defines 2nd value of 2nd row
  59054. * @param initialM23 defines 3rd value of 2nd row
  59055. * @param initialM24 defines 4th value of 2nd row
  59056. * @param initialM31 defines 1st value of 3rd row
  59057. * @param initialM32 defines 2nd value of 3rd row
  59058. * @param initialM33 defines 3rd value of 3rd row
  59059. * @param initialM34 defines 4th value of 3rd row
  59060. * @param initialM41 defines 1st value of 4th row
  59061. * @param initialM42 defines 2nd value of 4th row
  59062. * @param initialM43 defines 3rd value of 4th row
  59063. * @param initialM44 defines 4th value of 4th row
  59064. * @param result defines the target matrix
  59065. */
  59066. 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;
  59067. /**
  59068. * Creates new matrix from a list of values (16)
  59069. * @param initialM11 defines 1st value of 1st row
  59070. * @param initialM12 defines 2nd value of 1st row
  59071. * @param initialM13 defines 3rd value of 1st row
  59072. * @param initialM14 defines 4th value of 1st row
  59073. * @param initialM21 defines 1st value of 2nd row
  59074. * @param initialM22 defines 2nd value of 2nd row
  59075. * @param initialM23 defines 3rd value of 2nd row
  59076. * @param initialM24 defines 4th value of 2nd row
  59077. * @param initialM31 defines 1st value of 3rd row
  59078. * @param initialM32 defines 2nd value of 3rd row
  59079. * @param initialM33 defines 3rd value of 3rd row
  59080. * @param initialM34 defines 4th value of 3rd row
  59081. * @param initialM41 defines 1st value of 4th row
  59082. * @param initialM42 defines 2nd value of 4th row
  59083. * @param initialM43 defines 3rd value of 4th row
  59084. * @param initialM44 defines 4th value of 4th row
  59085. * @returns the new matrix
  59086. */
  59087. 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;
  59088. /**
  59089. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59090. * @param scale defines the scale vector3
  59091. * @param rotation defines the rotation quaternion
  59092. * @param translation defines the translation vector3
  59093. * @returns a new matrix
  59094. */
  59095. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59096. /**
  59097. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59098. * @param scale defines the scale vector3
  59099. * @param rotation defines the rotation quaternion
  59100. * @param translation defines the translation vector3
  59101. * @param result defines the target matrix
  59102. */
  59103. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59104. /**
  59105. * Creates a new identity matrix
  59106. * @returns a new identity matrix
  59107. */
  59108. static Identity(): Matrix;
  59109. /**
  59110. * Creates a new identity matrix and stores the result in a given matrix
  59111. * @param result defines the target matrix
  59112. */
  59113. static IdentityToRef(result: Matrix): void;
  59114. /**
  59115. * Creates a new zero matrix
  59116. * @returns a new zero matrix
  59117. */
  59118. static Zero(): Matrix;
  59119. /**
  59120. * Creates a new rotation matrix for "angle" radians around the X axis
  59121. * @param angle defines the angle (in radians) to use
  59122. * @return the new matrix
  59123. */
  59124. static RotationX(angle: number): Matrix;
  59125. /**
  59126. * Creates a new matrix as the invert of a given matrix
  59127. * @param source defines the source matrix
  59128. * @returns the new matrix
  59129. */
  59130. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59131. /**
  59132. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59133. * @param angle defines the angle (in radians) to use
  59134. * @param result defines the target matrix
  59135. */
  59136. static RotationXToRef(angle: number, result: Matrix): void;
  59137. /**
  59138. * Creates a new rotation matrix for "angle" radians around the Y axis
  59139. * @param angle defines the angle (in radians) to use
  59140. * @return the new matrix
  59141. */
  59142. static RotationY(angle: number): Matrix;
  59143. /**
  59144. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59145. * @param angle defines the angle (in radians) to use
  59146. * @param result defines the target matrix
  59147. */
  59148. static RotationYToRef(angle: number, result: Matrix): void;
  59149. /**
  59150. * Creates a new rotation matrix for "angle" radians around the Z axis
  59151. * @param angle defines the angle (in radians) to use
  59152. * @return the new matrix
  59153. */
  59154. static RotationZ(angle: number): Matrix;
  59155. /**
  59156. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59157. * @param angle defines the angle (in radians) to use
  59158. * @param result defines the target matrix
  59159. */
  59160. static RotationZToRef(angle: number, result: Matrix): void;
  59161. /**
  59162. * Creates a new rotation matrix for "angle" radians around the given axis
  59163. * @param axis defines the axis to use
  59164. * @param angle defines the angle (in radians) to use
  59165. * @return the new matrix
  59166. */
  59167. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59168. /**
  59169. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59170. * @param axis defines the axis to use
  59171. * @param angle defines the angle (in radians) to use
  59172. * @param result defines the target matrix
  59173. */
  59174. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59175. /**
  59176. * Creates a rotation matrix
  59177. * @param yaw defines the yaw angle in radians (Y axis)
  59178. * @param pitch defines the pitch angle in radians (X axis)
  59179. * @param roll defines the roll angle in radians (X axis)
  59180. * @returns the new rotation matrix
  59181. */
  59182. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59183. /**
  59184. * Creates a rotation matrix and stores it in a given matrix
  59185. * @param yaw defines the yaw angle in radians (Y axis)
  59186. * @param pitch defines the pitch angle in radians (X axis)
  59187. * @param roll defines the roll angle in radians (X axis)
  59188. * @param result defines the target matrix
  59189. */
  59190. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59191. /**
  59192. * Creates a scaling matrix
  59193. * @param x defines the scale factor on X axis
  59194. * @param y defines the scale factor on Y axis
  59195. * @param z defines the scale factor on Z axis
  59196. * @returns the new matrix
  59197. */
  59198. static Scaling(x: number, y: number, z: number): Matrix;
  59199. /**
  59200. * Creates a scaling matrix and stores it in a given matrix
  59201. * @param x defines the scale factor on X axis
  59202. * @param y defines the scale factor on Y axis
  59203. * @param z defines the scale factor on Z axis
  59204. * @param result defines the target matrix
  59205. */
  59206. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59207. /**
  59208. * Creates a translation matrix
  59209. * @param x defines the translation on X axis
  59210. * @param y defines the translation on Y axis
  59211. * @param z defines the translationon Z axis
  59212. * @returns the new matrix
  59213. */
  59214. static Translation(x: number, y: number, z: number): Matrix;
  59215. /**
  59216. * Creates a translation matrix and stores it in a given matrix
  59217. * @param x defines the translation on X axis
  59218. * @param y defines the translation on Y axis
  59219. * @param z defines the translationon Z axis
  59220. * @param result defines the target matrix
  59221. */
  59222. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59223. /**
  59224. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59225. * @param startValue defines the start value
  59226. * @param endValue defines the end value
  59227. * @param gradient defines the gradient factor
  59228. * @returns the new matrix
  59229. */
  59230. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59231. /**
  59232. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59233. * @param startValue defines the start value
  59234. * @param endValue defines the end value
  59235. * @param gradient defines the gradient factor
  59236. * @param result defines the Matrix object where to store data
  59237. */
  59238. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59239. /**
  59240. * Builds a new matrix whose values are computed by:
  59241. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59242. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59243. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59244. * @param startValue defines the first matrix
  59245. * @param endValue defines the second matrix
  59246. * @param gradient defines the gradient between the two matrices
  59247. * @returns the new matrix
  59248. */
  59249. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59250. /**
  59251. * Update a matrix to values which are computed by:
  59252. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59253. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59254. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59255. * @param startValue defines the first matrix
  59256. * @param endValue defines the second matrix
  59257. * @param gradient defines the gradient between the two matrices
  59258. * @param result defines the target matrix
  59259. */
  59260. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59261. /**
  59262. * 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"
  59263. * This function works in left handed mode
  59264. * @param eye defines the final position of the entity
  59265. * @param target defines where the entity should look at
  59266. * @param up defines the up vector for the entity
  59267. * @returns the new matrix
  59268. */
  59269. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59270. /**
  59271. * 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".
  59272. * This function works in left handed mode
  59273. * @param eye defines the final position of the entity
  59274. * @param target defines where the entity should look at
  59275. * @param up defines the up vector for the entity
  59276. * @param result defines the target matrix
  59277. */
  59278. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59279. /**
  59280. * 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"
  59281. * This function works in right handed mode
  59282. * @param eye defines the final position of the entity
  59283. * @param target defines where the entity should look at
  59284. * @param up defines the up vector for the entity
  59285. * @returns the new matrix
  59286. */
  59287. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59288. /**
  59289. * 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".
  59290. * This function works in right handed mode
  59291. * @param eye defines the final position of the entity
  59292. * @param target defines where the entity should look at
  59293. * @param up defines the up vector for the entity
  59294. * @param result defines the target matrix
  59295. */
  59296. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59297. /**
  59298. * Create a left-handed orthographic projection matrix
  59299. * @param width defines the viewport width
  59300. * @param height defines the viewport height
  59301. * @param znear defines the near clip plane
  59302. * @param zfar defines the far clip plane
  59303. * @returns a new matrix as a left-handed orthographic projection matrix
  59304. */
  59305. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59306. /**
  59307. * Store a left-handed orthographic projection to a given matrix
  59308. * @param width defines the viewport width
  59309. * @param height defines the viewport height
  59310. * @param znear defines the near clip plane
  59311. * @param zfar defines the far clip plane
  59312. * @param result defines the target matrix
  59313. */
  59314. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59315. /**
  59316. * Create a left-handed orthographic projection matrix
  59317. * @param left defines the viewport left coordinate
  59318. * @param right defines the viewport right coordinate
  59319. * @param bottom defines the viewport bottom coordinate
  59320. * @param top defines the viewport top coordinate
  59321. * @param znear defines the near clip plane
  59322. * @param zfar defines the far clip plane
  59323. * @returns a new matrix as a left-handed orthographic projection matrix
  59324. */
  59325. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59326. /**
  59327. * Stores a left-handed orthographic projection into a given matrix
  59328. * @param left defines the viewport left coordinate
  59329. * @param right defines the viewport right coordinate
  59330. * @param bottom defines the viewport bottom coordinate
  59331. * @param top defines the viewport top coordinate
  59332. * @param znear defines the near clip plane
  59333. * @param zfar defines the far clip plane
  59334. * @param result defines the target matrix
  59335. */
  59336. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59337. /**
  59338. * Creates a right-handed orthographic projection matrix
  59339. * @param left defines the viewport left coordinate
  59340. * @param right defines the viewport right coordinate
  59341. * @param bottom defines the viewport bottom coordinate
  59342. * @param top defines the viewport top coordinate
  59343. * @param znear defines the near clip plane
  59344. * @param zfar defines the far clip plane
  59345. * @returns a new matrix as a right-handed orthographic projection matrix
  59346. */
  59347. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59348. /**
  59349. * Stores a right-handed orthographic projection into a given matrix
  59350. * @param left defines the viewport left coordinate
  59351. * @param right defines the viewport right coordinate
  59352. * @param bottom defines the viewport bottom coordinate
  59353. * @param top defines the viewport top coordinate
  59354. * @param znear defines the near clip plane
  59355. * @param zfar defines the far clip plane
  59356. * @param result defines the target matrix
  59357. */
  59358. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59359. /**
  59360. * Creates a left-handed perspective projection matrix
  59361. * @param width defines the viewport width
  59362. * @param height defines the viewport height
  59363. * @param znear defines the near clip plane
  59364. * @param zfar defines the far clip plane
  59365. * @returns a new matrix as a left-handed perspective projection matrix
  59366. */
  59367. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59368. /**
  59369. * Creates a left-handed perspective projection matrix
  59370. * @param fov defines the horizontal field of view
  59371. * @param aspect defines the aspect ratio
  59372. * @param znear defines the near clip plane
  59373. * @param zfar defines the far clip plane
  59374. * @returns a new matrix as a left-handed perspective projection matrix
  59375. */
  59376. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59377. /**
  59378. * Stores a left-handed perspective projection into a given matrix
  59379. * @param fov defines the horizontal field of view
  59380. * @param aspect defines the aspect ratio
  59381. * @param znear defines the near clip plane
  59382. * @param zfar defines the far clip plane
  59383. * @param result defines the target matrix
  59384. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59385. */
  59386. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59387. /**
  59388. * Creates a right-handed perspective projection matrix
  59389. * @param fov defines the horizontal field of view
  59390. * @param aspect defines the aspect ratio
  59391. * @param znear defines the near clip plane
  59392. * @param zfar defines the far clip plane
  59393. * @returns a new matrix as a right-handed perspective projection matrix
  59394. */
  59395. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59396. /**
  59397. * Stores a right-handed perspective projection into a given matrix
  59398. * @param fov defines the horizontal field of view
  59399. * @param aspect defines the aspect ratio
  59400. * @param znear defines the near clip plane
  59401. * @param zfar defines the far clip plane
  59402. * @param result defines the target matrix
  59403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59404. */
  59405. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59406. /**
  59407. * Stores a perspective projection for WebVR info a given matrix
  59408. * @param fov defines the field of view
  59409. * @param znear defines the near clip plane
  59410. * @param zfar defines the far clip plane
  59411. * @param result defines the target matrix
  59412. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59413. */
  59414. static PerspectiveFovWebVRToRef(fov: {
  59415. upDegrees: number;
  59416. downDegrees: number;
  59417. leftDegrees: number;
  59418. rightDegrees: number;
  59419. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59420. /**
  59421. * Computes a complete transformation matrix
  59422. * @param viewport defines the viewport to use
  59423. * @param world defines the world matrix
  59424. * @param view defines the view matrix
  59425. * @param projection defines the projection matrix
  59426. * @param zmin defines the near clip plane
  59427. * @param zmax defines the far clip plane
  59428. * @returns the transformation matrix
  59429. */
  59430. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59431. /**
  59432. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  59433. * @param matrix defines the matrix to use
  59434. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  59435. */
  59436. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  59437. /**
  59438. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  59439. * @param matrix defines the matrix to use
  59440. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  59441. */
  59442. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  59443. /**
  59444. * Compute the transpose of a given matrix
  59445. * @param matrix defines the matrix to transpose
  59446. * @returns the new matrix
  59447. */
  59448. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  59449. /**
  59450. * Compute the transpose of a matrix and store it in a target matrix
  59451. * @param matrix defines the matrix to transpose
  59452. * @param result defines the target matrix
  59453. */
  59454. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  59455. /**
  59456. * Computes a reflection matrix from a plane
  59457. * @param plane defines the reflection plane
  59458. * @returns a new matrix
  59459. */
  59460. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  59461. /**
  59462. * Computes a reflection matrix from a plane
  59463. * @param plane defines the reflection plane
  59464. * @param result defines the target matrix
  59465. */
  59466. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  59467. /**
  59468. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  59469. * @param xaxis defines the value of the 1st axis
  59470. * @param yaxis defines the value of the 2nd axis
  59471. * @param zaxis defines the value of the 3rd axis
  59472. * @param result defines the target matrix
  59473. */
  59474. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  59475. /**
  59476. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  59477. * @param quat defines the quaternion to use
  59478. * @param result defines the target matrix
  59479. */
  59480. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  59481. }
  59482. /**
  59483. * Represens a plane by the equation ax + by + cz + d = 0
  59484. */
  59485. export class Plane {
  59486. /**
  59487. * Normal of the plane (a,b,c)
  59488. */
  59489. normal: Vector3;
  59490. /**
  59491. * d component of the plane
  59492. */
  59493. d: number;
  59494. /**
  59495. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  59496. * @param a a component of the plane
  59497. * @param b b component of the plane
  59498. * @param c c component of the plane
  59499. * @param d d component of the plane
  59500. */
  59501. constructor(a: number, b: number, c: number, d: number);
  59502. /**
  59503. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  59504. */
  59505. asArray(): number[];
  59506. /**
  59507. * @returns a new plane copied from the current Plane.
  59508. */
  59509. clone(): Plane;
  59510. /**
  59511. * @returns the string "Plane".
  59512. */
  59513. getClassName(): string;
  59514. /**
  59515. * @returns the Plane hash code.
  59516. */
  59517. getHashCode(): number;
  59518. /**
  59519. * Normalize the current Plane in place.
  59520. * @returns the updated Plane.
  59521. */
  59522. normalize(): Plane;
  59523. /**
  59524. * Applies a transformation the plane and returns the result
  59525. * @param transformation the transformation matrix to be applied to the plane
  59526. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  59527. */
  59528. transform(transformation: DeepImmutable<Matrix>): Plane;
  59529. /**
  59530. * Calcualtte the dot product between the point and the plane normal
  59531. * @param point point to calculate the dot product with
  59532. * @returns the dot product (float) of the point coordinates and the plane normal.
  59533. */
  59534. dotCoordinate(point: DeepImmutable<Vector3>): number;
  59535. /**
  59536. * Updates the current Plane from the plane defined by the three given points.
  59537. * @param point1 one of the points used to contruct the plane
  59538. * @param point2 one of the points used to contruct the plane
  59539. * @param point3 one of the points used to contruct the plane
  59540. * @returns the updated Plane.
  59541. */
  59542. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  59543. /**
  59544. * Checks if the plane is facing a given direction
  59545. * @param direction the direction to check if the plane is facing
  59546. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  59547. * @returns True is the vector "direction" is the same side than the plane normal.
  59548. */
  59549. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  59550. /**
  59551. * Calculates the distance to a point
  59552. * @param point point to calculate distance to
  59553. * @returns the signed distance (float) from the given point to the Plane.
  59554. */
  59555. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  59556. /**
  59557. * Creates a plane from an array
  59558. * @param array the array to create a plane from
  59559. * @returns a new Plane from the given array.
  59560. */
  59561. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  59562. /**
  59563. * Creates a plane from three points
  59564. * @param point1 point used to create the plane
  59565. * @param point2 point used to create the plane
  59566. * @param point3 point used to create the plane
  59567. * @returns a new Plane defined by the three given points.
  59568. */
  59569. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  59570. /**
  59571. * Creates a plane from an origin point and a normal
  59572. * @param origin origin of the plane to be constructed
  59573. * @param normal normal of the plane to be constructed
  59574. * @returns a new Plane the normal vector to this plane at the given origin point.
  59575. * Note : the vector "normal" is updated because normalized.
  59576. */
  59577. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  59578. /**
  59579. * Calculates the distance from a plane and a point
  59580. * @param origin origin of the plane to be constructed
  59581. * @param normal normal of the plane to be constructed
  59582. * @param point point to calculate distance to
  59583. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  59584. */
  59585. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  59586. }
  59587. /**
  59588. * Class used to represent a viewport on screen
  59589. */
  59590. export class Viewport {
  59591. /** viewport left coordinate */
  59592. x: number;
  59593. /** viewport top coordinate */
  59594. y: number;
  59595. /**viewport width */
  59596. width: number;
  59597. /** viewport height */
  59598. height: number;
  59599. /**
  59600. * Creates a Viewport object located at (x, y) and sized (width, height)
  59601. * @param x defines viewport left coordinate
  59602. * @param y defines viewport top coordinate
  59603. * @param width defines the viewport width
  59604. * @param height defines the viewport height
  59605. */
  59606. constructor(
  59607. /** viewport left coordinate */
  59608. x: number,
  59609. /** viewport top coordinate */
  59610. y: number,
  59611. /**viewport width */
  59612. width: number,
  59613. /** viewport height */
  59614. height: number);
  59615. /**
  59616. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  59617. * @param renderWidth defines the rendering width
  59618. * @param renderHeight defines the rendering height
  59619. * @returns a new Viewport
  59620. */
  59621. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  59622. /**
  59623. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  59624. * @param renderWidth defines the rendering width
  59625. * @param renderHeight defines the rendering height
  59626. * @param ref defines the target viewport
  59627. * @returns the current viewport
  59628. */
  59629. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  59630. /**
  59631. * Returns a new Viewport copied from the current one
  59632. * @returns a new Viewport
  59633. */
  59634. clone(): Viewport;
  59635. }
  59636. /**
  59637. * Reprasents a camera frustum
  59638. */
  59639. export class Frustum {
  59640. /**
  59641. * Gets the planes representing the frustum
  59642. * @param transform matrix to be applied to the returned planes
  59643. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  59644. */
  59645. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  59646. /**
  59647. * Gets the near frustum plane transformed by the transform matrix
  59648. * @param transform transformation matrix to be applied to the resulting frustum plane
  59649. * @param frustumPlane the resuling frustum plane
  59650. */
  59651. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59652. /**
  59653. * Gets the far frustum plane transformed by the transform matrix
  59654. * @param transform transformation matrix to be applied to the resulting frustum plane
  59655. * @param frustumPlane the resuling frustum plane
  59656. */
  59657. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59658. /**
  59659. * Gets the left frustum plane transformed by the transform matrix
  59660. * @param transform transformation matrix to be applied to the resulting frustum plane
  59661. * @param frustumPlane the resuling frustum plane
  59662. */
  59663. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59664. /**
  59665. * Gets the right frustum plane transformed by the transform matrix
  59666. * @param transform transformation matrix to be applied to the resulting frustum plane
  59667. * @param frustumPlane the resuling frustum plane
  59668. */
  59669. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59670. /**
  59671. * Gets the top frustum plane transformed by the transform matrix
  59672. * @param transform transformation matrix to be applied to the resulting frustum plane
  59673. * @param frustumPlane the resuling frustum plane
  59674. */
  59675. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59676. /**
  59677. * Gets the bottom frustum plane transformed by the transform matrix
  59678. * @param transform transformation matrix to be applied to the resulting frustum plane
  59679. * @param frustumPlane the resuling frustum plane
  59680. */
  59681. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  59682. /**
  59683. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  59684. * @param transform transformation matrix to be applied to the resulting frustum planes
  59685. * @param frustumPlanes the resuling frustum planes
  59686. */
  59687. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  59688. }
  59689. /** Defines supported spaces */
  59690. export enum Space {
  59691. /** Local (object) space */
  59692. LOCAL = 0,
  59693. /** World space */
  59694. WORLD = 1,
  59695. /** Bone space */
  59696. BONE = 2
  59697. }
  59698. /** Defines the 3 main axes */
  59699. export class Axis {
  59700. /** X axis */
  59701. static X: Vector3;
  59702. /** Y axis */
  59703. static Y: Vector3;
  59704. /** Z axis */
  59705. static Z: Vector3;
  59706. }
  59707. /** Class used to represent a Bezier curve */
  59708. export class BezierCurve {
  59709. /**
  59710. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  59711. * @param t defines the time
  59712. * @param x1 defines the left coordinate on X axis
  59713. * @param y1 defines the left coordinate on Y axis
  59714. * @param x2 defines the right coordinate on X axis
  59715. * @param y2 defines the right coordinate on Y axis
  59716. * @returns the interpolated value
  59717. */
  59718. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  59719. }
  59720. /**
  59721. * Defines potential orientation for back face culling
  59722. */
  59723. export enum Orientation {
  59724. /**
  59725. * Clockwise
  59726. */
  59727. CW = 0,
  59728. /** Counter clockwise */
  59729. CCW = 1
  59730. }
  59731. /**
  59732. * Defines angle representation
  59733. */
  59734. export class Angle {
  59735. private _radians;
  59736. /**
  59737. * Creates an Angle object of "radians" radians (float).
  59738. */
  59739. constructor(radians: number);
  59740. /**
  59741. * Get value in degrees
  59742. * @returns the Angle value in degrees (float)
  59743. */
  59744. degrees(): number;
  59745. /**
  59746. * Get value in radians
  59747. * @returns the Angle value in radians (float)
  59748. */
  59749. radians(): number;
  59750. /**
  59751. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  59752. * @param a defines first vector
  59753. * @param b defines second vector
  59754. * @returns a new Angle
  59755. */
  59756. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  59757. /**
  59758. * Gets a new Angle object from the given float in radians
  59759. * @param radians defines the angle value in radians
  59760. * @returns a new Angle
  59761. */
  59762. static FromRadians(radians: number): Angle;
  59763. /**
  59764. * Gets a new Angle object from the given float in degrees
  59765. * @param degrees defines the angle value in degrees
  59766. * @returns a new Angle
  59767. */
  59768. static FromDegrees(degrees: number): Angle;
  59769. }
  59770. /**
  59771. * This represents an arc in a 2d space.
  59772. */
  59773. export class Arc2 {
  59774. /** Defines the start point of the arc */
  59775. startPoint: Vector2;
  59776. /** Defines the mid point of the arc */
  59777. midPoint: Vector2;
  59778. /** Defines the end point of the arc */
  59779. endPoint: Vector2;
  59780. /**
  59781. * Defines the center point of the arc.
  59782. */
  59783. centerPoint: Vector2;
  59784. /**
  59785. * Defines the radius of the arc.
  59786. */
  59787. radius: number;
  59788. /**
  59789. * Defines the angle of the arc (from mid point to end point).
  59790. */
  59791. angle: Angle;
  59792. /**
  59793. * Defines the start angle of the arc (from start point to middle point).
  59794. */
  59795. startAngle: Angle;
  59796. /**
  59797. * Defines the orientation of the arc (clock wise/counter clock wise).
  59798. */
  59799. orientation: Orientation;
  59800. /**
  59801. * Creates an Arc object from the three given points : start, middle and end.
  59802. * @param startPoint Defines the start point of the arc
  59803. * @param midPoint Defines the midlle point of the arc
  59804. * @param endPoint Defines the end point of the arc
  59805. */
  59806. constructor(
  59807. /** Defines the start point of the arc */
  59808. startPoint: Vector2,
  59809. /** Defines the mid point of the arc */
  59810. midPoint: Vector2,
  59811. /** Defines the end point of the arc */
  59812. endPoint: Vector2);
  59813. }
  59814. /**
  59815. * Represents a 2D path made up of multiple 2D points
  59816. */
  59817. export class Path2 {
  59818. private _points;
  59819. private _length;
  59820. /**
  59821. * If the path start and end point are the same
  59822. */
  59823. closed: boolean;
  59824. /**
  59825. * Creates a Path2 object from the starting 2D coordinates x and y.
  59826. * @param x the starting points x value
  59827. * @param y the starting points y value
  59828. */
  59829. constructor(x: number, y: number);
  59830. /**
  59831. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  59832. * @param x the added points x value
  59833. * @param y the added points y value
  59834. * @returns the updated Path2.
  59835. */
  59836. addLineTo(x: number, y: number): Path2;
  59837. /**
  59838. * 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.
  59839. * @param midX middle point x value
  59840. * @param midY middle point y value
  59841. * @param endX end point x value
  59842. * @param endY end point y value
  59843. * @param numberOfSegments (default: 36)
  59844. * @returns the updated Path2.
  59845. */
  59846. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  59847. /**
  59848. * Closes the Path2.
  59849. * @returns the Path2.
  59850. */
  59851. close(): Path2;
  59852. /**
  59853. * Gets the sum of the distance between each sequential point in the path
  59854. * @returns the Path2 total length (float).
  59855. */
  59856. length(): number;
  59857. /**
  59858. * Gets the points which construct the path
  59859. * @returns the Path2 internal array of points.
  59860. */
  59861. getPoints(): Vector2[];
  59862. /**
  59863. * Retreives the point at the distance aways from the starting point
  59864. * @param normalizedLengthPosition the length along the path to retreive the point from
  59865. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  59866. */
  59867. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  59868. /**
  59869. * Creates a new path starting from an x and y position
  59870. * @param x starting x value
  59871. * @param y starting y value
  59872. * @returns a new Path2 starting at the coordinates (x, y).
  59873. */
  59874. static StartingAt(x: number, y: number): Path2;
  59875. }
  59876. /**
  59877. * Represents a 3D path made up of multiple 3D points
  59878. */
  59879. export class Path3D {
  59880. /**
  59881. * an array of Vector3, the curve axis of the Path3D
  59882. */
  59883. path: Vector3[];
  59884. private _curve;
  59885. private _distances;
  59886. private _tangents;
  59887. private _normals;
  59888. private _binormals;
  59889. private _raw;
  59890. /**
  59891. * new Path3D(path, normal, raw)
  59892. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  59893. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  59894. * @param path an array of Vector3, the curve axis of the Path3D
  59895. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  59896. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  59897. */
  59898. constructor(
  59899. /**
  59900. * an array of Vector3, the curve axis of the Path3D
  59901. */
  59902. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  59903. /**
  59904. * Returns the Path3D array of successive Vector3 designing its curve.
  59905. * @returns the Path3D array of successive Vector3 designing its curve.
  59906. */
  59907. getCurve(): Vector3[];
  59908. /**
  59909. * Returns an array populated with tangent vectors on each Path3D curve point.
  59910. * @returns an array populated with tangent vectors on each Path3D curve point.
  59911. */
  59912. getTangents(): Vector3[];
  59913. /**
  59914. * Returns an array populated with normal vectors on each Path3D curve point.
  59915. * @returns an array populated with normal vectors on each Path3D curve point.
  59916. */
  59917. getNormals(): Vector3[];
  59918. /**
  59919. * Returns an array populated with binormal vectors on each Path3D curve point.
  59920. * @returns an array populated with binormal vectors on each Path3D curve point.
  59921. */
  59922. getBinormals(): Vector3[];
  59923. /**
  59924. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  59925. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  59926. */
  59927. getDistances(): number[];
  59928. /**
  59929. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  59930. * @param path path which all values are copied into the curves points
  59931. * @param firstNormal which should be projected onto the curve
  59932. * @returns the same object updated.
  59933. */
  59934. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  59935. private _compute;
  59936. private _getFirstNonNullVector;
  59937. private _getLastNonNullVector;
  59938. private _normalVector;
  59939. }
  59940. /**
  59941. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  59942. * A Curve3 is designed from a series of successive Vector3.
  59943. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  59944. */
  59945. export class Curve3 {
  59946. private _points;
  59947. private _length;
  59948. /**
  59949. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  59950. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  59951. * @param v1 (Vector3) the control point
  59952. * @param v2 (Vector3) the end point of the Quadratic Bezier
  59953. * @param nbPoints (integer) the wanted number of points in the curve
  59954. * @returns the created Curve3
  59955. */
  59956. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  59957. /**
  59958. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  59959. * @param v0 (Vector3) the origin point of the Cubic Bezier
  59960. * @param v1 (Vector3) the first control point
  59961. * @param v2 (Vector3) the second control point
  59962. * @param v3 (Vector3) the end point of the Cubic Bezier
  59963. * @param nbPoints (integer) the wanted number of points in the curve
  59964. * @returns the created Curve3
  59965. */
  59966. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  59967. /**
  59968. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  59969. * @param p1 (Vector3) the origin point of the Hermite Spline
  59970. * @param t1 (Vector3) the tangent vector at the origin point
  59971. * @param p2 (Vector3) the end point of the Hermite Spline
  59972. * @param t2 (Vector3) the tangent vector at the end point
  59973. * @param nbPoints (integer) the wanted number of points in the curve
  59974. * @returns the created Curve3
  59975. */
  59976. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  59977. /**
  59978. * Returns a Curve3 object along a CatmullRom Spline curve :
  59979. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  59980. * @param nbPoints (integer) the wanted number of points between each curve control points
  59981. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  59982. * @returns the created Curve3
  59983. */
  59984. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  59985. /**
  59986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  59987. * A Curve3 is designed from a series of successive Vector3.
  59988. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  59989. * @param points points which make up the curve
  59990. */
  59991. constructor(points: Vector3[]);
  59992. /**
  59993. * @returns the Curve3 stored array of successive Vector3
  59994. */
  59995. getPoints(): Vector3[];
  59996. /**
  59997. * @returns the computed length (float) of the curve.
  59998. */
  59999. length(): number;
  60000. /**
  60001. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60002. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60003. * curveA and curveB keep unchanged.
  60004. * @param curve the curve to continue from this curve
  60005. * @returns the newly constructed curve
  60006. */
  60007. continue(curve: DeepImmutable<Curve3>): Curve3;
  60008. private _computeLength;
  60009. }
  60010. /**
  60011. * Contains position and normal vectors for a vertex
  60012. */
  60013. export class PositionNormalVertex {
  60014. /** the position of the vertex (defaut: 0,0,0) */
  60015. position: Vector3;
  60016. /** the normal of the vertex (defaut: 0,1,0) */
  60017. normal: Vector3;
  60018. /**
  60019. * Creates a PositionNormalVertex
  60020. * @param position the position of the vertex (defaut: 0,0,0)
  60021. * @param normal the normal of the vertex (defaut: 0,1,0)
  60022. */
  60023. constructor(
  60024. /** the position of the vertex (defaut: 0,0,0) */
  60025. position?: Vector3,
  60026. /** the normal of the vertex (defaut: 0,1,0) */
  60027. normal?: Vector3);
  60028. /**
  60029. * Clones the PositionNormalVertex
  60030. * @returns the cloned PositionNormalVertex
  60031. */
  60032. clone(): PositionNormalVertex;
  60033. }
  60034. /**
  60035. * Contains position, normal and uv vectors for a vertex
  60036. */
  60037. export class PositionNormalTextureVertex {
  60038. /** the position of the vertex (defaut: 0,0,0) */
  60039. position: Vector3;
  60040. /** the normal of the vertex (defaut: 0,1,0) */
  60041. normal: Vector3;
  60042. /** the uv of the vertex (default: 0,0) */
  60043. uv: Vector2;
  60044. /**
  60045. * Creates a PositionNormalTextureVertex
  60046. * @param position the position of the vertex (defaut: 0,0,0)
  60047. * @param normal the normal of the vertex (defaut: 0,1,0)
  60048. * @param uv the uv of the vertex (default: 0,0)
  60049. */
  60050. constructor(
  60051. /** the position of the vertex (defaut: 0,0,0) */
  60052. position?: Vector3,
  60053. /** the normal of the vertex (defaut: 0,1,0) */
  60054. normal?: Vector3,
  60055. /** the uv of the vertex (default: 0,0) */
  60056. uv?: Vector2);
  60057. /**
  60058. * Clones the PositionNormalTextureVertex
  60059. * @returns the cloned PositionNormalTextureVertex
  60060. */
  60061. clone(): PositionNormalTextureVertex;
  60062. }
  60063. /**
  60064. * @hidden
  60065. */
  60066. export class Tmp {
  60067. static Color3: Color3[];
  60068. static Color4: Color4[];
  60069. static Vector2: Vector2[];
  60070. static Vector3: Vector3[];
  60071. static Vector4: Vector4[];
  60072. static Quaternion: Quaternion[];
  60073. static Matrix: Matrix[];
  60074. }
  60075. }
  60076. declare module BABYLON {
  60077. /**
  60078. * Class used to enable access to offline support
  60079. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60080. */
  60081. export interface IOfflineProvider {
  60082. /**
  60083. * Gets a boolean indicating if scene must be saved in the database
  60084. */
  60085. enableSceneOffline: boolean;
  60086. /**
  60087. * Gets a boolean indicating if textures must be saved in the database
  60088. */
  60089. enableTexturesOffline: boolean;
  60090. /**
  60091. * Open the offline support and make it available
  60092. * @param successCallback defines the callback to call on success
  60093. * @param errorCallback defines the callback to call on error
  60094. */
  60095. open(successCallback: () => void, errorCallback: () => void): void;
  60096. /**
  60097. * Loads an image from the offline support
  60098. * @param url defines the url to load from
  60099. * @param image defines the target DOM image
  60100. */
  60101. loadImage(url: string, image: HTMLImageElement): void;
  60102. /**
  60103. * Loads a file from offline support
  60104. * @param url defines the URL to load from
  60105. * @param sceneLoaded defines a callback to call on success
  60106. * @param progressCallBack defines a callback to call when progress changed
  60107. * @param errorCallback defines a callback to call on error
  60108. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60109. */
  60110. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60111. }
  60112. }
  60113. declare module BABYLON {
  60114. /**
  60115. * A class serves as a medium between the observable and its observers
  60116. */
  60117. export class EventState {
  60118. /**
  60119. * Create a new EventState
  60120. * @param mask defines the mask associated with this state
  60121. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60122. * @param target defines the original target of the state
  60123. * @param currentTarget defines the current target of the state
  60124. */
  60125. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60126. /**
  60127. * Initialize the current event state
  60128. * @param mask defines the mask associated with this state
  60129. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60130. * @param target defines the original target of the state
  60131. * @param currentTarget defines the current target of the state
  60132. * @returns the current event state
  60133. */
  60134. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60135. /**
  60136. * An Observer can set this property to true to prevent subsequent observers of being notified
  60137. */
  60138. skipNextObservers: boolean;
  60139. /**
  60140. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60141. */
  60142. mask: number;
  60143. /**
  60144. * The object that originally notified the event
  60145. */
  60146. target?: any;
  60147. /**
  60148. * The current object in the bubbling phase
  60149. */
  60150. currentTarget?: any;
  60151. /**
  60152. * This will be populated with the return value of the last function that was executed.
  60153. * If it is the first function in the callback chain it will be the event data.
  60154. */
  60155. lastReturnValue?: any;
  60156. }
  60157. /**
  60158. * Represent an Observer registered to a given Observable object.
  60159. */
  60160. export class Observer<T> {
  60161. /**
  60162. * Defines the callback to call when the observer is notified
  60163. */
  60164. callback: (eventData: T, eventState: EventState) => void;
  60165. /**
  60166. * Defines the mask of the observer (used to filter notifications)
  60167. */
  60168. mask: number;
  60169. /**
  60170. * Defines the current scope used to restore the JS context
  60171. */
  60172. scope: any;
  60173. /** @hidden */
  60174. _willBeUnregistered: boolean;
  60175. /**
  60176. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60177. */
  60178. unregisterOnNextCall: boolean;
  60179. /**
  60180. * Creates a new observer
  60181. * @param callback defines the callback to call when the observer is notified
  60182. * @param mask defines the mask of the observer (used to filter notifications)
  60183. * @param scope defines the current scope used to restore the JS context
  60184. */
  60185. constructor(
  60186. /**
  60187. * Defines the callback to call when the observer is notified
  60188. */
  60189. callback: (eventData: T, eventState: EventState) => void,
  60190. /**
  60191. * Defines the mask of the observer (used to filter notifications)
  60192. */
  60193. mask: number,
  60194. /**
  60195. * Defines the current scope used to restore the JS context
  60196. */
  60197. scope?: any);
  60198. }
  60199. /**
  60200. * Represent a list of observers registered to multiple Observables object.
  60201. */
  60202. export class MultiObserver<T> {
  60203. private _observers;
  60204. private _observables;
  60205. /**
  60206. * Release associated resources
  60207. */
  60208. dispose(): void;
  60209. /**
  60210. * Raise a callback when one of the observable will notify
  60211. * @param observables defines a list of observables to watch
  60212. * @param callback defines the callback to call on notification
  60213. * @param mask defines the mask used to filter notifications
  60214. * @param scope defines the current scope used to restore the JS context
  60215. * @returns the new MultiObserver
  60216. */
  60217. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60218. }
  60219. /**
  60220. * The Observable class is a simple implementation of the Observable pattern.
  60221. *
  60222. * 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.
  60223. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60224. * 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).
  60225. * 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.
  60226. */
  60227. export class Observable<T> {
  60228. private _observers;
  60229. private _eventState;
  60230. private _onObserverAdded;
  60231. /**
  60232. * Creates a new observable
  60233. * @param onObserverAdded defines a callback to call when a new observer is added
  60234. */
  60235. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60236. /**
  60237. * Create a new Observer with the specified callback
  60238. * @param callback the callback that will be executed for that Observer
  60239. * @param mask the mask used to filter observers
  60240. * @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.
  60241. * @param scope optional scope for the callback to be called from
  60242. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60243. * @returns the new observer created for the callback
  60244. */
  60245. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60246. /**
  60247. * Create a new Observer with the specified callback and unregisters after the next notification
  60248. * @param callback the callback that will be executed for that Observer
  60249. * @returns the new observer created for the callback
  60250. */
  60251. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60252. /**
  60253. * Remove an Observer from the Observable object
  60254. * @param observer the instance of the Observer to remove
  60255. * @returns false if it doesn't belong to this Observable
  60256. */
  60257. remove(observer: Nullable<Observer<T>>): boolean;
  60258. /**
  60259. * Remove a callback from the Observable object
  60260. * @param callback the callback to remove
  60261. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60262. * @returns false if it doesn't belong to this Observable
  60263. */
  60264. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60265. private _deferUnregister;
  60266. private _remove;
  60267. /**
  60268. * Notify all Observers by calling their respective callback with the given data
  60269. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60270. * @param eventData defines the data to send to all observers
  60271. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60272. * @param target defines the original target of the state
  60273. * @param currentTarget defines the current target of the state
  60274. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60275. */
  60276. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60277. /**
  60278. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60279. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60280. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60281. * and it is crucial that all callbacks will be executed.
  60282. * The order of the callbacks is kept, callbacks are not executed parallel.
  60283. *
  60284. * @param eventData The data to be sent to each callback
  60285. * @param mask is used to filter observers defaults to -1
  60286. * @param target defines the callback target (see EventState)
  60287. * @param currentTarget defines he current object in the bubbling phase
  60288. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60289. */
  60290. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60291. /**
  60292. * Notify a specific observer
  60293. * @param observer defines the observer to notify
  60294. * @param eventData defines the data to be sent to each callback
  60295. * @param mask is used to filter observers defaults to -1
  60296. */
  60297. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60298. /**
  60299. * Gets a boolean indicating if the observable has at least one observer
  60300. * @returns true is the Observable has at least one Observer registered
  60301. */
  60302. hasObservers(): boolean;
  60303. /**
  60304. * Clear the list of observers
  60305. */
  60306. clear(): void;
  60307. /**
  60308. * Clone the current observable
  60309. * @returns a new observable
  60310. */
  60311. clone(): Observable<T>;
  60312. /**
  60313. * Does this observable handles observer registered with a given mask
  60314. * @param mask defines the mask to be tested
  60315. * @return whether or not one observer registered with the given mask is handeled
  60316. **/
  60317. hasSpecificMask(mask?: number): boolean;
  60318. }
  60319. }
  60320. declare module BABYLON {
  60321. /**
  60322. * Class used to help managing file picking and drag'n'drop
  60323. * File Storage
  60324. */
  60325. export class FilesInputStore {
  60326. /**
  60327. * List of files ready to be loaded
  60328. */
  60329. static FilesToLoad: {
  60330. [key: string]: File;
  60331. };
  60332. }
  60333. }
  60334. declare module BABYLON {
  60335. /** Defines the cross module used constants to avoid circular dependncies */
  60336. export class Constants {
  60337. /** Defines that alpha blending is disabled */
  60338. static readonly ALPHA_DISABLE: number;
  60339. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60340. static readonly ALPHA_ADD: number;
  60341. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60342. static readonly ALPHA_COMBINE: number;
  60343. /** Defines that alpha blending to DEST - SRC * DEST */
  60344. static readonly ALPHA_SUBTRACT: number;
  60345. /** Defines that alpha blending to SRC * DEST */
  60346. static readonly ALPHA_MULTIPLY: number;
  60347. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60348. static readonly ALPHA_MAXIMIZED: number;
  60349. /** Defines that alpha blending to SRC + DEST */
  60350. static readonly ALPHA_ONEONE: number;
  60351. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60352. static readonly ALPHA_PREMULTIPLIED: number;
  60353. /**
  60354. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60355. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60356. */
  60357. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60358. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60359. static readonly ALPHA_INTERPOLATE: number;
  60360. /**
  60361. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60362. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60363. */
  60364. static readonly ALPHA_SCREENMODE: number;
  60365. /** Defines that the ressource is not delayed*/
  60366. static readonly DELAYLOADSTATE_NONE: number;
  60367. /** Defines that the ressource was successfully delay loaded */
  60368. static readonly DELAYLOADSTATE_LOADED: number;
  60369. /** Defines that the ressource is currently delay loading */
  60370. static readonly DELAYLOADSTATE_LOADING: number;
  60371. /** Defines that the ressource is delayed and has not started loading */
  60372. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60374. static readonly NEVER: number;
  60375. /** 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 */
  60376. static readonly ALWAYS: number;
  60377. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60378. static readonly LESS: number;
  60379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60380. static readonly EQUAL: number;
  60381. /** 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 */
  60382. static readonly LEQUAL: number;
  60383. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60384. static readonly GREATER: number;
  60385. /** 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 */
  60386. static readonly GEQUAL: number;
  60387. /** 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 */
  60388. static readonly NOTEQUAL: number;
  60389. /** Passed to stencilOperation to specify that stencil value must be kept */
  60390. static readonly KEEP: number;
  60391. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60392. static readonly REPLACE: number;
  60393. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60394. static readonly INCR: number;
  60395. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60396. static readonly DECR: number;
  60397. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60398. static readonly INVERT: number;
  60399. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60400. static readonly INCR_WRAP: number;
  60401. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60402. static readonly DECR_WRAP: number;
  60403. /** Texture is not repeating outside of 0..1 UVs */
  60404. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60405. /** Texture is repeating outside of 0..1 UVs */
  60406. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60407. /** Texture is repeating and mirrored */
  60408. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60409. /** ALPHA */
  60410. static readonly TEXTUREFORMAT_ALPHA: number;
  60411. /** LUMINANCE */
  60412. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60413. /** LUMINANCE_ALPHA */
  60414. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60415. /** RGB */
  60416. static readonly TEXTUREFORMAT_RGB: number;
  60417. /** RGBA */
  60418. static readonly TEXTUREFORMAT_RGBA: number;
  60419. /** RED */
  60420. static readonly TEXTUREFORMAT_RED: number;
  60421. /** RED (2nd reference) */
  60422. static readonly TEXTUREFORMAT_R: number;
  60423. /** RG */
  60424. static readonly TEXTUREFORMAT_RG: number;
  60425. /** RED_INTEGER */
  60426. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60427. /** RED_INTEGER (2nd reference) */
  60428. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60429. /** RG_INTEGER */
  60430. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60431. /** RGB_INTEGER */
  60432. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  60433. /** RGBA_INTEGER */
  60434. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  60435. /** UNSIGNED_BYTE */
  60436. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  60437. /** UNSIGNED_BYTE (2nd reference) */
  60438. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  60439. /** FLOAT */
  60440. static readonly TEXTURETYPE_FLOAT: number;
  60441. /** HALF_FLOAT */
  60442. static readonly TEXTURETYPE_HALF_FLOAT: number;
  60443. /** BYTE */
  60444. static readonly TEXTURETYPE_BYTE: number;
  60445. /** SHORT */
  60446. static readonly TEXTURETYPE_SHORT: number;
  60447. /** UNSIGNED_SHORT */
  60448. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  60449. /** INT */
  60450. static readonly TEXTURETYPE_INT: number;
  60451. /** UNSIGNED_INT */
  60452. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  60453. /** UNSIGNED_SHORT_4_4_4_4 */
  60454. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  60455. /** UNSIGNED_SHORT_5_5_5_1 */
  60456. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  60457. /** UNSIGNED_SHORT_5_6_5 */
  60458. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  60459. /** UNSIGNED_INT_2_10_10_10_REV */
  60460. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  60461. /** UNSIGNED_INT_24_8 */
  60462. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  60463. /** UNSIGNED_INT_10F_11F_11F_REV */
  60464. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  60465. /** UNSIGNED_INT_5_9_9_9_REV */
  60466. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  60467. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  60468. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60469. /** nearest is mag = nearest and min = nearest and mip = linear */
  60470. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  60471. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60472. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  60473. /** Trilinear is mag = linear and min = linear and mip = linear */
  60474. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  60475. /** nearest is mag = nearest and min = nearest and mip = linear */
  60476. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  60477. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60478. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  60479. /** Trilinear is mag = linear and min = linear and mip = linear */
  60480. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  60481. /** mag = nearest and min = nearest and mip = nearest */
  60482. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  60483. /** mag = nearest and min = linear and mip = nearest */
  60484. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  60485. /** mag = nearest and min = linear and mip = linear */
  60486. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  60487. /** mag = nearest and min = linear and mip = none */
  60488. static readonly TEXTURE_NEAREST_LINEAR: number;
  60489. /** mag = nearest and min = nearest and mip = none */
  60490. static readonly TEXTURE_NEAREST_NEAREST: number;
  60491. /** mag = linear and min = nearest and mip = nearest */
  60492. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  60493. /** mag = linear and min = nearest and mip = linear */
  60494. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  60495. /** mag = linear and min = linear and mip = none */
  60496. static readonly TEXTURE_LINEAR_LINEAR: number;
  60497. /** mag = linear and min = nearest and mip = none */
  60498. static readonly TEXTURE_LINEAR_NEAREST: number;
  60499. /** Explicit coordinates mode */
  60500. static readonly TEXTURE_EXPLICIT_MODE: number;
  60501. /** Spherical coordinates mode */
  60502. static readonly TEXTURE_SPHERICAL_MODE: number;
  60503. /** Planar coordinates mode */
  60504. static readonly TEXTURE_PLANAR_MODE: number;
  60505. /** Cubic coordinates mode */
  60506. static readonly TEXTURE_CUBIC_MODE: number;
  60507. /** Projection coordinates mode */
  60508. static readonly TEXTURE_PROJECTION_MODE: number;
  60509. /** Skybox coordinates mode */
  60510. static readonly TEXTURE_SKYBOX_MODE: number;
  60511. /** Inverse Cubic coordinates mode */
  60512. static readonly TEXTURE_INVCUBIC_MODE: number;
  60513. /** Equirectangular coordinates mode */
  60514. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  60515. /** Equirectangular Fixed coordinates mode */
  60516. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  60517. /** Equirectangular Fixed Mirrored coordinates mode */
  60518. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  60519. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  60520. static readonly SCALEMODE_FLOOR: number;
  60521. /** Defines that texture rescaling will look for the nearest power of 2 size */
  60522. static readonly SCALEMODE_NEAREST: number;
  60523. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  60524. static readonly SCALEMODE_CEILING: number;
  60525. /**
  60526. * The dirty texture flag value
  60527. */
  60528. static readonly MATERIAL_TextureDirtyFlag: number;
  60529. /**
  60530. * The dirty light flag value
  60531. */
  60532. static readonly MATERIAL_LightDirtyFlag: number;
  60533. /**
  60534. * The dirty fresnel flag value
  60535. */
  60536. static readonly MATERIAL_FresnelDirtyFlag: number;
  60537. /**
  60538. * The dirty attribute flag value
  60539. */
  60540. static readonly MATERIAL_AttributesDirtyFlag: number;
  60541. /**
  60542. * The dirty misc flag value
  60543. */
  60544. static readonly MATERIAL_MiscDirtyFlag: number;
  60545. /**
  60546. * The all dirty flag value
  60547. */
  60548. static readonly MATERIAL_AllDirtyFlag: number;
  60549. /**
  60550. * Returns the triangle fill mode
  60551. */
  60552. static readonly MATERIAL_TriangleFillMode: number;
  60553. /**
  60554. * Returns the wireframe mode
  60555. */
  60556. static readonly MATERIAL_WireFrameFillMode: number;
  60557. /**
  60558. * Returns the point fill mode
  60559. */
  60560. static readonly MATERIAL_PointFillMode: number;
  60561. /**
  60562. * Returns the point list draw mode
  60563. */
  60564. static readonly MATERIAL_PointListDrawMode: number;
  60565. /**
  60566. * Returns the line list draw mode
  60567. */
  60568. static readonly MATERIAL_LineListDrawMode: number;
  60569. /**
  60570. * Returns the line loop draw mode
  60571. */
  60572. static readonly MATERIAL_LineLoopDrawMode: number;
  60573. /**
  60574. * Returns the line strip draw mode
  60575. */
  60576. static readonly MATERIAL_LineStripDrawMode: number;
  60577. /**
  60578. * Returns the triangle strip draw mode
  60579. */
  60580. static readonly MATERIAL_TriangleStripDrawMode: number;
  60581. /**
  60582. * Returns the triangle fan draw mode
  60583. */
  60584. static readonly MATERIAL_TriangleFanDrawMode: number;
  60585. /**
  60586. * Stores the clock-wise side orientation
  60587. */
  60588. static readonly MATERIAL_ClockWiseSideOrientation: number;
  60589. /**
  60590. * Stores the counter clock-wise side orientation
  60591. */
  60592. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  60593. /**
  60594. * Nothing
  60595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60596. */
  60597. static readonly ACTION_NothingTrigger: number;
  60598. /**
  60599. * On pick
  60600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60601. */
  60602. static readonly ACTION_OnPickTrigger: number;
  60603. /**
  60604. * On left pick
  60605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60606. */
  60607. static readonly ACTION_OnLeftPickTrigger: number;
  60608. /**
  60609. * On right pick
  60610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60611. */
  60612. static readonly ACTION_OnRightPickTrigger: number;
  60613. /**
  60614. * On center pick
  60615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60616. */
  60617. static readonly ACTION_OnCenterPickTrigger: number;
  60618. /**
  60619. * On pick down
  60620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60621. */
  60622. static readonly ACTION_OnPickDownTrigger: number;
  60623. /**
  60624. * On double pick
  60625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60626. */
  60627. static readonly ACTION_OnDoublePickTrigger: number;
  60628. /**
  60629. * On pick up
  60630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60631. */
  60632. static readonly ACTION_OnPickUpTrigger: number;
  60633. /**
  60634. * On pick out.
  60635. * This trigger will only be raised if you also declared a OnPickDown
  60636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60637. */
  60638. static readonly ACTION_OnPickOutTrigger: number;
  60639. /**
  60640. * On long press
  60641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60642. */
  60643. static readonly ACTION_OnLongPressTrigger: number;
  60644. /**
  60645. * On pointer over
  60646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60647. */
  60648. static readonly ACTION_OnPointerOverTrigger: number;
  60649. /**
  60650. * On pointer out
  60651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60652. */
  60653. static readonly ACTION_OnPointerOutTrigger: number;
  60654. /**
  60655. * On every frame
  60656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60657. */
  60658. static readonly ACTION_OnEveryFrameTrigger: number;
  60659. /**
  60660. * On intersection enter
  60661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60662. */
  60663. static readonly ACTION_OnIntersectionEnterTrigger: number;
  60664. /**
  60665. * On intersection exit
  60666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60667. */
  60668. static readonly ACTION_OnIntersectionExitTrigger: number;
  60669. /**
  60670. * On key down
  60671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60672. */
  60673. static readonly ACTION_OnKeyDownTrigger: number;
  60674. /**
  60675. * On key up
  60676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  60677. */
  60678. static readonly ACTION_OnKeyUpTrigger: number;
  60679. /**
  60680. * Billboard mode will only apply to Y axis
  60681. */
  60682. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  60683. /**
  60684. * Billboard mode will apply to all axes
  60685. */
  60686. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  60687. /**
  60688. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  60689. */
  60690. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  60691. /**
  60692. * Gets or sets base Assets URL
  60693. */
  60694. static readonly PARTICLES_BaseAssetsUrl: string;
  60695. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  60696. * Test order :
  60697. * Is the bounding sphere outside the frustum ?
  60698. * If not, are the bounding box vertices outside the frustum ?
  60699. * It not, then the cullable object is in the frustum.
  60700. */
  60701. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  60702. /** Culling strategy : Bounding Sphere Only.
  60703. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  60704. * It's also less accurate than the standard because some not visible objects can still be selected.
  60705. * Test : is the bounding sphere outside the frustum ?
  60706. * If not, then the cullable object is in the frustum.
  60707. */
  60708. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  60709. /** Culling strategy : Optimistic Inclusion.
  60710. * This in an inclusion test first, then the standard exclusion test.
  60711. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  60712. * 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.
  60713. * Anyway, it's as accurate as the standard strategy.
  60714. * Test :
  60715. * Is the cullable object bounding sphere center in the frustum ?
  60716. * If not, apply the default culling strategy.
  60717. */
  60718. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  60719. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  60720. * This in an inclusion test first, then the bounding sphere only exclusion test.
  60721. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  60722. * 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.
  60723. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  60724. * Test :
  60725. * Is the cullable object bounding sphere center in the frustum ?
  60726. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  60727. */
  60728. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  60729. /**
  60730. * No logging while loading
  60731. */
  60732. static readonly SCENELOADER_NO_LOGGING: number;
  60733. /**
  60734. * Minimal logging while loading
  60735. */
  60736. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  60737. /**
  60738. * Summary logging while loading
  60739. */
  60740. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  60741. /**
  60742. * Detailled logging while loading
  60743. */
  60744. static readonly SCENELOADER_DETAILED_LOGGING: number;
  60745. }
  60746. }
  60747. declare module BABYLON {
  60748. /**
  60749. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  60750. * Babylon.js
  60751. */
  60752. export class DomManagement {
  60753. /**
  60754. * Checks if the window object exists
  60755. * @returns true if the window object exists
  60756. */
  60757. static IsWindowObjectExist(): boolean;
  60758. /**
  60759. * Extracts text content from a DOM element hierarchy
  60760. * @param element defines the root element
  60761. * @returns a string
  60762. */
  60763. static GetDOMTextContent(element: HTMLElement): string;
  60764. }
  60765. }
  60766. declare module BABYLON {
  60767. /**
  60768. * Logger used througouht the application to allow configuration of
  60769. * the log level required for the messages.
  60770. */
  60771. export class Logger {
  60772. /**
  60773. * No log
  60774. */
  60775. static readonly NoneLogLevel: number;
  60776. /**
  60777. * Only message logs
  60778. */
  60779. static readonly MessageLogLevel: number;
  60780. /**
  60781. * Only warning logs
  60782. */
  60783. static readonly WarningLogLevel: number;
  60784. /**
  60785. * Only error logs
  60786. */
  60787. static readonly ErrorLogLevel: number;
  60788. /**
  60789. * All logs
  60790. */
  60791. static readonly AllLogLevel: number;
  60792. private static _LogCache;
  60793. /**
  60794. * Gets a value indicating the number of loading errors
  60795. * @ignorenaming
  60796. */
  60797. static errorsCount: number;
  60798. /**
  60799. * Callback called when a new log is added
  60800. */
  60801. static OnNewCacheEntry: (entry: string) => void;
  60802. private static _AddLogEntry;
  60803. private static _FormatMessage;
  60804. private static _LogDisabled;
  60805. private static _LogEnabled;
  60806. private static _WarnDisabled;
  60807. private static _WarnEnabled;
  60808. private static _ErrorDisabled;
  60809. private static _ErrorEnabled;
  60810. /**
  60811. * Log a message to the console
  60812. */
  60813. static Log: (message: string) => void;
  60814. /**
  60815. * Write a warning message to the console
  60816. */
  60817. static Warn: (message: string) => void;
  60818. /**
  60819. * Write an error message to the console
  60820. */
  60821. static Error: (message: string) => void;
  60822. /**
  60823. * Gets current log cache (list of logs)
  60824. */
  60825. static readonly LogCache: string;
  60826. /**
  60827. * Clears the log cache
  60828. */
  60829. static ClearLogCache(): void;
  60830. /**
  60831. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  60832. */
  60833. static LogLevels: number;
  60834. }
  60835. }
  60836. declare module BABYLON {
  60837. /** @hidden */
  60838. export class _TypeStore {
  60839. /** @hidden */
  60840. static RegisteredTypes: {
  60841. [key: string]: Object;
  60842. };
  60843. /** @hidden */
  60844. static GetClass(fqdn: string): any;
  60845. }
  60846. }
  60847. declare module BABYLON {
  60848. /**
  60849. * Class containing a set of static utilities functions for deep copy.
  60850. */
  60851. export class DeepCopier {
  60852. /**
  60853. * Tries to copy an object by duplicating every property
  60854. * @param source defines the source object
  60855. * @param destination defines the target object
  60856. * @param doNotCopyList defines a list of properties to avoid
  60857. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  60858. */
  60859. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  60860. }
  60861. }
  60862. declare module BABYLON {
  60863. /**
  60864. * Class containing a set of static utilities functions for precision date
  60865. */
  60866. export class PrecisionDate {
  60867. /**
  60868. * Gets either window.performance.now() if supported or Date.now() else
  60869. */
  60870. static readonly Now: number;
  60871. }
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Class used to evalaute queries containing `and` and `or` operators
  60876. */
  60877. export class AndOrNotEvaluator {
  60878. /**
  60879. * Evaluate a query
  60880. * @param query defines the query to evaluate
  60881. * @param evaluateCallback defines the callback used to filter result
  60882. * @returns true if the query matches
  60883. */
  60884. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  60885. private static _HandleParenthesisContent;
  60886. private static _SimplifyNegation;
  60887. }
  60888. }
  60889. declare module BABYLON {
  60890. /**
  60891. * Class used to store custom tags
  60892. */
  60893. export class Tags {
  60894. /**
  60895. * Adds support for tags on the given object
  60896. * @param obj defines the object to use
  60897. */
  60898. static EnableFor(obj: any): void;
  60899. /**
  60900. * Removes tags support
  60901. * @param obj defines the object to use
  60902. */
  60903. static DisableFor(obj: any): void;
  60904. /**
  60905. * Gets a boolean indicating if the given object has tags
  60906. * @param obj defines the object to use
  60907. * @returns a boolean
  60908. */
  60909. static HasTags(obj: any): boolean;
  60910. /**
  60911. * Gets the tags available on a given object
  60912. * @param obj defines the object to use
  60913. * @param asString defines if the tags must be returned as a string instead of an array of strings
  60914. * @returns the tags
  60915. */
  60916. static GetTags(obj: any, asString?: boolean): any;
  60917. /**
  60918. * Adds tags to an object
  60919. * @param obj defines the object to use
  60920. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  60921. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  60922. */
  60923. static AddTagsTo(obj: any, tagsString: string): void;
  60924. /**
  60925. * @hidden
  60926. */
  60927. static _AddTagTo(obj: any, tag: string): void;
  60928. /**
  60929. * Removes specific tags from a specific object
  60930. * @param obj defines the object to use
  60931. * @param tagsString defines the tags to remove
  60932. */
  60933. static RemoveTagsFrom(obj: any, tagsString: string): void;
  60934. /**
  60935. * @hidden
  60936. */
  60937. static _RemoveTagFrom(obj: any, tag: string): void;
  60938. /**
  60939. * Defines if tags hosted on an object match a given query
  60940. * @param obj defines the object to use
  60941. * @param tagsQuery defines the tag query
  60942. * @returns a boolean
  60943. */
  60944. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  60945. }
  60946. }
  60947. declare module BABYLON {
  60948. /**
  60949. * Manages the defines for the Material
  60950. */
  60951. export class MaterialDefines {
  60952. private _keys;
  60953. private _isDirty;
  60954. /** @hidden */
  60955. _renderId: number;
  60956. /** @hidden */
  60957. _areLightsDirty: boolean;
  60958. /** @hidden */
  60959. _areAttributesDirty: boolean;
  60960. /** @hidden */
  60961. _areTexturesDirty: boolean;
  60962. /** @hidden */
  60963. _areFresnelDirty: boolean;
  60964. /** @hidden */
  60965. _areMiscDirty: boolean;
  60966. /** @hidden */
  60967. _areImageProcessingDirty: boolean;
  60968. /** @hidden */
  60969. _normals: boolean;
  60970. /** @hidden */
  60971. _uvs: boolean;
  60972. /** @hidden */
  60973. _needNormals: boolean;
  60974. /** @hidden */
  60975. _needUVs: boolean;
  60976. /**
  60977. * Specifies if the material needs to be re-calculated
  60978. */
  60979. readonly isDirty: boolean;
  60980. /**
  60981. * Marks the material to indicate that it has been re-calculated
  60982. */
  60983. markAsProcessed(): void;
  60984. /**
  60985. * Marks the material to indicate that it needs to be re-calculated
  60986. */
  60987. markAsUnprocessed(): void;
  60988. /**
  60989. * Marks the material to indicate all of its defines need to be re-calculated
  60990. */
  60991. markAllAsDirty(): void;
  60992. /**
  60993. * Marks the material to indicate that image processing needs to be re-calculated
  60994. */
  60995. markAsImageProcessingDirty(): void;
  60996. /**
  60997. * Marks the material to indicate the lights need to be re-calculated
  60998. */
  60999. markAsLightDirty(): void;
  61000. /**
  61001. * Marks the attribute state as changed
  61002. */
  61003. markAsAttributesDirty(): void;
  61004. /**
  61005. * Marks the texture state as changed
  61006. */
  61007. markAsTexturesDirty(): void;
  61008. /**
  61009. * Marks the fresnel state as changed
  61010. */
  61011. markAsFresnelDirty(): void;
  61012. /**
  61013. * Marks the misc state as changed
  61014. */
  61015. markAsMiscDirty(): void;
  61016. /**
  61017. * Rebuilds the material defines
  61018. */
  61019. rebuild(): void;
  61020. /**
  61021. * Specifies if two material defines are equal
  61022. * @param other - A material define instance to compare to
  61023. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61024. */
  61025. isEqual(other: MaterialDefines): boolean;
  61026. /**
  61027. * Clones this instance's defines to another instance
  61028. * @param other - material defines to clone values to
  61029. */
  61030. cloneTo(other: MaterialDefines): void;
  61031. /**
  61032. * Resets the material define values
  61033. */
  61034. reset(): void;
  61035. /**
  61036. * Converts the material define values to a string
  61037. * @returns - String of material define information
  61038. */
  61039. toString(): string;
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /**
  61044. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61045. */
  61046. export class PerformanceMonitor {
  61047. private _enabled;
  61048. private _rollingFrameTime;
  61049. private _lastFrameTimeMs;
  61050. /**
  61051. * constructor
  61052. * @param frameSampleSize The number of samples required to saturate the sliding window
  61053. */
  61054. constructor(frameSampleSize?: number);
  61055. /**
  61056. * Samples current frame
  61057. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61058. */
  61059. sampleFrame(timeMs?: number): void;
  61060. /**
  61061. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61062. */
  61063. readonly averageFrameTime: number;
  61064. /**
  61065. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61066. */
  61067. readonly averageFrameTimeVariance: number;
  61068. /**
  61069. * Returns the frame time of the most recent frame
  61070. */
  61071. readonly instantaneousFrameTime: number;
  61072. /**
  61073. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61074. */
  61075. readonly averageFPS: number;
  61076. /**
  61077. * Returns the average framerate in frames per second using the most recent frame time
  61078. */
  61079. readonly instantaneousFPS: number;
  61080. /**
  61081. * Returns true if enough samples have been taken to completely fill the sliding window
  61082. */
  61083. readonly isSaturated: boolean;
  61084. /**
  61085. * Enables contributions to the sliding window sample set
  61086. */
  61087. enable(): void;
  61088. /**
  61089. * Disables contributions to the sliding window sample set
  61090. * Samples will not be interpolated over the disabled period
  61091. */
  61092. disable(): void;
  61093. /**
  61094. * Returns true if sampling is enabled
  61095. */
  61096. readonly isEnabled: boolean;
  61097. /**
  61098. * Resets performance monitor
  61099. */
  61100. reset(): void;
  61101. }
  61102. /**
  61103. * RollingAverage
  61104. *
  61105. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61106. */
  61107. export class RollingAverage {
  61108. /**
  61109. * Current average
  61110. */
  61111. average: number;
  61112. /**
  61113. * Current variance
  61114. */
  61115. variance: number;
  61116. protected _samples: Array<number>;
  61117. protected _sampleCount: number;
  61118. protected _pos: number;
  61119. protected _m2: number;
  61120. /**
  61121. * constructor
  61122. * @param length The number of samples required to saturate the sliding window
  61123. */
  61124. constructor(length: number);
  61125. /**
  61126. * Adds a sample to the sample set
  61127. * @param v The sample value
  61128. */
  61129. add(v: number): void;
  61130. /**
  61131. * Returns previously added values or null if outside of history or outside the sliding window domain
  61132. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61133. * @return Value previously recorded with add() or null if outside of range
  61134. */
  61135. history(i: number): number;
  61136. /**
  61137. * Returns true if enough samples have been taken to completely fill the sliding window
  61138. * @return true if sample-set saturated
  61139. */
  61140. isSaturated(): boolean;
  61141. /**
  61142. * Resets the rolling average (equivalent to 0 samples taken so far)
  61143. */
  61144. reset(): void;
  61145. /**
  61146. * Wraps a value around the sample range boundaries
  61147. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61148. * @return Wrapped position in sample range
  61149. */
  61150. protected _wrapPosition(i: number): number;
  61151. }
  61152. }
  61153. declare module BABYLON {
  61154. /**
  61155. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61156. * The underlying implementation relies on an associative array to ensure the best performances.
  61157. * The value can be anything including 'null' but except 'undefined'
  61158. */
  61159. export class StringDictionary<T> {
  61160. /**
  61161. * This will clear this dictionary and copy the content from the 'source' one.
  61162. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61163. * @param source the dictionary to take the content from and copy to this dictionary
  61164. */
  61165. copyFrom(source: StringDictionary<T>): void;
  61166. /**
  61167. * Get a value based from its key
  61168. * @param key the given key to get the matching value from
  61169. * @return the value if found, otherwise undefined is returned
  61170. */
  61171. get(key: string): T | undefined;
  61172. /**
  61173. * Get a value from its key or add it if it doesn't exist.
  61174. * This method will ensure you that a given key/data will be present in the dictionary.
  61175. * @param key the given key to get the matching value from
  61176. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61177. * The factory will only be invoked if there's no data for the given key.
  61178. * @return the value corresponding to the key.
  61179. */
  61180. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61181. /**
  61182. * Get a value from its key if present in the dictionary otherwise add it
  61183. * @param key the key to get the value from
  61184. * @param val if there's no such key/value pair in the dictionary add it with this value
  61185. * @return the value corresponding to the key
  61186. */
  61187. getOrAdd(key: string, val: T): T;
  61188. /**
  61189. * Check if there's a given key in the dictionary
  61190. * @param key the key to check for
  61191. * @return true if the key is present, false otherwise
  61192. */
  61193. contains(key: string): boolean;
  61194. /**
  61195. * Add a new key and its corresponding value
  61196. * @param key the key to add
  61197. * @param value the value corresponding to the key
  61198. * @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
  61199. */
  61200. add(key: string, value: T): boolean;
  61201. /**
  61202. * Update a specific value associated to a key
  61203. * @param key defines the key to use
  61204. * @param value defines the value to store
  61205. * @returns true if the value was updated (or false if the key was not found)
  61206. */
  61207. set(key: string, value: T): boolean;
  61208. /**
  61209. * Get the element of the given key and remove it from the dictionary
  61210. * @param key defines the key to search
  61211. * @returns the value associated with the key or null if not found
  61212. */
  61213. getAndRemove(key: string): Nullable<T>;
  61214. /**
  61215. * Remove a key/value from the dictionary.
  61216. * @param key the key to remove
  61217. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61218. */
  61219. remove(key: string): boolean;
  61220. /**
  61221. * Clear the whole content of the dictionary
  61222. */
  61223. clear(): void;
  61224. /**
  61225. * Gets the current count
  61226. */
  61227. readonly count: number;
  61228. /**
  61229. * Execute a callback on each key/val of the dictionary.
  61230. * Note that you can remove any element in this dictionary in the callback implementation
  61231. * @param callback the callback to execute on a given key/value pair
  61232. */
  61233. forEach(callback: (key: string, val: T) => void): void;
  61234. /**
  61235. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61236. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61237. * Note that you can remove any element in this dictionary in the callback implementation
  61238. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61239. * @returns the first item
  61240. */
  61241. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61242. private _count;
  61243. private _data;
  61244. }
  61245. }
  61246. declare module BABYLON {
  61247. /**
  61248. * Helper class that provides a small promise polyfill
  61249. */
  61250. export class PromisePolyfill {
  61251. /**
  61252. * Static function used to check if the polyfill is required
  61253. * If this is the case then the function will inject the polyfill to window.Promise
  61254. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61255. */
  61256. static Apply(force?: boolean): void;
  61257. }
  61258. }
  61259. declare module BABYLON {
  61260. /**
  61261. * Class used to store data that will be store in GPU memory
  61262. */
  61263. export class Buffer {
  61264. private _engine;
  61265. private _buffer;
  61266. /** @hidden */
  61267. _data: Nullable<DataArray>;
  61268. private _updatable;
  61269. private _instanced;
  61270. /**
  61271. * Gets the byte stride.
  61272. */
  61273. readonly byteStride: number;
  61274. /**
  61275. * Constructor
  61276. * @param engine the engine
  61277. * @param data the data to use for this buffer
  61278. * @param updatable whether the data is updatable
  61279. * @param stride the stride (optional)
  61280. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61281. * @param instanced whether the buffer is instanced (optional)
  61282. * @param useBytes set to true if the stride in in bytes (optional)
  61283. */
  61284. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61285. /**
  61286. * Create a new VertexBuffer based on the current buffer
  61287. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61288. * @param offset defines offset in the buffer (0 by default)
  61289. * @param size defines the size in floats of attributes (position is 3 for instance)
  61290. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61291. * @param instanced defines if the vertex buffer contains indexed data
  61292. * @param useBytes defines if the offset and stride are in bytes
  61293. * @returns the new vertex buffer
  61294. */
  61295. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61296. /**
  61297. * Gets a boolean indicating if the Buffer is updatable?
  61298. * @returns true if the buffer is updatable
  61299. */
  61300. isUpdatable(): boolean;
  61301. /**
  61302. * Gets current buffer's data
  61303. * @returns a DataArray or null
  61304. */
  61305. getData(): Nullable<DataArray>;
  61306. /**
  61307. * Gets underlying native buffer
  61308. * @returns underlying native buffer
  61309. */
  61310. getBuffer(): Nullable<WebGLBuffer>;
  61311. /**
  61312. * Gets the stride in float32 units (i.e. byte stride / 4).
  61313. * May not be an integer if the byte stride is not divisible by 4.
  61314. * DEPRECATED. Use byteStride instead.
  61315. * @returns the stride in float32 units
  61316. */
  61317. getStrideSize(): number;
  61318. /**
  61319. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61320. * @param data defines the data to store
  61321. */
  61322. create(data?: Nullable<DataArray>): void;
  61323. /** @hidden */
  61324. _rebuild(): void;
  61325. /**
  61326. * Update current buffer data
  61327. * @param data defines the data to store
  61328. */
  61329. update(data: DataArray): void;
  61330. /**
  61331. * Updates the data directly.
  61332. * @param data the new data
  61333. * @param offset the new offset
  61334. * @param vertexCount the vertex count (optional)
  61335. * @param useBytes set to true if the offset is in bytes
  61336. */
  61337. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61338. /**
  61339. * Release all resources
  61340. */
  61341. dispose(): void;
  61342. }
  61343. /**
  61344. * Specialized buffer used to store vertex data
  61345. */
  61346. export class VertexBuffer {
  61347. /** @hidden */
  61348. _buffer: Buffer;
  61349. private _kind;
  61350. private _size;
  61351. private _ownsBuffer;
  61352. private _instanced;
  61353. private _instanceDivisor;
  61354. /**
  61355. * The byte type.
  61356. */
  61357. static readonly BYTE: number;
  61358. /**
  61359. * The unsigned byte type.
  61360. */
  61361. static readonly UNSIGNED_BYTE: number;
  61362. /**
  61363. * The short type.
  61364. */
  61365. static readonly SHORT: number;
  61366. /**
  61367. * The unsigned short type.
  61368. */
  61369. static readonly UNSIGNED_SHORT: number;
  61370. /**
  61371. * The integer type.
  61372. */
  61373. static readonly INT: number;
  61374. /**
  61375. * The unsigned integer type.
  61376. */
  61377. static readonly UNSIGNED_INT: number;
  61378. /**
  61379. * The float type.
  61380. */
  61381. static readonly FLOAT: number;
  61382. /**
  61383. * Gets or sets the instance divisor when in instanced mode
  61384. */
  61385. instanceDivisor: number;
  61386. /**
  61387. * Gets the byte stride.
  61388. */
  61389. readonly byteStride: number;
  61390. /**
  61391. * Gets the byte offset.
  61392. */
  61393. readonly byteOffset: number;
  61394. /**
  61395. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61396. */
  61397. readonly normalized: boolean;
  61398. /**
  61399. * Gets the data type of each component in the array.
  61400. */
  61401. readonly type: number;
  61402. /**
  61403. * Constructor
  61404. * @param engine the engine
  61405. * @param data the data to use for this vertex buffer
  61406. * @param kind the vertex buffer kind
  61407. * @param updatable whether the data is updatable
  61408. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61409. * @param stride the stride (optional)
  61410. * @param instanced whether the buffer is instanced (optional)
  61411. * @param offset the offset of the data (optional)
  61412. * @param size the number of components (optional)
  61413. * @param type the type of the component (optional)
  61414. * @param normalized whether the data contains normalized data (optional)
  61415. * @param useBytes set to true if stride and offset are in bytes (optional)
  61416. */
  61417. 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);
  61418. /** @hidden */
  61419. _rebuild(): void;
  61420. /**
  61421. * Returns the kind of the VertexBuffer (string)
  61422. * @returns a string
  61423. */
  61424. getKind(): string;
  61425. /**
  61426. * Gets a boolean indicating if the VertexBuffer is updatable?
  61427. * @returns true if the buffer is updatable
  61428. */
  61429. isUpdatable(): boolean;
  61430. /**
  61431. * Gets current buffer's data
  61432. * @returns a DataArray or null
  61433. */
  61434. getData(): Nullable<DataArray>;
  61435. /**
  61436. * Gets underlying native buffer
  61437. * @returns underlying native buffer
  61438. */
  61439. getBuffer(): Nullable<WebGLBuffer>;
  61440. /**
  61441. * Gets the stride in float32 units (i.e. byte stride / 4).
  61442. * May not be an integer if the byte stride is not divisible by 4.
  61443. * DEPRECATED. Use byteStride instead.
  61444. * @returns the stride in float32 units
  61445. */
  61446. getStrideSize(): number;
  61447. /**
  61448. * Returns the offset as a multiple of the type byte length.
  61449. * DEPRECATED. Use byteOffset instead.
  61450. * @returns the offset in bytes
  61451. */
  61452. getOffset(): number;
  61453. /**
  61454. * Returns the number of components per vertex attribute (integer)
  61455. * @returns the size in float
  61456. */
  61457. getSize(): number;
  61458. /**
  61459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  61460. * @returns true if this buffer is instanced
  61461. */
  61462. getIsInstanced(): boolean;
  61463. /**
  61464. * Returns the instancing divisor, zero for non-instanced (integer).
  61465. * @returns a number
  61466. */
  61467. getInstanceDivisor(): number;
  61468. /**
  61469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61470. * @param data defines the data to store
  61471. */
  61472. create(data?: DataArray): void;
  61473. /**
  61474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  61475. * This function will create a new buffer if the current one is not updatable
  61476. * @param data defines the data to store
  61477. */
  61478. update(data: DataArray): void;
  61479. /**
  61480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  61481. * Returns the directly updated WebGLBuffer.
  61482. * @param data the new data
  61483. * @param offset the new offset
  61484. * @param useBytes set to true if the offset is in bytes
  61485. */
  61486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  61487. /**
  61488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  61489. */
  61490. dispose(): void;
  61491. /**
  61492. * Enumerates each value of this vertex buffer as numbers.
  61493. * @param count the number of values to enumerate
  61494. * @param callback the callback function called for each value
  61495. */
  61496. forEach(count: number, callback: (value: number, index: number) => void): void;
  61497. /**
  61498. * Positions
  61499. */
  61500. static readonly PositionKind: string;
  61501. /**
  61502. * Normals
  61503. */
  61504. static readonly NormalKind: string;
  61505. /**
  61506. * Tangents
  61507. */
  61508. static readonly TangentKind: string;
  61509. /**
  61510. * Texture coordinates
  61511. */
  61512. static readonly UVKind: string;
  61513. /**
  61514. * Texture coordinates 2
  61515. */
  61516. static readonly UV2Kind: string;
  61517. /**
  61518. * Texture coordinates 3
  61519. */
  61520. static readonly UV3Kind: string;
  61521. /**
  61522. * Texture coordinates 4
  61523. */
  61524. static readonly UV4Kind: string;
  61525. /**
  61526. * Texture coordinates 5
  61527. */
  61528. static readonly UV5Kind: string;
  61529. /**
  61530. * Texture coordinates 6
  61531. */
  61532. static readonly UV6Kind: string;
  61533. /**
  61534. * Colors
  61535. */
  61536. static readonly ColorKind: string;
  61537. /**
  61538. * Matrix indices (for bones)
  61539. */
  61540. static readonly MatricesIndicesKind: string;
  61541. /**
  61542. * Matrix weights (for bones)
  61543. */
  61544. static readonly MatricesWeightsKind: string;
  61545. /**
  61546. * Additional matrix indices (for bones)
  61547. */
  61548. static readonly MatricesIndicesExtraKind: string;
  61549. /**
  61550. * Additional matrix weights (for bones)
  61551. */
  61552. static readonly MatricesWeightsExtraKind: string;
  61553. /**
  61554. * Deduces the stride given a kind.
  61555. * @param kind The kind string to deduce
  61556. * @returns The deduced stride
  61557. */
  61558. static DeduceStride(kind: string): number;
  61559. /**
  61560. * Gets the byte length of the given type.
  61561. * @param type the type
  61562. * @returns the number of bytes
  61563. */
  61564. static GetTypeByteLength(type: number): number;
  61565. /**
  61566. * Enumerates each value of the given parameters as numbers.
  61567. * @param data the data to enumerate
  61568. * @param byteOffset the byte offset of the data
  61569. * @param byteStride the byte stride of the data
  61570. * @param componentCount the number of components per element
  61571. * @param componentType the type of the component
  61572. * @param count the total number of components
  61573. * @param normalized whether the data is normalized
  61574. * @param callback the callback function called for each value
  61575. */
  61576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  61577. private static _GetFloatValue;
  61578. }
  61579. }
  61580. declare module BABYLON {
  61581. /**
  61582. * Class representing spherical polynomial coefficients to the 3rd degree
  61583. */
  61584. export class SphericalPolynomial {
  61585. /**
  61586. * The x coefficients of the spherical polynomial
  61587. */
  61588. x: Vector3;
  61589. /**
  61590. * The y coefficients of the spherical polynomial
  61591. */
  61592. y: Vector3;
  61593. /**
  61594. * The z coefficients of the spherical polynomial
  61595. */
  61596. z: Vector3;
  61597. /**
  61598. * The xx coefficients of the spherical polynomial
  61599. */
  61600. xx: Vector3;
  61601. /**
  61602. * The yy coefficients of the spherical polynomial
  61603. */
  61604. yy: Vector3;
  61605. /**
  61606. * The zz coefficients of the spherical polynomial
  61607. */
  61608. zz: Vector3;
  61609. /**
  61610. * The xy coefficients of the spherical polynomial
  61611. */
  61612. xy: Vector3;
  61613. /**
  61614. * The yz coefficients of the spherical polynomial
  61615. */
  61616. yz: Vector3;
  61617. /**
  61618. * The zx coefficients of the spherical polynomial
  61619. */
  61620. zx: Vector3;
  61621. /**
  61622. * Adds an ambient color to the spherical polynomial
  61623. * @param color the color to add
  61624. */
  61625. addAmbient(color: Color3): void;
  61626. /**
  61627. * Scales the spherical polynomial by the given amount
  61628. * @param scale the amount to scale
  61629. */
  61630. scale(scale: number): void;
  61631. /**
  61632. * Gets the spherical polynomial from harmonics
  61633. * @param harmonics the spherical harmonics
  61634. * @returns the spherical polynomial
  61635. */
  61636. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  61637. /**
  61638. * Constructs a spherical polynomial from an array.
  61639. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  61640. * @returns the spherical polynomial
  61641. */
  61642. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  61643. }
  61644. /**
  61645. * Class representing spherical harmonics coefficients to the 3rd degree
  61646. */
  61647. export class SphericalHarmonics {
  61648. /**
  61649. * The l0,0 coefficients of the spherical harmonics
  61650. */
  61651. l00: Vector3;
  61652. /**
  61653. * The l1,-1 coefficients of the spherical harmonics
  61654. */
  61655. l1_1: Vector3;
  61656. /**
  61657. * The l1,0 coefficients of the spherical harmonics
  61658. */
  61659. l10: Vector3;
  61660. /**
  61661. * The l1,1 coefficients of the spherical harmonics
  61662. */
  61663. l11: Vector3;
  61664. /**
  61665. * The l2,-2 coefficients of the spherical harmonics
  61666. */
  61667. l2_2: Vector3;
  61668. /**
  61669. * The l2,-1 coefficients of the spherical harmonics
  61670. */
  61671. l2_1: Vector3;
  61672. /**
  61673. * The l2,0 coefficients of the spherical harmonics
  61674. */
  61675. l20: Vector3;
  61676. /**
  61677. * The l2,1 coefficients of the spherical harmonics
  61678. */
  61679. l21: Vector3;
  61680. /**
  61681. * The l2,2 coefficients of the spherical harmonics
  61682. */
  61683. lL22: Vector3;
  61684. /**
  61685. * Adds a light to the spherical harmonics
  61686. * @param direction the direction of the light
  61687. * @param color the color of the light
  61688. * @param deltaSolidAngle the delta solid angle of the light
  61689. */
  61690. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  61691. /**
  61692. * Scales the spherical harmonics by the given amount
  61693. * @param scale the amount to scale
  61694. */
  61695. scale(scale: number): void;
  61696. /**
  61697. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  61698. *
  61699. * ```
  61700. * E_lm = A_l * L_lm
  61701. * ```
  61702. *
  61703. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  61704. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  61705. * the scaling factors are given in equation 9.
  61706. */
  61707. convertIncidentRadianceToIrradiance(): void;
  61708. /**
  61709. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  61710. *
  61711. * ```
  61712. * L = (1/pi) * E * rho
  61713. * ```
  61714. *
  61715. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  61716. */
  61717. convertIrradianceToLambertianRadiance(): void;
  61718. /**
  61719. * Gets the spherical harmonics from polynomial
  61720. * @param polynomial the spherical polynomial
  61721. * @returns the spherical harmonics
  61722. */
  61723. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  61724. /**
  61725. * Constructs a spherical harmonics from an array.
  61726. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  61727. * @returns the spherical harmonics
  61728. */
  61729. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  61730. }
  61731. }
  61732. declare module BABYLON {
  61733. /**
  61734. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  61735. */
  61736. export interface CubeMapInfo {
  61737. /**
  61738. * The pixel array for the front face.
  61739. * This is stored in format, left to right, up to down format.
  61740. */
  61741. front: Nullable<ArrayBufferView>;
  61742. /**
  61743. * The pixel array for the back face.
  61744. * This is stored in format, left to right, up to down format.
  61745. */
  61746. back: Nullable<ArrayBufferView>;
  61747. /**
  61748. * The pixel array for the left face.
  61749. * This is stored in format, left to right, up to down format.
  61750. */
  61751. left: Nullable<ArrayBufferView>;
  61752. /**
  61753. * The pixel array for the right face.
  61754. * This is stored in format, left to right, up to down format.
  61755. */
  61756. right: Nullable<ArrayBufferView>;
  61757. /**
  61758. * The pixel array for the up face.
  61759. * This is stored in format, left to right, up to down format.
  61760. */
  61761. up: Nullable<ArrayBufferView>;
  61762. /**
  61763. * The pixel array for the down face.
  61764. * This is stored in format, left to right, up to down format.
  61765. */
  61766. down: Nullable<ArrayBufferView>;
  61767. /**
  61768. * The size of the cubemap stored.
  61769. *
  61770. * Each faces will be size * size pixels.
  61771. */
  61772. size: number;
  61773. /**
  61774. * The format of the texture.
  61775. *
  61776. * RGBA, RGB.
  61777. */
  61778. format: number;
  61779. /**
  61780. * The type of the texture data.
  61781. *
  61782. * UNSIGNED_INT, FLOAT.
  61783. */
  61784. type: number;
  61785. /**
  61786. * Specifies whether the texture is in gamma space.
  61787. */
  61788. gammaSpace: boolean;
  61789. }
  61790. /**
  61791. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  61792. */
  61793. export class PanoramaToCubeMapTools {
  61794. private static FACE_FRONT;
  61795. private static FACE_BACK;
  61796. private static FACE_RIGHT;
  61797. private static FACE_LEFT;
  61798. private static FACE_DOWN;
  61799. private static FACE_UP;
  61800. /**
  61801. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  61802. *
  61803. * @param float32Array The source data.
  61804. * @param inputWidth The width of the input panorama.
  61805. * @param inputHeight The height of the input panorama.
  61806. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  61807. * @return The cubemap data
  61808. */
  61809. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  61810. private static CreateCubemapTexture;
  61811. private static CalcProjectionSpherical;
  61812. }
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * Helper class dealing with the extraction of spherical polynomial dataArray
  61817. * from a cube map.
  61818. */
  61819. export class CubeMapToSphericalPolynomialTools {
  61820. private static FileFaces;
  61821. /**
  61822. * Converts a texture to the according Spherical Polynomial data.
  61823. * This extracts the first 3 orders only as they are the only one used in the lighting.
  61824. *
  61825. * @param texture The texture to extract the information from.
  61826. * @return The Spherical Polynomial data.
  61827. */
  61828. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  61829. /**
  61830. * Converts a cubemap to the according Spherical Polynomial data.
  61831. * This extracts the first 3 orders only as they are the only one used in the lighting.
  61832. *
  61833. * @param cubeInfo The Cube map to extract the information from.
  61834. * @return The Spherical Polynomial data.
  61835. */
  61836. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  61837. }
  61838. }
  61839. declare module BABYLON {
  61840. /**
  61841. * The engine store class is responsible to hold all the instances of Engine and Scene created
  61842. * during the life time of the application.
  61843. */
  61844. export class EngineStore {
  61845. /** Gets the list of created engines */
  61846. static Instances: Engine[];
  61847. /**
  61848. * Gets the latest created engine
  61849. */
  61850. static readonly LastCreatedEngine: Nullable<Engine>;
  61851. /**
  61852. * Gets the latest created scene
  61853. */
  61854. static readonly LastCreatedScene: Nullable<Scene>;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Define options used to create a render target texture
  61860. */
  61861. export class RenderTargetCreationOptions {
  61862. /**
  61863. * Specifies is mipmaps must be generated
  61864. */
  61865. generateMipMaps?: boolean;
  61866. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  61867. generateDepthBuffer?: boolean;
  61868. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  61869. generateStencilBuffer?: boolean;
  61870. /** Defines texture type (int by default) */
  61871. type?: number;
  61872. /** Defines sampling mode (trilinear by default) */
  61873. samplingMode?: number;
  61874. /** Defines format (RGBA by default) */
  61875. format?: number;
  61876. }
  61877. }
  61878. declare module BABYLON {
  61879. /**
  61880. * @hidden
  61881. **/
  61882. export class _AlphaState {
  61883. private _isAlphaBlendDirty;
  61884. private _isBlendFunctionParametersDirty;
  61885. private _isBlendEquationParametersDirty;
  61886. private _isBlendConstantsDirty;
  61887. private _alphaBlend;
  61888. private _blendFunctionParameters;
  61889. private _blendEquationParameters;
  61890. private _blendConstants;
  61891. /**
  61892. * Initializes the state.
  61893. */
  61894. constructor();
  61895. readonly isDirty: boolean;
  61896. alphaBlend: boolean;
  61897. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  61898. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  61899. setAlphaEquationParameters(rgb: number, alpha: number): void;
  61900. reset(): void;
  61901. apply(gl: WebGLRenderingContext): void;
  61902. }
  61903. }
  61904. declare module BABYLON {
  61905. /**
  61906. * @hidden
  61907. **/
  61908. export class _DepthCullingState {
  61909. private _isDepthTestDirty;
  61910. private _isDepthMaskDirty;
  61911. private _isDepthFuncDirty;
  61912. private _isCullFaceDirty;
  61913. private _isCullDirty;
  61914. private _isZOffsetDirty;
  61915. private _isFrontFaceDirty;
  61916. private _depthTest;
  61917. private _depthMask;
  61918. private _depthFunc;
  61919. private _cull;
  61920. private _cullFace;
  61921. private _zOffset;
  61922. private _frontFace;
  61923. /**
  61924. * Initializes the state.
  61925. */
  61926. constructor();
  61927. readonly isDirty: boolean;
  61928. zOffset: number;
  61929. cullFace: Nullable<number>;
  61930. cull: Nullable<boolean>;
  61931. depthFunc: Nullable<number>;
  61932. depthMask: boolean;
  61933. depthTest: boolean;
  61934. frontFace: Nullable<number>;
  61935. reset(): void;
  61936. apply(gl: WebGLRenderingContext): void;
  61937. }
  61938. }
  61939. declare module BABYLON {
  61940. /**
  61941. * @hidden
  61942. **/
  61943. export class _StencilState {
  61944. /** 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 */
  61945. static readonly ALWAYS: number;
  61946. /** Passed to stencilOperation to specify that stencil value must be kept */
  61947. static readonly KEEP: number;
  61948. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61949. static readonly REPLACE: number;
  61950. private _isStencilTestDirty;
  61951. private _isStencilMaskDirty;
  61952. private _isStencilFuncDirty;
  61953. private _isStencilOpDirty;
  61954. private _stencilTest;
  61955. private _stencilMask;
  61956. private _stencilFunc;
  61957. private _stencilFuncRef;
  61958. private _stencilFuncMask;
  61959. private _stencilOpStencilFail;
  61960. private _stencilOpDepthFail;
  61961. private _stencilOpStencilDepthPass;
  61962. readonly isDirty: boolean;
  61963. stencilFunc: number;
  61964. stencilFuncRef: number;
  61965. stencilFuncMask: number;
  61966. stencilOpStencilFail: number;
  61967. stencilOpDepthFail: number;
  61968. stencilOpStencilDepthPass: number;
  61969. stencilMask: number;
  61970. stencilTest: boolean;
  61971. constructor();
  61972. reset(): void;
  61973. apply(gl: WebGLRenderingContext): void;
  61974. }
  61975. }
  61976. declare module BABYLON {
  61977. /**
  61978. * @hidden
  61979. **/
  61980. export class _TimeToken {
  61981. _startTimeQuery: Nullable<WebGLQuery>;
  61982. _endTimeQuery: Nullable<WebGLQuery>;
  61983. _timeElapsedQuery: Nullable<WebGLQuery>;
  61984. _timeElapsedQueryEnded: boolean;
  61985. }
  61986. }
  61987. declare module BABYLON {
  61988. /**
  61989. * Internal interface used to track InternalTexture already bound to the GL context
  61990. */
  61991. export interface IInternalTextureTracker {
  61992. /**
  61993. * Gets or set the previous tracker in the list
  61994. */
  61995. previous: Nullable<IInternalTextureTracker>;
  61996. /**
  61997. * Gets or set the next tracker in the list
  61998. */
  61999. next: Nullable<IInternalTextureTracker>;
  62000. }
  62001. /**
  62002. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62003. */
  62004. export class DummyInternalTextureTracker {
  62005. /**
  62006. * Gets or set the previous tracker in the list
  62007. */
  62008. previous: Nullable<IInternalTextureTracker>;
  62009. /**
  62010. * Gets or set the next tracker in the list
  62011. */
  62012. next: Nullable<IInternalTextureTracker>;
  62013. }
  62014. }
  62015. declare module BABYLON {
  62016. /**
  62017. * Class used to store data associated with WebGL texture data for the engine
  62018. * This class should not be used directly
  62019. */
  62020. export class InternalTexture implements IInternalTextureTracker {
  62021. /** hidden */
  62022. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62023. /**
  62024. * The source of the texture data is unknown
  62025. */
  62026. static DATASOURCE_UNKNOWN: number;
  62027. /**
  62028. * Texture data comes from an URL
  62029. */
  62030. static DATASOURCE_URL: number;
  62031. /**
  62032. * Texture data is only used for temporary storage
  62033. */
  62034. static DATASOURCE_TEMP: number;
  62035. /**
  62036. * Texture data comes from raw data (ArrayBuffer)
  62037. */
  62038. static DATASOURCE_RAW: number;
  62039. /**
  62040. * Texture content is dynamic (video or dynamic texture)
  62041. */
  62042. static DATASOURCE_DYNAMIC: number;
  62043. /**
  62044. * Texture content is generated by rendering to it
  62045. */
  62046. static DATASOURCE_RENDERTARGET: number;
  62047. /**
  62048. * Texture content is part of a multi render target process
  62049. */
  62050. static DATASOURCE_MULTIRENDERTARGET: number;
  62051. /**
  62052. * Texture data comes from a cube data file
  62053. */
  62054. static DATASOURCE_CUBE: number;
  62055. /**
  62056. * Texture data comes from a raw cube data
  62057. */
  62058. static DATASOURCE_CUBERAW: number;
  62059. /**
  62060. * Texture data come from a prefiltered cube data file
  62061. */
  62062. static DATASOURCE_CUBEPREFILTERED: number;
  62063. /**
  62064. * Texture content is raw 3D data
  62065. */
  62066. static DATASOURCE_RAW3D: number;
  62067. /**
  62068. * Texture content is a depth texture
  62069. */
  62070. static DATASOURCE_DEPTHTEXTURE: number;
  62071. /**
  62072. * Texture data comes from a raw cube data encoded with RGBD
  62073. */
  62074. static DATASOURCE_CUBERAW_RGBD: number;
  62075. /**
  62076. * Defines if the texture is ready
  62077. */
  62078. isReady: boolean;
  62079. /**
  62080. * Defines if the texture is a cube texture
  62081. */
  62082. isCube: boolean;
  62083. /**
  62084. * Defines if the texture contains 3D data
  62085. */
  62086. is3D: boolean;
  62087. /**
  62088. * Gets the URL used to load this texture
  62089. */
  62090. url: string;
  62091. /**
  62092. * Gets the sampling mode of the texture
  62093. */
  62094. samplingMode: number;
  62095. /**
  62096. * Gets a boolean indicating if the texture needs mipmaps generation
  62097. */
  62098. generateMipMaps: boolean;
  62099. /**
  62100. * Gets the number of samples used by the texture (WebGL2+ only)
  62101. */
  62102. samples: number;
  62103. /**
  62104. * Gets the type of the texture (int, float...)
  62105. */
  62106. type: number;
  62107. /**
  62108. * Gets the format of the texture (RGB, RGBA...)
  62109. */
  62110. format: number;
  62111. /**
  62112. * Observable called when the texture is loaded
  62113. */
  62114. onLoadedObservable: Observable<InternalTexture>;
  62115. /**
  62116. * Gets the width of the texture
  62117. */
  62118. width: number;
  62119. /**
  62120. * Gets the height of the texture
  62121. */
  62122. height: number;
  62123. /**
  62124. * Gets the depth of the texture
  62125. */
  62126. depth: number;
  62127. /**
  62128. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62129. */
  62130. baseWidth: number;
  62131. /**
  62132. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62133. */
  62134. baseHeight: number;
  62135. /**
  62136. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62137. */
  62138. baseDepth: number;
  62139. /**
  62140. * Gets a boolean indicating if the texture is inverted on Y axis
  62141. */
  62142. invertY: boolean;
  62143. /**
  62144. * Gets or set the previous tracker in the list
  62145. */
  62146. previous: Nullable<IInternalTextureTracker>;
  62147. /**
  62148. * Gets or set the next tracker in the list
  62149. */
  62150. next: Nullable<IInternalTextureTracker>;
  62151. /** @hidden */
  62152. _invertVScale: boolean;
  62153. /** @hidden */
  62154. _initialSlot: number;
  62155. /** @hidden */
  62156. _designatedSlot: number;
  62157. /** @hidden */
  62158. _dataSource: number;
  62159. /** @hidden */
  62160. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62161. /** @hidden */
  62162. _bufferView: Nullable<ArrayBufferView>;
  62163. /** @hidden */
  62164. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62165. /** @hidden */
  62166. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62167. /** @hidden */
  62168. _size: number;
  62169. /** @hidden */
  62170. _extension: string;
  62171. /** @hidden */
  62172. _files: Nullable<string[]>;
  62173. /** @hidden */
  62174. _workingCanvas: HTMLCanvasElement;
  62175. /** @hidden */
  62176. _workingContext: CanvasRenderingContext2D;
  62177. /** @hidden */
  62178. _framebuffer: Nullable<WebGLFramebuffer>;
  62179. /** @hidden */
  62180. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62181. /** @hidden */
  62182. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62183. /** @hidden */
  62184. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62185. /** @hidden */
  62186. _attachments: Nullable<number[]>;
  62187. /** @hidden */
  62188. _cachedCoordinatesMode: Nullable<number>;
  62189. /** @hidden */
  62190. _cachedWrapU: Nullable<number>;
  62191. /** @hidden */
  62192. _cachedWrapV: Nullable<number>;
  62193. /** @hidden */
  62194. _cachedWrapR: Nullable<number>;
  62195. /** @hidden */
  62196. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62197. /** @hidden */
  62198. _isDisabled: boolean;
  62199. /** @hidden */
  62200. _compression: Nullable<string>;
  62201. /** @hidden */
  62202. _generateStencilBuffer: boolean;
  62203. /** @hidden */
  62204. _generateDepthBuffer: boolean;
  62205. /** @hidden */
  62206. _comparisonFunction: number;
  62207. /** @hidden */
  62208. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62209. /** @hidden */
  62210. _lodGenerationScale: number;
  62211. /** @hidden */
  62212. _lodGenerationOffset: number;
  62213. /** @hidden */
  62214. _lodTextureHigh: BaseTexture;
  62215. /** @hidden */
  62216. _lodTextureMid: BaseTexture;
  62217. /** @hidden */
  62218. _lodTextureLow: BaseTexture;
  62219. /** @hidden */
  62220. _isRGBD: boolean;
  62221. /** @hidden */
  62222. _webGLTexture: Nullable<WebGLTexture>;
  62223. /** @hidden */
  62224. _references: number;
  62225. private _engine;
  62226. /**
  62227. * Gets the Engine the texture belongs to.
  62228. * @returns The babylon engine
  62229. */
  62230. getEngine(): Engine;
  62231. /**
  62232. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62233. */
  62234. readonly dataSource: number;
  62235. /**
  62236. * Creates a new InternalTexture
  62237. * @param engine defines the engine to use
  62238. * @param dataSource defines the type of data that will be used
  62239. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62240. */
  62241. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62242. /**
  62243. * Increments the number of references (ie. the number of Texture that point to it)
  62244. */
  62245. incrementReferences(): void;
  62246. /**
  62247. * Change the size of the texture (not the size of the content)
  62248. * @param width defines the new width
  62249. * @param height defines the new height
  62250. * @param depth defines the new depth (1 by default)
  62251. */
  62252. updateSize(width: int, height: int, depth?: int): void;
  62253. /** @hidden */
  62254. _rebuild(): void;
  62255. /** @hidden */
  62256. _swapAndDie(target: InternalTexture): void;
  62257. /**
  62258. * Dispose the current allocated resources
  62259. */
  62260. dispose(): void;
  62261. }
  62262. }
  62263. declare module BABYLON {
  62264. /**
  62265. * This represents the main contract an easing function should follow.
  62266. * Easing functions are used throughout the animation system.
  62267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62268. */
  62269. export interface IEasingFunction {
  62270. /**
  62271. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62272. * of the easing function.
  62273. * The link below provides some of the most common examples of easing functions.
  62274. * @see https://easings.net/
  62275. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62276. * @returns the corresponding value on the curve defined by the easing function
  62277. */
  62278. ease(gradient: number): number;
  62279. }
  62280. /**
  62281. * Base class used for every default easing function.
  62282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62283. */
  62284. export class EasingFunction implements IEasingFunction {
  62285. /**
  62286. * Interpolation follows the mathematical formula associated with the easing function.
  62287. */
  62288. static readonly EASINGMODE_EASEIN: number;
  62289. /**
  62290. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62291. */
  62292. static readonly EASINGMODE_EASEOUT: number;
  62293. /**
  62294. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62295. */
  62296. static readonly EASINGMODE_EASEINOUT: number;
  62297. private _easingMode;
  62298. /**
  62299. * Sets the easing mode of the current function.
  62300. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62301. */
  62302. setEasingMode(easingMode: number): void;
  62303. /**
  62304. * Gets the current easing mode.
  62305. * @returns the easing mode
  62306. */
  62307. getEasingMode(): number;
  62308. /**
  62309. * @hidden
  62310. */
  62311. easeInCore(gradient: number): number;
  62312. /**
  62313. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62314. * of the easing function.
  62315. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62316. * @returns the corresponding value on the curve defined by the easing function
  62317. */
  62318. ease(gradient: number): number;
  62319. }
  62320. /**
  62321. * Easing function with a circle shape (see link below).
  62322. * @see https://easings.net/#easeInCirc
  62323. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62324. */
  62325. export class CircleEase extends EasingFunction implements IEasingFunction {
  62326. /** @hidden */
  62327. easeInCore(gradient: number): number;
  62328. }
  62329. /**
  62330. * Easing function with a ease back shape (see link below).
  62331. * @see https://easings.net/#easeInBack
  62332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62333. */
  62334. export class BackEase extends EasingFunction implements IEasingFunction {
  62335. /** Defines the amplitude of the function */
  62336. amplitude: number;
  62337. /**
  62338. * Instantiates a back ease easing
  62339. * @see https://easings.net/#easeInBack
  62340. * @param amplitude Defines the amplitude of the function
  62341. */
  62342. constructor(
  62343. /** Defines the amplitude of the function */
  62344. amplitude?: number);
  62345. /** @hidden */
  62346. easeInCore(gradient: number): number;
  62347. }
  62348. /**
  62349. * Easing function with a bouncing shape (see link below).
  62350. * @see https://easings.net/#easeInBounce
  62351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62352. */
  62353. export class BounceEase extends EasingFunction implements IEasingFunction {
  62354. /** Defines the number of bounces */
  62355. bounces: number;
  62356. /** Defines the amplitude of the bounce */
  62357. bounciness: number;
  62358. /**
  62359. * Instantiates a bounce easing
  62360. * @see https://easings.net/#easeInBounce
  62361. * @param bounces Defines the number of bounces
  62362. * @param bounciness Defines the amplitude of the bounce
  62363. */
  62364. constructor(
  62365. /** Defines the number of bounces */
  62366. bounces?: number,
  62367. /** Defines the amplitude of the bounce */
  62368. bounciness?: number);
  62369. /** @hidden */
  62370. easeInCore(gradient: number): number;
  62371. }
  62372. /**
  62373. * Easing function with a power of 3 shape (see link below).
  62374. * @see https://easings.net/#easeInCubic
  62375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62376. */
  62377. export class CubicEase extends EasingFunction implements IEasingFunction {
  62378. /** @hidden */
  62379. easeInCore(gradient: number): number;
  62380. }
  62381. /**
  62382. * Easing function with an elastic shape (see link below).
  62383. * @see https://easings.net/#easeInElastic
  62384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62385. */
  62386. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62387. /** Defines the number of oscillations*/
  62388. oscillations: number;
  62389. /** Defines the amplitude of the oscillations*/
  62390. springiness: number;
  62391. /**
  62392. * Instantiates an elastic easing function
  62393. * @see https://easings.net/#easeInElastic
  62394. * @param oscillations Defines the number of oscillations
  62395. * @param springiness Defines the amplitude of the oscillations
  62396. */
  62397. constructor(
  62398. /** Defines the number of oscillations*/
  62399. oscillations?: number,
  62400. /** Defines the amplitude of the oscillations*/
  62401. springiness?: number);
  62402. /** @hidden */
  62403. easeInCore(gradient: number): number;
  62404. }
  62405. /**
  62406. * Easing function with an exponential shape (see link below).
  62407. * @see https://easings.net/#easeInExpo
  62408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62409. */
  62410. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62411. /** Defines the exponent of the function */
  62412. exponent: number;
  62413. /**
  62414. * Instantiates an exponential easing function
  62415. * @see https://easings.net/#easeInExpo
  62416. * @param exponent Defines the exponent of the function
  62417. */
  62418. constructor(
  62419. /** Defines the exponent of the function */
  62420. exponent?: number);
  62421. /** @hidden */
  62422. easeInCore(gradient: number): number;
  62423. }
  62424. /**
  62425. * Easing function with a power shape (see link below).
  62426. * @see https://easings.net/#easeInQuad
  62427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62428. */
  62429. export class PowerEase extends EasingFunction implements IEasingFunction {
  62430. /** Defines the power of the function */
  62431. power: number;
  62432. /**
  62433. * Instantiates an power base easing function
  62434. * @see https://easings.net/#easeInQuad
  62435. * @param power Defines the power of the function
  62436. */
  62437. constructor(
  62438. /** Defines the power of the function */
  62439. power?: number);
  62440. /** @hidden */
  62441. easeInCore(gradient: number): number;
  62442. }
  62443. /**
  62444. * Easing function with a power of 2 shape (see link below).
  62445. * @see https://easings.net/#easeInQuad
  62446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62447. */
  62448. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  62449. /** @hidden */
  62450. easeInCore(gradient: number): number;
  62451. }
  62452. /**
  62453. * Easing function with a power of 4 shape (see link below).
  62454. * @see https://easings.net/#easeInQuart
  62455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62456. */
  62457. export class QuarticEase extends EasingFunction implements IEasingFunction {
  62458. /** @hidden */
  62459. easeInCore(gradient: number): number;
  62460. }
  62461. /**
  62462. * Easing function with a power of 5 shape (see link below).
  62463. * @see https://easings.net/#easeInQuint
  62464. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62465. */
  62466. export class QuinticEase extends EasingFunction implements IEasingFunction {
  62467. /** @hidden */
  62468. easeInCore(gradient: number): number;
  62469. }
  62470. /**
  62471. * Easing function with a sin shape (see link below).
  62472. * @see https://easings.net/#easeInSine
  62473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62474. */
  62475. export class SineEase extends EasingFunction implements IEasingFunction {
  62476. /** @hidden */
  62477. easeInCore(gradient: number): number;
  62478. }
  62479. /**
  62480. * Easing function with a bezier shape (see link below).
  62481. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62483. */
  62484. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  62485. /** Defines the x component of the start tangent in the bezier curve */
  62486. x1: number;
  62487. /** Defines the y component of the start tangent in the bezier curve */
  62488. y1: number;
  62489. /** Defines the x component of the end tangent in the bezier curve */
  62490. x2: number;
  62491. /** Defines the y component of the end tangent in the bezier curve */
  62492. y2: number;
  62493. /**
  62494. * Instantiates a bezier function
  62495. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62496. * @param x1 Defines the x component of the start tangent in the bezier curve
  62497. * @param y1 Defines the y component of the start tangent in the bezier curve
  62498. * @param x2 Defines the x component of the end tangent in the bezier curve
  62499. * @param y2 Defines the y component of the end tangent in the bezier curve
  62500. */
  62501. constructor(
  62502. /** Defines the x component of the start tangent in the bezier curve */
  62503. x1?: number,
  62504. /** Defines the y component of the start tangent in the bezier curve */
  62505. y1?: number,
  62506. /** Defines the x component of the end tangent in the bezier curve */
  62507. x2?: number,
  62508. /** Defines the y component of the end tangent in the bezier curve */
  62509. y2?: number);
  62510. /** @hidden */
  62511. easeInCore(gradient: number): number;
  62512. }
  62513. }
  62514. declare module BABYLON {
  62515. /**
  62516. * Interface used to define a behavior
  62517. */
  62518. export interface Behavior<T> {
  62519. /** gets or sets behavior's name */
  62520. name: string;
  62521. /**
  62522. * Function called when the behavior needs to be initialized (after attaching it to a target)
  62523. */
  62524. init(): void;
  62525. /**
  62526. * Called when the behavior is attached to a target
  62527. * @param target defines the target where the behavior is attached to
  62528. */
  62529. attach(target: T): void;
  62530. /**
  62531. * Called when the behavior is detached from its target
  62532. */
  62533. detach(): void;
  62534. }
  62535. /**
  62536. * Interface implemented by classes supporting behaviors
  62537. */
  62538. export interface IBehaviorAware<T> {
  62539. /**
  62540. * Attach a behavior
  62541. * @param behavior defines the behavior to attach
  62542. * @returns the current host
  62543. */
  62544. addBehavior(behavior: Behavior<T>): T;
  62545. /**
  62546. * Remove a behavior from the current object
  62547. * @param behavior defines the behavior to detach
  62548. * @returns the current host
  62549. */
  62550. removeBehavior(behavior: Behavior<T>): T;
  62551. /**
  62552. * Gets a behavior using its name to search
  62553. * @param name defines the name to search
  62554. * @returns the behavior or null if not found
  62555. */
  62556. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  62557. }
  62558. }
  62559. declare module BABYLON {
  62560. /**
  62561. * Defines a runtime animation
  62562. */
  62563. export class RuntimeAnimation {
  62564. private _events;
  62565. /**
  62566. * The current frame of the runtime animation
  62567. */
  62568. private _currentFrame;
  62569. /**
  62570. * The animation used by the runtime animation
  62571. */
  62572. private _animation;
  62573. /**
  62574. * The target of the runtime animation
  62575. */
  62576. private _target;
  62577. /**
  62578. * The initiating animatable
  62579. */
  62580. private _host;
  62581. /**
  62582. * The original value of the runtime animation
  62583. */
  62584. private _originalValue;
  62585. /**
  62586. * The original blend value of the runtime animation
  62587. */
  62588. private _originalBlendValue;
  62589. /**
  62590. * The offsets cache of the runtime animation
  62591. */
  62592. private _offsetsCache;
  62593. /**
  62594. * The high limits cache of the runtime animation
  62595. */
  62596. private _highLimitsCache;
  62597. /**
  62598. * Specifies if the runtime animation has been stopped
  62599. */
  62600. private _stopped;
  62601. /**
  62602. * The blending factor of the runtime animation
  62603. */
  62604. private _blendingFactor;
  62605. /**
  62606. * The BabylonJS scene
  62607. */
  62608. private _scene;
  62609. /**
  62610. * The current value of the runtime animation
  62611. */
  62612. private _currentValue;
  62613. /** @hidden */
  62614. _workValue: any;
  62615. /**
  62616. * The active target of the runtime animation
  62617. */
  62618. private _activeTarget;
  62619. /**
  62620. * The target path of the runtime animation
  62621. */
  62622. private _targetPath;
  62623. /**
  62624. * The weight of the runtime animation
  62625. */
  62626. private _weight;
  62627. /**
  62628. * The ratio offset of the runtime animation
  62629. */
  62630. private _ratioOffset;
  62631. /**
  62632. * The previous delay of the runtime animation
  62633. */
  62634. private _previousDelay;
  62635. /**
  62636. * The previous ratio of the runtime animation
  62637. */
  62638. private _previousRatio;
  62639. /**
  62640. * Gets the current frame of the runtime animation
  62641. */
  62642. readonly currentFrame: number;
  62643. /**
  62644. * Gets the weight of the runtime animation
  62645. */
  62646. readonly weight: number;
  62647. /**
  62648. * Gets the current value of the runtime animation
  62649. */
  62650. readonly currentValue: any;
  62651. /**
  62652. * Gets the target path of the runtime animation
  62653. */
  62654. readonly targetPath: string;
  62655. /**
  62656. * Gets the actual target of the runtime animation
  62657. */
  62658. readonly target: any;
  62659. /**
  62660. * Create a new RuntimeAnimation object
  62661. * @param target defines the target of the animation
  62662. * @param animation defines the source animation object
  62663. * @param scene defines the hosting scene
  62664. * @param host defines the initiating Animatable
  62665. */
  62666. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  62667. /**
  62668. * Gets the animation from the runtime animation
  62669. */
  62670. readonly animation: Animation;
  62671. /**
  62672. * Resets the runtime animation to the beginning
  62673. * @param restoreOriginal defines whether to restore the target property to the original value
  62674. */
  62675. reset(restoreOriginal?: boolean): void;
  62676. /**
  62677. * Specifies if the runtime animation is stopped
  62678. * @returns Boolean specifying if the runtime animation is stopped
  62679. */
  62680. isStopped(): boolean;
  62681. /**
  62682. * Disposes of the runtime animation
  62683. */
  62684. dispose(): void;
  62685. /**
  62686. * Interpolates the animation from the current frame
  62687. * @param currentFrame The frame to interpolate the animation to
  62688. * @param repeatCount The number of times that the animation should loop
  62689. * @param loopMode The type of looping mode to use
  62690. * @param offsetValue Animation offset value
  62691. * @param highLimitValue The high limit value
  62692. * @returns The interpolated value
  62693. */
  62694. private _interpolate;
  62695. /**
  62696. * Apply the interpolated value to the target
  62697. * @param currentValue defines the value computed by the animation
  62698. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  62699. */
  62700. setValue(currentValue: any, weight?: number): void;
  62701. private _setValue;
  62702. /**
  62703. * Gets the loop pmode of the runtime animation
  62704. * @returns Loop Mode
  62705. */
  62706. private _getCorrectLoopMode;
  62707. /**
  62708. * Move the current animation to a given frame
  62709. * @param frame defines the frame to move to
  62710. */
  62711. goToFrame(frame: number): void;
  62712. /**
  62713. * @hidden Internal use only
  62714. */
  62715. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  62716. /**
  62717. * Execute the current animation
  62718. * @param delay defines the delay to add to the current frame
  62719. * @param from defines the lower bound of the animation range
  62720. * @param to defines the upper bound of the animation range
  62721. * @param loop defines if the current animation must loop
  62722. * @param speedRatio defines the current speed ratio
  62723. * @param weight defines the weight of the animation (default is -1 so no weight)
  62724. * @param onLoop optional callback called when animation loops
  62725. * @returns a boolean indicating if the animation is running
  62726. */
  62727. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Class used to store an actual running animation
  62733. */
  62734. export class Animatable {
  62735. /** defines the target object */
  62736. target: any;
  62737. /** defines the starting frame number (default is 0) */
  62738. fromFrame: number;
  62739. /** defines the ending frame number (default is 100) */
  62740. toFrame: number;
  62741. /** defines if the animation must loop (default is false) */
  62742. loopAnimation: boolean;
  62743. /** defines a callback to call when animation ends if it is not looping */
  62744. onAnimationEnd?: (() => void) | null | undefined;
  62745. /** defines a callback to call when animation loops */
  62746. onAnimationLoop?: (() => void) | null | undefined;
  62747. private _localDelayOffset;
  62748. private _pausedDelay;
  62749. private _runtimeAnimations;
  62750. private _paused;
  62751. private _scene;
  62752. private _speedRatio;
  62753. private _weight;
  62754. private _syncRoot;
  62755. /**
  62756. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  62757. * This will only apply for non looping animation (default is true)
  62758. */
  62759. disposeOnEnd: boolean;
  62760. /**
  62761. * Gets a boolean indicating if the animation has started
  62762. */
  62763. animationStarted: boolean;
  62764. /**
  62765. * Observer raised when the animation ends
  62766. */
  62767. onAnimationEndObservable: Observable<Animatable>;
  62768. /**
  62769. * Observer raised when the animation loops
  62770. */
  62771. onAnimationLoopObservable: Observable<Animatable>;
  62772. /**
  62773. * Gets the root Animatable used to synchronize and normalize animations
  62774. */
  62775. readonly syncRoot: Animatable;
  62776. /**
  62777. * Gets the current frame of the first RuntimeAnimation
  62778. * Used to synchronize Animatables
  62779. */
  62780. readonly masterFrame: number;
  62781. /**
  62782. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  62783. */
  62784. weight: number;
  62785. /**
  62786. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  62787. */
  62788. speedRatio: number;
  62789. /**
  62790. * Creates a new Animatable
  62791. * @param scene defines the hosting scene
  62792. * @param target defines the target object
  62793. * @param fromFrame defines the starting frame number (default is 0)
  62794. * @param toFrame defines the ending frame number (default is 100)
  62795. * @param loopAnimation defines if the animation must loop (default is false)
  62796. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  62797. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  62798. * @param animations defines a group of animation to add to the new Animatable
  62799. * @param onAnimationLoop defines a callback to call when animation loops
  62800. */
  62801. constructor(scene: Scene,
  62802. /** defines the target object */
  62803. target: any,
  62804. /** defines the starting frame number (default is 0) */
  62805. fromFrame?: number,
  62806. /** defines the ending frame number (default is 100) */
  62807. toFrame?: number,
  62808. /** defines if the animation must loop (default is false) */
  62809. loopAnimation?: boolean, speedRatio?: number,
  62810. /** defines a callback to call when animation ends if it is not looping */
  62811. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  62812. /** defines a callback to call when animation loops */
  62813. onAnimationLoop?: (() => void) | null | undefined);
  62814. /**
  62815. * Synchronize and normalize current Animatable with a source Animatable
  62816. * This is useful when using animation weights and when animations are not of the same length
  62817. * @param root defines the root Animatable to synchronize with
  62818. * @returns the current Animatable
  62819. */
  62820. syncWith(root: Animatable): Animatable;
  62821. /**
  62822. * Gets the list of runtime animations
  62823. * @returns an array of RuntimeAnimation
  62824. */
  62825. getAnimations(): RuntimeAnimation[];
  62826. /**
  62827. * Adds more animations to the current animatable
  62828. * @param target defines the target of the animations
  62829. * @param animations defines the new animations to add
  62830. */
  62831. appendAnimations(target: any, animations: Animation[]): void;
  62832. /**
  62833. * Gets the source animation for a specific property
  62834. * @param property defines the propertyu to look for
  62835. * @returns null or the source animation for the given property
  62836. */
  62837. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  62838. /**
  62839. * Gets the runtime animation for a specific property
  62840. * @param property defines the propertyu to look for
  62841. * @returns null or the runtime animation for the given property
  62842. */
  62843. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  62844. /**
  62845. * Resets the animatable to its original state
  62846. */
  62847. reset(): void;
  62848. /**
  62849. * Allows the animatable to blend with current running animations
  62850. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  62851. * @param blendingSpeed defines the blending speed to use
  62852. */
  62853. enableBlending(blendingSpeed: number): void;
  62854. /**
  62855. * Disable animation blending
  62856. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  62857. */
  62858. disableBlending(): void;
  62859. /**
  62860. * Jump directly to a given frame
  62861. * @param frame defines the frame to jump to
  62862. */
  62863. goToFrame(frame: number): void;
  62864. /**
  62865. * Pause the animation
  62866. */
  62867. pause(): void;
  62868. /**
  62869. * Restart the animation
  62870. */
  62871. restart(): void;
  62872. private _raiseOnAnimationEnd;
  62873. /**
  62874. * Stop and delete the current animation
  62875. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  62876. * @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)
  62877. */
  62878. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  62879. /**
  62880. * Wait asynchronously for the animation to end
  62881. * @returns a promise which will be fullfilled when the animation ends
  62882. */
  62883. waitAsync(): Promise<Animatable>;
  62884. /** @hidden */
  62885. _animate(delay: number): boolean;
  62886. }
  62887. }
  62888. declare module BABYLON {
  62889. /**
  62890. * Class used to override all child animations of a given target
  62891. */
  62892. export class AnimationPropertiesOverride {
  62893. /**
  62894. * Gets or sets a value indicating if animation blending must be used
  62895. */
  62896. enableBlending: boolean;
  62897. /**
  62898. * Gets or sets the blending speed to use when enableBlending is true
  62899. */
  62900. blendingSpeed: number;
  62901. /**
  62902. * Gets or sets the default loop mode to use
  62903. */
  62904. loopMode: number;
  62905. }
  62906. }
  62907. declare module BABYLON {
  62908. /** @hidden */
  62909. export class Collider {
  62910. /** Define if a collision was found */
  62911. collisionFound: boolean;
  62912. /**
  62913. * Define last intersection point in local space
  62914. */
  62915. intersectionPoint: Vector3;
  62916. /**
  62917. * Define last collided mesh
  62918. */
  62919. collidedMesh: Nullable<AbstractMesh>;
  62920. private _collisionPoint;
  62921. private _planeIntersectionPoint;
  62922. private _tempVector;
  62923. private _tempVector2;
  62924. private _tempVector3;
  62925. private _tempVector4;
  62926. private _edge;
  62927. private _baseToVertex;
  62928. private _destinationPoint;
  62929. private _slidePlaneNormal;
  62930. private _displacementVector;
  62931. /** @hidden */
  62932. _radius: Vector3;
  62933. /** @hidden */
  62934. _retry: number;
  62935. private _velocity;
  62936. private _basePoint;
  62937. private _epsilon;
  62938. /** @hidden */
  62939. _velocityWorldLength: number;
  62940. /** @hidden */
  62941. _basePointWorld: Vector3;
  62942. private _velocityWorld;
  62943. private _normalizedVelocity;
  62944. /** @hidden */
  62945. _initialVelocity: Vector3;
  62946. /** @hidden */
  62947. _initialPosition: Vector3;
  62948. private _nearestDistance;
  62949. private _collisionMask;
  62950. collisionMask: number;
  62951. /**
  62952. * Gets the plane normal used to compute the sliding response (in local space)
  62953. */
  62954. readonly slidePlaneNormal: Vector3;
  62955. /** @hidden */
  62956. _initialize(source: Vector3, dir: Vector3, e: number): void;
  62957. /** @hidden */
  62958. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  62959. /** @hidden */
  62960. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  62961. /** @hidden */
  62962. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  62963. /** @hidden */
  62964. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  62965. /** @hidden */
  62966. _getResponse(pos: Vector3, vel: Vector3): void;
  62967. }
  62968. }
  62969. declare module BABYLON {
  62970. /**
  62971. * @hidden
  62972. */
  62973. export class IntersectionInfo {
  62974. bu: Nullable<number>;
  62975. bv: Nullable<number>;
  62976. distance: number;
  62977. faceId: number;
  62978. subMeshId: number;
  62979. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * ActionEvent is the event being sent when an action is triggered.
  62985. */
  62986. export class ActionEvent {
  62987. /** The mesh or sprite that triggered the action */
  62988. source: any;
  62989. /** The X mouse cursor position at the time of the event */
  62990. pointerX: number;
  62991. /** The Y mouse cursor position at the time of the event */
  62992. pointerY: number;
  62993. /** The mesh that is currently pointed at (can be null) */
  62994. meshUnderPointer: Nullable<AbstractMesh>;
  62995. /** the original (browser) event that triggered the ActionEvent */
  62996. sourceEvent?: any;
  62997. /** additional data for the event */
  62998. additionalData?: any;
  62999. /**
  63000. * Creates a new ActionEvent
  63001. * @param source The mesh or sprite that triggered the action
  63002. * @param pointerX The X mouse cursor position at the time of the event
  63003. * @param pointerY The Y mouse cursor position at the time of the event
  63004. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  63005. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  63006. * @param additionalData additional data for the event
  63007. */
  63008. constructor(
  63009. /** The mesh or sprite that triggered the action */
  63010. source: any,
  63011. /** The X mouse cursor position at the time of the event */
  63012. pointerX: number,
  63013. /** The Y mouse cursor position at the time of the event */
  63014. pointerY: number,
  63015. /** The mesh that is currently pointed at (can be null) */
  63016. meshUnderPointer: Nullable<AbstractMesh>,
  63017. /** the original (browser) event that triggered the ActionEvent */
  63018. sourceEvent?: any,
  63019. /** additional data for the event */
  63020. additionalData?: any);
  63021. /**
  63022. * Helper function to auto-create an ActionEvent from a source mesh.
  63023. * @param source The source mesh that triggered the event
  63024. * @param evt The original (browser) event
  63025. * @param additionalData additional data for the event
  63026. * @returns the new ActionEvent
  63027. */
  63028. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  63029. /**
  63030. * Helper function to auto-create an ActionEvent from a source sprite
  63031. * @param source The source sprite that triggered the event
  63032. * @param scene Scene associated with the sprite
  63033. * @param evt The original (browser) event
  63034. * @param additionalData additional data for the event
  63035. * @returns the new ActionEvent
  63036. */
  63037. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  63038. /**
  63039. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  63040. * @param scene the scene where the event occurred
  63041. * @param evt The original (browser) event
  63042. * @returns the new ActionEvent
  63043. */
  63044. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  63045. /**
  63046. * Helper function to auto-create an ActionEvent from a primitive
  63047. * @param prim defines the target primitive
  63048. * @param pointerPos defines the pointer position
  63049. * @param evt The original (browser) event
  63050. * @param additionalData additional data for the event
  63051. * @returns the new ActionEvent
  63052. */
  63053. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  63054. }
  63055. }
  63056. declare module BABYLON {
  63057. /**
  63058. * Class used to store bounding sphere information
  63059. */
  63060. export class BoundingSphere {
  63061. /**
  63062. * Gets the center of the bounding sphere in local space
  63063. */
  63064. readonly center: Vector3;
  63065. /**
  63066. * Radius of the bounding sphere in local space
  63067. */
  63068. radius: number;
  63069. /**
  63070. * Gets the center of the bounding sphere in world space
  63071. */
  63072. readonly centerWorld: Vector3;
  63073. /**
  63074. * Radius of the bounding sphere in world space
  63075. */
  63076. radiusWorld: number;
  63077. /**
  63078. * Gets the minimum vector in local space
  63079. */
  63080. readonly minimum: Vector3;
  63081. /**
  63082. * Gets the maximum vector in local space
  63083. */
  63084. readonly maximum: Vector3;
  63085. private _worldMatrix;
  63086. private static readonly TmpVector3;
  63087. /**
  63088. * Creates a new bounding sphere
  63089. * @param min defines the minimum vector (in local space)
  63090. * @param max defines the maximum vector (in local space)
  63091. * @param worldMatrix defines the new world matrix
  63092. */
  63093. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63094. /**
  63095. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63096. * @param min defines the new minimum vector (in local space)
  63097. * @param max defines the new maximum vector (in local space)
  63098. * @param worldMatrix defines the new world matrix
  63099. */
  63100. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63101. /**
  63102. * Scale the current bounding sphere by applying a scale factor
  63103. * @param factor defines the scale factor to apply
  63104. * @returns the current bounding box
  63105. */
  63106. scale(factor: number): BoundingSphere;
  63107. /**
  63108. * Gets the world matrix of the bounding box
  63109. * @returns a matrix
  63110. */
  63111. getWorldMatrix(): DeepImmutable<Matrix>;
  63112. /** @hidden */
  63113. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63114. /**
  63115. * Tests if the bounding sphere is intersecting the frustum planes
  63116. * @param frustumPlanes defines the frustum planes to test
  63117. * @returns true if there is an intersection
  63118. */
  63119. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63120. /**
  63121. * Tests if the bounding sphere center is in between the frustum planes.
  63122. * Used for optimistic fast inclusion.
  63123. * @param frustumPlanes defines the frustum planes to test
  63124. * @returns true if the sphere center is in between the frustum planes
  63125. */
  63126. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63127. /**
  63128. * Tests if a point is inside the bounding sphere
  63129. * @param point defines the point to test
  63130. * @returns true if the point is inside the bounding sphere
  63131. */
  63132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63133. /**
  63134. * Checks if two sphere intersct
  63135. * @param sphere0 sphere 0
  63136. * @param sphere1 sphere 1
  63137. * @returns true if the speres intersect
  63138. */
  63139. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63140. }
  63141. }
  63142. declare module BABYLON {
  63143. /**
  63144. * Class used to store bounding box information
  63145. */
  63146. export class BoundingBox implements ICullable {
  63147. /**
  63148. * Gets the 8 vectors representing the bounding box in local space
  63149. */
  63150. readonly vectors: Vector3[];
  63151. /**
  63152. * Gets the center of the bounding box in local space
  63153. */
  63154. readonly center: Vector3;
  63155. /**
  63156. * Gets the center of the bounding box in world space
  63157. */
  63158. readonly centerWorld: Vector3;
  63159. /**
  63160. * Gets the extend size in local space
  63161. */
  63162. readonly extendSize: Vector3;
  63163. /**
  63164. * Gets the extend size in world space
  63165. */
  63166. readonly extendSizeWorld: Vector3;
  63167. /**
  63168. * Gets the OBB (object bounding box) directions
  63169. */
  63170. readonly directions: Vector3[];
  63171. /**
  63172. * Gets the 8 vectors representing the bounding box in world space
  63173. */
  63174. readonly vectorsWorld: Vector3[];
  63175. /**
  63176. * Gets the minimum vector in world space
  63177. */
  63178. readonly minimumWorld: Vector3;
  63179. /**
  63180. * Gets the maximum vector in world space
  63181. */
  63182. readonly maximumWorld: Vector3;
  63183. /**
  63184. * Gets the minimum vector in local space
  63185. */
  63186. readonly minimum: Vector3;
  63187. /**
  63188. * Gets the maximum vector in local space
  63189. */
  63190. readonly maximum: Vector3;
  63191. private _worldMatrix;
  63192. private static readonly TmpVector3;
  63193. /**
  63194. * @hidden
  63195. */
  63196. _tag: number;
  63197. /**
  63198. * Creates a new bounding box
  63199. * @param min defines the minimum vector (in local space)
  63200. * @param max defines the maximum vector (in local space)
  63201. * @param worldMatrix defines the new world matrix
  63202. */
  63203. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63204. /**
  63205. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63206. * @param min defines the new minimum vector (in local space)
  63207. * @param max defines the new maximum vector (in local space)
  63208. * @param worldMatrix defines the new world matrix
  63209. */
  63210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63211. /**
  63212. * Scale the current bounding box by applying a scale factor
  63213. * @param factor defines the scale factor to apply
  63214. * @returns the current bounding box
  63215. */
  63216. scale(factor: number): BoundingBox;
  63217. /**
  63218. * Gets the world matrix of the bounding box
  63219. * @returns a matrix
  63220. */
  63221. getWorldMatrix(): DeepImmutable<Matrix>;
  63222. /** @hidden */
  63223. _update(world: DeepImmutable<Matrix>): void;
  63224. /**
  63225. * Tests if the bounding box is intersecting the frustum planes
  63226. * @param frustumPlanes defines the frustum planes to test
  63227. * @returns true if there is an intersection
  63228. */
  63229. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63230. /**
  63231. * Tests if the bounding box is entirely inside the frustum planes
  63232. * @param frustumPlanes defines the frustum planes to test
  63233. * @returns true if there is an inclusion
  63234. */
  63235. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63236. /**
  63237. * Tests if a point is inside the bounding box
  63238. * @param point defines the point to test
  63239. * @returns true if the point is inside the bounding box
  63240. */
  63241. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63242. /**
  63243. * Tests if the bounding box intersects with a bounding sphere
  63244. * @param sphere defines the sphere to test
  63245. * @returns true if there is an intersection
  63246. */
  63247. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63248. /**
  63249. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63250. * @param min defines the min vector to use
  63251. * @param max defines the max vector to use
  63252. * @returns true if there is an intersection
  63253. */
  63254. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63255. /**
  63256. * Tests if two bounding boxes are intersections
  63257. * @param box0 defines the first box to test
  63258. * @param box1 defines the second box to test
  63259. * @returns true if there is an intersection
  63260. */
  63261. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63262. /**
  63263. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63264. * @param minPoint defines the minimum vector of the bounding box
  63265. * @param maxPoint defines the maximum vector of the bounding box
  63266. * @param sphereCenter defines the sphere center
  63267. * @param sphereRadius defines the sphere radius
  63268. * @returns true if there is an intersection
  63269. */
  63270. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63271. /**
  63272. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63273. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63274. * @param frustumPlanes defines the frustum planes to test
  63275. * @return true if there is an inclusion
  63276. */
  63277. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63278. /**
  63279. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63280. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63281. * @param frustumPlanes defines the frustum planes to test
  63282. * @return true if there is an intersection
  63283. */
  63284. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63285. }
  63286. }
  63287. declare module BABYLON {
  63288. /**
  63289. * Interface for cullable objects
  63290. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63291. */
  63292. export interface ICullable {
  63293. /**
  63294. * Checks if the object or part of the object is in the frustum
  63295. * @param frustumPlanes Camera near/planes
  63296. * @returns true if the object is in frustum otherwise false
  63297. */
  63298. isInFrustum(frustumPlanes: Plane[]): boolean;
  63299. /**
  63300. * Checks if a cullable object (mesh...) is in the camera frustum
  63301. * Unlike isInFrustum this cheks the full bounding box
  63302. * @param frustumPlanes Camera near/planes
  63303. * @returns true if the object is in frustum otherwise false
  63304. */
  63305. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63306. }
  63307. /**
  63308. * Info for a bounding data of a mesh
  63309. */
  63310. export class BoundingInfo implements ICullable {
  63311. /**
  63312. * Bounding box for the mesh
  63313. */
  63314. readonly boundingBox: BoundingBox;
  63315. /**
  63316. * Bounding sphere for the mesh
  63317. */
  63318. readonly boundingSphere: BoundingSphere;
  63319. private _isLocked;
  63320. private static readonly TmpVector3;
  63321. /**
  63322. * Constructs bounding info
  63323. * @param minimum min vector of the bounding box/sphere
  63324. * @param maximum max vector of the bounding box/sphere
  63325. * @param worldMatrix defines the new world matrix
  63326. */
  63327. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63328. /**
  63329. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63330. * @param min defines the new minimum vector (in local space)
  63331. * @param max defines the new maximum vector (in local space)
  63332. * @param worldMatrix defines the new world matrix
  63333. */
  63334. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63335. /**
  63336. * min vector of the bounding box/sphere
  63337. */
  63338. readonly minimum: Vector3;
  63339. /**
  63340. * max vector of the bounding box/sphere
  63341. */
  63342. readonly maximum: Vector3;
  63343. /**
  63344. * If the info is locked and won't be updated to avoid perf overhead
  63345. */
  63346. isLocked: boolean;
  63347. /**
  63348. * Updates the bounding sphere and box
  63349. * @param world world matrix to be used to update
  63350. */
  63351. update(world: DeepImmutable<Matrix>): void;
  63352. /**
  63353. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63354. * @param center New center of the bounding info
  63355. * @param extend New extend of the bounding info
  63356. * @returns the current bounding info
  63357. */
  63358. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63359. /**
  63360. * Scale the current bounding info by applying a scale factor
  63361. * @param factor defines the scale factor to apply
  63362. * @returns the current bounding info
  63363. */
  63364. scale(factor: number): BoundingInfo;
  63365. /**
  63366. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63367. * @param frustumPlanes defines the frustum to test
  63368. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63369. * @returns true if the bounding info is in the frustum planes
  63370. */
  63371. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63372. /**
  63373. * Gets the world distance between the min and max points of the bounding box
  63374. */
  63375. readonly diagonalLength: number;
  63376. /**
  63377. * Checks if a cullable object (mesh...) is in the camera frustum
  63378. * Unlike isInFrustum this cheks the full bounding box
  63379. * @param frustumPlanes Camera near/planes
  63380. * @returns true if the object is in frustum otherwise false
  63381. */
  63382. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63383. /** @hidden */
  63384. _checkCollision(collider: Collider): boolean;
  63385. /**
  63386. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63387. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63388. * @param point the point to check intersection with
  63389. * @returns if the point intersects
  63390. */
  63391. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63392. /**
  63393. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63394. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63395. * @param boundingInfo the bounding info to check intersection with
  63396. * @param precise if the intersection should be done using OBB
  63397. * @returns if the bounding info intersects
  63398. */
  63399. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63400. }
  63401. }
  63402. declare module BABYLON {
  63403. /**
  63404. * Defines an array and its length.
  63405. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63406. */
  63407. export interface ISmartArrayLike<T> {
  63408. /**
  63409. * The data of the array.
  63410. */
  63411. data: Array<T>;
  63412. /**
  63413. * The active length of the array.
  63414. */
  63415. length: number;
  63416. }
  63417. /**
  63418. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63419. */
  63420. export class SmartArray<T> implements ISmartArrayLike<T> {
  63421. /**
  63422. * The full set of data from the array.
  63423. */
  63424. data: Array<T>;
  63425. /**
  63426. * The active length of the array.
  63427. */
  63428. length: number;
  63429. protected _id: number;
  63430. /**
  63431. * Instantiates a Smart Array.
  63432. * @param capacity defines the default capacity of the array.
  63433. */
  63434. constructor(capacity: number);
  63435. /**
  63436. * Pushes a value at the end of the active data.
  63437. * @param value defines the object to push in the array.
  63438. */
  63439. push(value: T): void;
  63440. /**
  63441. * Iterates over the active data and apply the lambda to them.
  63442. * @param func defines the action to apply on each value.
  63443. */
  63444. forEach(func: (content: T) => void): void;
  63445. /**
  63446. * Sorts the full sets of data.
  63447. * @param compareFn defines the comparison function to apply.
  63448. */
  63449. sort(compareFn: (a: T, b: T) => number): void;
  63450. /**
  63451. * Resets the active data to an empty array.
  63452. */
  63453. reset(): void;
  63454. /**
  63455. * Releases all the data from the array as well as the array.
  63456. */
  63457. dispose(): void;
  63458. /**
  63459. * Concats the active data with a given array.
  63460. * @param array defines the data to concatenate with.
  63461. */
  63462. concat(array: any): void;
  63463. /**
  63464. * Returns the position of a value in the active data.
  63465. * @param value defines the value to find the index for
  63466. * @returns the index if found in the active data otherwise -1
  63467. */
  63468. indexOf(value: T): number;
  63469. /**
  63470. * Returns whether an element is part of the active data.
  63471. * @param value defines the value to look for
  63472. * @returns true if found in the active data otherwise false
  63473. */
  63474. contains(value: T): boolean;
  63475. private static _GlobalId;
  63476. }
  63477. /**
  63478. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63479. * The data in this array can only be present once
  63480. */
  63481. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63482. private _duplicateId;
  63483. /**
  63484. * Pushes a value at the end of the active data.
  63485. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63486. * @param value defines the object to push in the array.
  63487. */
  63488. push(value: T): void;
  63489. /**
  63490. * Pushes a value at the end of the active data.
  63491. * If the data is already present, it won t be added again
  63492. * @param value defines the object to push in the array.
  63493. * @returns true if added false if it was already present
  63494. */
  63495. pushNoDuplicate(value: T): boolean;
  63496. /**
  63497. * Resets the active data to an empty array.
  63498. */
  63499. reset(): void;
  63500. /**
  63501. * Concats the active data with a given array.
  63502. * This ensures no dupplicate will be present in the result.
  63503. * @param array defines the data to concatenate with.
  63504. */
  63505. concatWithNoDuplicate(array: any): void;
  63506. }
  63507. }
  63508. declare module BABYLON {
  63509. /**
  63510. * Class for creating a cube texture
  63511. */
  63512. export class CubeTexture extends BaseTexture {
  63513. private _delayedOnLoad;
  63514. /**
  63515. * The url of the texture
  63516. */
  63517. url: string;
  63518. /**
  63519. * Gets or sets the center of the bounding box associated with the cube texture.
  63520. * It must define where the camera used to render the texture was set
  63521. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  63522. */
  63523. boundingBoxPosition: Vector3;
  63524. private _boundingBoxSize;
  63525. /**
  63526. * Gets or sets the size of the bounding box associated with the cube texture
  63527. * When defined, the cubemap will switch to local mode
  63528. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63529. * @example https://www.babylonjs-playground.com/#RNASML
  63530. */
  63531. /**
  63532. * Returns the bounding box size
  63533. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  63534. */
  63535. boundingBoxSize: Vector3;
  63536. protected _rotationY: number;
  63537. /**
  63538. * Sets texture matrix rotation angle around Y axis in radians.
  63539. */
  63540. /**
  63541. * Gets texture matrix rotation angle around Y axis radians.
  63542. */
  63543. rotationY: number;
  63544. /**
  63545. * Are mip maps generated for this texture or not.
  63546. */
  63547. readonly noMipmap: boolean;
  63548. private _noMipmap;
  63549. private _files;
  63550. private _extensions;
  63551. private _textureMatrix;
  63552. private _format;
  63553. private _createPolynomials;
  63554. /** @hidden */
  63555. _prefiltered: boolean;
  63556. /**
  63557. * Creates a cube texture from an array of image urls
  63558. * @param files defines an array of image urls
  63559. * @param scene defines the hosting scene
  63560. * @param noMipmap specifies if mip maps are not used
  63561. * @returns a cube texture
  63562. */
  63563. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  63564. /**
  63565. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  63566. * @param url defines the url of the prefiltered texture
  63567. * @param scene defines the scene the texture is attached to
  63568. * @param forcedExtension defines the extension of the file if different from the url
  63569. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  63570. * @return the prefiltered texture
  63571. */
  63572. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  63573. /**
  63574. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  63575. * as prefiltered data.
  63576. * @param rootUrl defines the url of the texture or the root name of the six images
  63577. * @param scene defines the scene the texture is attached to
  63578. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  63579. * @param noMipmap defines if mipmaps should be created or not
  63580. * @param files defines the six files to load for the different faces
  63581. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  63582. * @param onError defines a callback triggered in case of error during load
  63583. * @param format defines the internal format to use for the texture once loaded
  63584. * @param prefiltered defines whether or not the texture is created from prefiltered data
  63585. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  63586. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  63587. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63588. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63589. * @return the cube texture
  63590. */
  63591. 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);
  63592. /**
  63593. * Get the current class name of the texture useful for serialization or dynamic coding.
  63594. * @returns "CubeTexture"
  63595. */
  63596. getClassName(): string;
  63597. /**
  63598. * Update the url (and optional buffer) of this texture if url was null during construction.
  63599. * @param url the url of the texture
  63600. * @param forcedExtension defines the extension to use
  63601. * @param onLoad callback called when the texture is loaded (defaults to null)
  63602. */
  63603. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  63604. /**
  63605. * Delays loading of the cube texture
  63606. * @param forcedExtension defines the extension to use
  63607. */
  63608. delayLoad(forcedExtension?: string): void;
  63609. /**
  63610. * Returns the reflection texture matrix
  63611. * @returns the reflection texture matrix
  63612. */
  63613. getReflectionTextureMatrix(): Matrix;
  63614. /**
  63615. * Sets the reflection texture matrix
  63616. * @param value Reflection texture matrix
  63617. */
  63618. setReflectionTextureMatrix(value: Matrix): void;
  63619. /**
  63620. * Parses text to create a cube texture
  63621. * @param parsedTexture define the serialized text to read from
  63622. * @param scene defines the hosting scene
  63623. * @param rootUrl defines the root url of the cube texture
  63624. * @returns a cube texture
  63625. */
  63626. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  63627. /**
  63628. * Makes a clone, or deep copy, of the cube texture
  63629. * @returns a new cube texture
  63630. */
  63631. clone(): CubeTexture;
  63632. }
  63633. }
  63634. declare module BABYLON {
  63635. /** @hidden */
  63636. export var postprocessVertexShader: {
  63637. name: string;
  63638. shader: string;
  63639. };
  63640. }
  63641. declare module BABYLON {
  63642. /**
  63643. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  63644. * This is the base of the follow, arc rotate cameras and Free camera
  63645. * @see http://doc.babylonjs.com/features/cameras
  63646. */
  63647. export class TargetCamera extends Camera {
  63648. private static _RigCamTransformMatrix;
  63649. private static _TargetTransformMatrix;
  63650. private static _TargetFocalPoint;
  63651. /**
  63652. * Define the current direction the camera is moving to
  63653. */
  63654. cameraDirection: Vector3;
  63655. /**
  63656. * Define the current rotation the camera is rotating to
  63657. */
  63658. cameraRotation: Vector2;
  63659. /**
  63660. * When set, the up vector of the camera will be updated by the rotation of the camera
  63661. */
  63662. updateUpVectorFromRotation: boolean;
  63663. private _tmpQuaternion;
  63664. /**
  63665. * Define the current rotation of the camera
  63666. */
  63667. rotation: Vector3;
  63668. /**
  63669. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  63670. */
  63671. rotationQuaternion: Quaternion;
  63672. /**
  63673. * Define the current speed of the camera
  63674. */
  63675. speed: number;
  63676. /**
  63677. * Add cconstraint to the camera to prevent it to move freely in all directions and
  63678. * around all axis.
  63679. */
  63680. noRotationConstraint: boolean;
  63681. /**
  63682. * Define the current target of the camera as an object or a position.
  63683. */
  63684. lockedTarget: any;
  63685. /** @hidden */
  63686. _currentTarget: Vector3;
  63687. /** @hidden */
  63688. _initialFocalDistance: number;
  63689. /** @hidden */
  63690. _viewMatrix: Matrix;
  63691. /** @hidden */
  63692. _camMatrix: Matrix;
  63693. /** @hidden */
  63694. _cameraTransformMatrix: Matrix;
  63695. /** @hidden */
  63696. _cameraRotationMatrix: Matrix;
  63697. /** @hidden */
  63698. _referencePoint: Vector3;
  63699. /** @hidden */
  63700. _transformedReferencePoint: Vector3;
  63701. protected _globalCurrentTarget: Vector3;
  63702. protected _globalCurrentUpVector: Vector3;
  63703. /** @hidden */
  63704. _reset: () => void;
  63705. private _defaultUp;
  63706. /**
  63707. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  63708. * This is the base of the follow, arc rotate cameras and Free camera
  63709. * @see http://doc.babylonjs.com/features/cameras
  63710. * @param name Defines the name of the camera in the scene
  63711. * @param position Defines the start position of the camera in the scene
  63712. * @param scene Defines the scene the camera belongs to
  63713. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  63714. */
  63715. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  63716. /**
  63717. * Gets the position in front of the camera at a given distance.
  63718. * @param distance The distance from the camera we want the position to be
  63719. * @returns the position
  63720. */
  63721. getFrontPosition(distance: number): Vector3;
  63722. /** @hidden */
  63723. _getLockedTargetPosition(): Nullable<Vector3>;
  63724. private _storedPosition;
  63725. private _storedRotation;
  63726. private _storedRotationQuaternion;
  63727. /**
  63728. * Store current camera state of the camera (fov, position, rotation, etc..)
  63729. * @returns the camera
  63730. */
  63731. storeState(): Camera;
  63732. /**
  63733. * Restored camera state. You must call storeState() first
  63734. * @returns whether it was successful or not
  63735. * @hidden
  63736. */
  63737. _restoreStateValues(): boolean;
  63738. /** @hidden */
  63739. _initCache(): void;
  63740. /** @hidden */
  63741. _updateCache(ignoreParentClass?: boolean): void;
  63742. /** @hidden */
  63743. _isSynchronizedViewMatrix(): boolean;
  63744. /** @hidden */
  63745. _computeLocalCameraSpeed(): number;
  63746. /** @hidden */
  63747. setTarget(target: Vector3): void;
  63748. /**
  63749. * Return the current target position of the camera. This value is expressed in local space.
  63750. * @returns the target position
  63751. */
  63752. getTarget(): Vector3;
  63753. /** @hidden */
  63754. _decideIfNeedsToMove(): boolean;
  63755. /** @hidden */
  63756. _updatePosition(): void;
  63757. /** @hidden */
  63758. _checkInputs(): void;
  63759. protected _updateCameraRotationMatrix(): void;
  63760. /**
  63761. * 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)
  63762. * @returns the current camera
  63763. */
  63764. private _rotateUpVectorWithCameraRotationMatrix;
  63765. private _cachedRotationZ;
  63766. private _cachedQuaternionRotationZ;
  63767. /** @hidden */
  63768. _getViewMatrix(): Matrix;
  63769. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  63770. /**
  63771. * @hidden
  63772. */
  63773. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  63774. /**
  63775. * @hidden
  63776. */
  63777. _updateRigCameras(): void;
  63778. private _getRigCamPositionAndTarget;
  63779. /**
  63780. * Gets the current object class name.
  63781. * @return the class name
  63782. */
  63783. getClassName(): string;
  63784. }
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * @ignore
  63789. * This is a list of all the different input types that are available in the application.
  63790. * Fo instance: ArcRotateCameraGamepadInput...
  63791. */
  63792. export var CameraInputTypes: {};
  63793. /**
  63794. * This is the contract to implement in order to create a new input class.
  63795. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  63796. */
  63797. export interface ICameraInput<TCamera extends Camera> {
  63798. /**
  63799. * Defines the camera the input is attached to.
  63800. */
  63801. camera: Nullable<TCamera>;
  63802. /**
  63803. * Gets the class name of the current intput.
  63804. * @returns the class name
  63805. */
  63806. getClassName(): string;
  63807. /**
  63808. * Get the friendly name associated with the input class.
  63809. * @returns the input friendly name
  63810. */
  63811. getSimpleName(): string;
  63812. /**
  63813. * Attach the input controls to a specific dom element to get the input from.
  63814. * @param element Defines the element the controls should be listened from
  63815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  63816. */
  63817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  63818. /**
  63819. * Detach the current controls from the specified dom element.
  63820. * @param element Defines the element to stop listening the inputs from
  63821. */
  63822. detachControl(element: Nullable<HTMLElement>): void;
  63823. /**
  63824. * Update the current camera state depending on the inputs that have been used this frame.
  63825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  63826. */
  63827. checkInputs?: () => void;
  63828. }
  63829. /**
  63830. * Represents a map of input types to input instance or input index to input instance.
  63831. */
  63832. export interface CameraInputsMap<TCamera extends Camera> {
  63833. /**
  63834. * Accessor to the input by input type.
  63835. */
  63836. [name: string]: ICameraInput<TCamera>;
  63837. /**
  63838. * Accessor to the input by input index.
  63839. */
  63840. [idx: number]: ICameraInput<TCamera>;
  63841. }
  63842. /**
  63843. * This represents the input manager used within a camera.
  63844. * It helps dealing with all the different kind of input attached to a camera.
  63845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  63846. */
  63847. export class CameraInputsManager<TCamera extends Camera> {
  63848. /**
  63849. * Defines the list of inputs attahed to the camera.
  63850. */
  63851. attached: CameraInputsMap<TCamera>;
  63852. /**
  63853. * Defines the dom element the camera is collecting inputs from.
  63854. * This is null if the controls have not been attached.
  63855. */
  63856. attachedElement: Nullable<HTMLElement>;
  63857. /**
  63858. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  63859. */
  63860. noPreventDefault: boolean;
  63861. /**
  63862. * Defined the camera the input manager belongs to.
  63863. */
  63864. camera: TCamera;
  63865. /**
  63866. * Update the current camera state depending on the inputs that have been used this frame.
  63867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  63868. */
  63869. checkInputs: () => void;
  63870. /**
  63871. * Instantiate a new Camera Input Manager.
  63872. * @param camera Defines the camera the input manager blongs to
  63873. */
  63874. constructor(camera: TCamera);
  63875. /**
  63876. * Add an input method to a camera
  63877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  63878. * @param input camera input method
  63879. */
  63880. add(input: ICameraInput<TCamera>): void;
  63881. /**
  63882. * Remove a specific input method from a camera
  63883. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  63884. * @param inputToRemove camera input method
  63885. */
  63886. remove(inputToRemove: ICameraInput<TCamera>): void;
  63887. /**
  63888. * Remove a specific input type from a camera
  63889. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  63890. * @param inputType the type of the input to remove
  63891. */
  63892. removeByType(inputType: string): void;
  63893. private _addCheckInputs;
  63894. /**
  63895. * Attach the input controls to the currently attached dom element to listen the events from.
  63896. * @param input Defines the input to attach
  63897. */
  63898. attachInput(input: ICameraInput<TCamera>): void;
  63899. /**
  63900. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  63901. * @param element Defines the dom element to collect the events from
  63902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  63903. */
  63904. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  63905. /**
  63906. * Detach the current manager inputs controls from a specific dom element.
  63907. * @param element Defines the dom element to collect the events from
  63908. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  63909. */
  63910. detachElement(element: HTMLElement, disconnect?: boolean): void;
  63911. /**
  63912. * Rebuild the dynamic inputCheck function from the current list of
  63913. * defined inputs in the manager.
  63914. */
  63915. rebuildInputCheck(): void;
  63916. /**
  63917. * Remove all attached input methods from a camera
  63918. */
  63919. clear(): void;
  63920. /**
  63921. * Serialize the current input manager attached to a camera.
  63922. * This ensures than once parsed,
  63923. * the input associated to the camera will be identical to the current ones
  63924. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  63925. */
  63926. serialize(serializedCamera: any): void;
  63927. /**
  63928. * Parses an input manager serialized JSON to restore the previous list of inputs
  63929. * and states associated to a camera.
  63930. * @param parsedCamera Defines the JSON to parse
  63931. */
  63932. parse(parsedCamera: any): void;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Gather the list of keyboard event types as constants.
  63938. */
  63939. export class KeyboardEventTypes {
  63940. /**
  63941. * The keydown event is fired when a key becomes active (pressed).
  63942. */
  63943. static readonly KEYDOWN: number;
  63944. /**
  63945. * The keyup event is fired when a key has been released.
  63946. */
  63947. static readonly KEYUP: number;
  63948. }
  63949. /**
  63950. * This class is used to store keyboard related info for the onKeyboardObservable event.
  63951. */
  63952. export class KeyboardInfo {
  63953. /**
  63954. * Defines the type of event (KeyboardEventTypes)
  63955. */
  63956. type: number;
  63957. /**
  63958. * Defines the related dom event
  63959. */
  63960. event: KeyboardEvent;
  63961. /**
  63962. * Instantiates a new keyboard info.
  63963. * This class is used to store keyboard related info for the onKeyboardObservable event.
  63964. * @param type Defines the type of event (KeyboardEventTypes)
  63965. * @param event Defines the related dom event
  63966. */
  63967. constructor(
  63968. /**
  63969. * Defines the type of event (KeyboardEventTypes)
  63970. */
  63971. type: number,
  63972. /**
  63973. * Defines the related dom event
  63974. */
  63975. event: KeyboardEvent);
  63976. }
  63977. /**
  63978. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  63979. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  63980. */
  63981. export class KeyboardInfoPre extends KeyboardInfo {
  63982. /**
  63983. * Defines the type of event (KeyboardEventTypes)
  63984. */
  63985. type: number;
  63986. /**
  63987. * Defines the related dom event
  63988. */
  63989. event: KeyboardEvent;
  63990. /**
  63991. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  63992. */
  63993. skipOnPointerObservable: boolean;
  63994. /**
  63995. * Instantiates a new keyboard pre info.
  63996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  63997. * @param type Defines the type of event (KeyboardEventTypes)
  63998. * @param event Defines the related dom event
  63999. */
  64000. constructor(
  64001. /**
  64002. * Defines the type of event (KeyboardEventTypes)
  64003. */
  64004. type: number,
  64005. /**
  64006. * Defines the related dom event
  64007. */
  64008. event: KeyboardEvent);
  64009. }
  64010. }
  64011. declare module BABYLON {
  64012. /**
  64013. * Manage the keyboard inputs to control the movement of a free camera.
  64014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64015. */
  64016. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64017. /**
  64018. * Defines the camera the input is attached to.
  64019. */
  64020. camera: FreeCamera;
  64021. /**
  64022. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64023. */
  64024. keysUp: number[];
  64025. /**
  64026. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64027. */
  64028. keysDown: number[];
  64029. /**
  64030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64031. */
  64032. keysLeft: number[];
  64033. /**
  64034. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64035. */
  64036. keysRight: number[];
  64037. private _keys;
  64038. private _onCanvasBlurObserver;
  64039. private _onKeyboardObserver;
  64040. private _engine;
  64041. private _scene;
  64042. /**
  64043. * Attach the input controls to a specific dom element to get the input from.
  64044. * @param element Defines the element the controls should be listened from
  64045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64046. */
  64047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64048. /**
  64049. * Detach the current controls from the specified dom element.
  64050. * @param element Defines the element to stop listening the inputs from
  64051. */
  64052. detachControl(element: Nullable<HTMLElement>): void;
  64053. /**
  64054. * Update the current camera state depending on the inputs that have been used this frame.
  64055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64056. */
  64057. checkInputs(): void;
  64058. /**
  64059. * Gets the class name of the current intput.
  64060. * @returns the class name
  64061. */
  64062. getClassName(): string;
  64063. /** @hidden */
  64064. _onLostFocus(): void;
  64065. /**
  64066. * Get the friendly name associated with the input class.
  64067. * @returns the input friendly name
  64068. */
  64069. getSimpleName(): string;
  64070. }
  64071. }
  64072. declare module BABYLON {
  64073. /**
  64074. * Gather the list of pointer event types as constants.
  64075. */
  64076. export class PointerEventTypes {
  64077. /**
  64078. * 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.
  64079. */
  64080. static readonly POINTERDOWN: number;
  64081. /**
  64082. * The pointerup event is fired when a pointer is no longer active.
  64083. */
  64084. static readonly POINTERUP: number;
  64085. /**
  64086. * The pointermove event is fired when a pointer changes coordinates.
  64087. */
  64088. static readonly POINTERMOVE: number;
  64089. /**
  64090. * The pointerwheel event is fired when a mouse wheel has been rotated.
  64091. */
  64092. static readonly POINTERWHEEL: number;
  64093. /**
  64094. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  64095. */
  64096. static readonly POINTERPICK: number;
  64097. /**
  64098. * The pointertap event is fired when a the object has been touched and released without drag.
  64099. */
  64100. static readonly POINTERTAP: number;
  64101. /**
  64102. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  64103. */
  64104. static readonly POINTERDOUBLETAP: number;
  64105. }
  64106. /**
  64107. * Base class of pointer info types.
  64108. */
  64109. export class PointerInfoBase {
  64110. /**
  64111. * Defines the type of event (PointerEventTypes)
  64112. */
  64113. type: number;
  64114. /**
  64115. * Defines the related dom event
  64116. */
  64117. event: PointerEvent | MouseWheelEvent;
  64118. /**
  64119. * Instantiates the base class of pointers info.
  64120. * @param type Defines the type of event (PointerEventTypes)
  64121. * @param event Defines the related dom event
  64122. */
  64123. constructor(
  64124. /**
  64125. * Defines the type of event (PointerEventTypes)
  64126. */
  64127. type: number,
  64128. /**
  64129. * Defines the related dom event
  64130. */
  64131. event: PointerEvent | MouseWheelEvent);
  64132. }
  64133. /**
  64134. * This class is used to store pointer related info for the onPrePointerObservable event.
  64135. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  64136. */
  64137. export class PointerInfoPre extends PointerInfoBase {
  64138. /**
  64139. * Ray from a pointer if availible (eg. 6dof controller)
  64140. */
  64141. ray: Nullable<Ray>;
  64142. /**
  64143. * Defines the local position of the pointer on the canvas.
  64144. */
  64145. localPosition: Vector2;
  64146. /**
  64147. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  64148. */
  64149. skipOnPointerObservable: boolean;
  64150. /**
  64151. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  64152. * @param type Defines the type of event (PointerEventTypes)
  64153. * @param event Defines the related dom event
  64154. * @param localX Defines the local x coordinates of the pointer when the event occured
  64155. * @param localY Defines the local y coordinates of the pointer when the event occured
  64156. */
  64157. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  64158. }
  64159. /**
  64160. * This type contains all the data related to a pointer event in Babylon.js.
  64161. * 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.
  64162. */
  64163. export class PointerInfo extends PointerInfoBase {
  64164. /**
  64165. * Defines the picking info associated to the info (if any)\
  64166. */
  64167. pickInfo: Nullable<PickingInfo>;
  64168. /**
  64169. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  64170. * @param type Defines the type of event (PointerEventTypes)
  64171. * @param event Defines the related dom event
  64172. * @param pickInfo Defines the picking info associated to the info (if any)\
  64173. */
  64174. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  64175. /**
  64176. * Defines the picking info associated to the info (if any)\
  64177. */
  64178. pickInfo: Nullable<PickingInfo>);
  64179. }
  64180. }
  64181. declare module BABYLON {
  64182. /**
  64183. * Manage the mouse inputs to control the movement of a free camera.
  64184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64185. */
  64186. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  64187. /**
  64188. * Define if touch is enabled in the mouse input
  64189. */
  64190. touchEnabled: boolean;
  64191. /**
  64192. * Defines the camera the input is attached to.
  64193. */
  64194. camera: FreeCamera;
  64195. /**
  64196. * Defines the buttons associated with the input to handle camera move.
  64197. */
  64198. buttons: number[];
  64199. /**
  64200. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  64201. */
  64202. angularSensibility: number;
  64203. private _pointerInput;
  64204. private _onMouseMove;
  64205. private _observer;
  64206. private previousPosition;
  64207. /**
  64208. * Manage the mouse inputs to control the movement of a free camera.
  64209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64210. * @param touchEnabled Defines if touch is enabled or not
  64211. */
  64212. constructor(
  64213. /**
  64214. * Define if touch is enabled in the mouse input
  64215. */
  64216. touchEnabled?: boolean);
  64217. /**
  64218. * Attach the input controls to a specific dom element to get the input from.
  64219. * @param element Defines the element the controls should be listened from
  64220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64221. */
  64222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64223. /**
  64224. * Detach the current controls from the specified dom element.
  64225. * @param element Defines the element to stop listening the inputs from
  64226. */
  64227. detachControl(element: Nullable<HTMLElement>): void;
  64228. /**
  64229. * Gets the class name of the current intput.
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Get the friendly name associated with the input class.
  64235. * @returns the input friendly name
  64236. */
  64237. getSimpleName(): string;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /**
  64242. * Manage the touch inputs to control the movement of a free camera.
  64243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64244. */
  64245. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  64246. /**
  64247. * Defines the camera the input is attached to.
  64248. */
  64249. camera: FreeCamera;
  64250. /**
  64251. * Defines the touch sensibility for rotation.
  64252. * The higher the faster.
  64253. */
  64254. touchAngularSensibility: number;
  64255. /**
  64256. * Defines the touch sensibility for move.
  64257. * The higher the faster.
  64258. */
  64259. touchMoveSensibility: number;
  64260. private _offsetX;
  64261. private _offsetY;
  64262. private _pointerPressed;
  64263. private _pointerInput;
  64264. private _observer;
  64265. private _onLostFocus;
  64266. /**
  64267. * Attach the input controls to a specific dom element to get the input from.
  64268. * @param element Defines the element the controls should be listened from
  64269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64270. */
  64271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64272. /**
  64273. * Detach the current controls from the specified dom element.
  64274. * @param element Defines the element to stop listening the inputs from
  64275. */
  64276. detachControl(element: Nullable<HTMLElement>): void;
  64277. /**
  64278. * Update the current camera state depending on the inputs that have been used this frame.
  64279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64280. */
  64281. checkInputs(): void;
  64282. /**
  64283. * Gets the class name of the current intput.
  64284. * @returns the class name
  64285. */
  64286. getClassName(): string;
  64287. /**
  64288. * Get the friendly name associated with the input class.
  64289. * @returns the input friendly name
  64290. */
  64291. getSimpleName(): string;
  64292. }
  64293. }
  64294. declare module BABYLON {
  64295. /**
  64296. * Default Inputs manager for the FreeCamera.
  64297. * It groups all the default supported inputs for ease of use.
  64298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64299. */
  64300. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  64301. /**
  64302. * Instantiates a new FreeCameraInputsManager.
  64303. * @param camera Defines the camera the inputs belong to
  64304. */
  64305. constructor(camera: FreeCamera);
  64306. /**
  64307. * Add keyboard input support to the input manager.
  64308. * @returns the current input manager
  64309. */
  64310. addKeyboard(): FreeCameraInputsManager;
  64311. /**
  64312. * Add mouse input support to the input manager.
  64313. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  64314. * @returns the current input manager
  64315. */
  64316. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  64317. /**
  64318. * Add touch input support to the input manager.
  64319. * @returns the current input manager
  64320. */
  64321. addTouch(): FreeCameraInputsManager;
  64322. }
  64323. }
  64324. declare module BABYLON {
  64325. /**
  64326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64327. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  64328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64329. */
  64330. export class FreeCamera extends TargetCamera {
  64331. /**
  64332. * Define the collision ellipsoid of the camera.
  64333. * This is helpful to simulate a camera body like the player body around the camera
  64334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  64335. */
  64336. ellipsoid: Vector3;
  64337. /**
  64338. * Define an offset for the position of the ellipsoid around the camera.
  64339. * This can be helpful to determine the center of the body near the gravity center of the body
  64340. * instead of its head.
  64341. */
  64342. ellipsoidOffset: Vector3;
  64343. /**
  64344. * Enable or disable collisions of the camera with the rest of the scene objects.
  64345. */
  64346. checkCollisions: boolean;
  64347. /**
  64348. * Enable or disable gravity on the camera.
  64349. */
  64350. applyGravity: boolean;
  64351. /**
  64352. * Define the input manager associated to the camera.
  64353. */
  64354. inputs: FreeCameraInputsManager;
  64355. /**
  64356. * Gets the input sensibility for a mouse input. (default is 2000.0)
  64357. * Higher values reduce sensitivity.
  64358. */
  64359. /**
  64360. * Sets the input sensibility for a mouse input. (default is 2000.0)
  64361. * Higher values reduce sensitivity.
  64362. */
  64363. angularSensibility: number;
  64364. /**
  64365. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64366. */
  64367. keysUp: number[];
  64368. /**
  64369. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64370. */
  64371. keysDown: number[];
  64372. /**
  64373. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64374. */
  64375. keysLeft: number[];
  64376. /**
  64377. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64378. */
  64379. keysRight: number[];
  64380. /**
  64381. * Event raised when the camera collide with a mesh in the scene.
  64382. */
  64383. onCollide: (collidedMesh: AbstractMesh) => void;
  64384. private _collider;
  64385. private _needMoveForGravity;
  64386. private _oldPosition;
  64387. private _diffPosition;
  64388. private _newPosition;
  64389. /** @hidden */
  64390. _localDirection: Vector3;
  64391. /** @hidden */
  64392. _transformedDirection: Vector3;
  64393. /**
  64394. * Instantiates a Free Camera.
  64395. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64396. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  64397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64398. * @param name Define the name of the camera in the scene
  64399. * @param position Define the start position of the camera in the scene
  64400. * @param scene Define the scene the camera belongs to
  64401. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64402. */
  64403. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64404. /**
  64405. * Attached controls to the current camera.
  64406. * @param element Defines the element the controls should be listened from
  64407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64408. */
  64409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64410. /**
  64411. * Detach the current controls from the camera.
  64412. * The camera will stop reacting to inputs.
  64413. * @param element Defines the element to stop listening the inputs from
  64414. */
  64415. detachControl(element: HTMLElement): void;
  64416. private _collisionMask;
  64417. /**
  64418. * Define a collision mask to limit the list of object the camera can collide with
  64419. */
  64420. collisionMask: number;
  64421. /** @hidden */
  64422. _collideWithWorld(displacement: Vector3): void;
  64423. private _onCollisionPositionChange;
  64424. /** @hidden */
  64425. _checkInputs(): void;
  64426. /** @hidden */
  64427. _decideIfNeedsToMove(): boolean;
  64428. /** @hidden */
  64429. _updatePosition(): void;
  64430. /**
  64431. * Destroy the camera and release the current resources hold by it.
  64432. */
  64433. dispose(): void;
  64434. /**
  64435. * Gets the current object class name.
  64436. * @return the class name
  64437. */
  64438. getClassName(): string;
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /**
  64443. * Represents a gamepad control stick position
  64444. */
  64445. export class StickValues {
  64446. /**
  64447. * The x component of the control stick
  64448. */
  64449. x: number;
  64450. /**
  64451. * The y component of the control stick
  64452. */
  64453. y: number;
  64454. /**
  64455. * Initializes the gamepad x and y control stick values
  64456. * @param x The x component of the gamepad control stick value
  64457. * @param y The y component of the gamepad control stick value
  64458. */
  64459. constructor(
  64460. /**
  64461. * The x component of the control stick
  64462. */
  64463. x: number,
  64464. /**
  64465. * The y component of the control stick
  64466. */
  64467. y: number);
  64468. }
  64469. /**
  64470. * An interface which manages callbacks for gamepad button changes
  64471. */
  64472. export interface GamepadButtonChanges {
  64473. /**
  64474. * Called when a gamepad has been changed
  64475. */
  64476. changed: boolean;
  64477. /**
  64478. * Called when a gamepad press event has been triggered
  64479. */
  64480. pressChanged: boolean;
  64481. /**
  64482. * Called when a touch event has been triggered
  64483. */
  64484. touchChanged: boolean;
  64485. /**
  64486. * Called when a value has changed
  64487. */
  64488. valueChanged: boolean;
  64489. }
  64490. /**
  64491. * Represents a gamepad
  64492. */
  64493. export class Gamepad {
  64494. /**
  64495. * The id of the gamepad
  64496. */
  64497. id: string;
  64498. /**
  64499. * The index of the gamepad
  64500. */
  64501. index: number;
  64502. /**
  64503. * The browser gamepad
  64504. */
  64505. browserGamepad: any;
  64506. /**
  64507. * Specifies what type of gamepad this represents
  64508. */
  64509. type: number;
  64510. private _leftStick;
  64511. private _rightStick;
  64512. /** @hidden */
  64513. _isConnected: boolean;
  64514. private _leftStickAxisX;
  64515. private _leftStickAxisY;
  64516. private _rightStickAxisX;
  64517. private _rightStickAxisY;
  64518. /**
  64519. * Triggered when the left control stick has been changed
  64520. */
  64521. private _onleftstickchanged;
  64522. /**
  64523. * Triggered when the right control stick has been changed
  64524. */
  64525. private _onrightstickchanged;
  64526. /**
  64527. * Represents a gamepad controller
  64528. */
  64529. static GAMEPAD: number;
  64530. /**
  64531. * Represents a generic controller
  64532. */
  64533. static GENERIC: number;
  64534. /**
  64535. * Represents an XBox controller
  64536. */
  64537. static XBOX: number;
  64538. /**
  64539. * Represents a pose-enabled controller
  64540. */
  64541. static POSE_ENABLED: number;
  64542. /**
  64543. * Specifies whether the left control stick should be Y-inverted
  64544. */
  64545. protected _invertLeftStickY: boolean;
  64546. /**
  64547. * Specifies if the gamepad has been connected
  64548. */
  64549. readonly isConnected: boolean;
  64550. /**
  64551. * Initializes the gamepad
  64552. * @param id The id of the gamepad
  64553. * @param index The index of the gamepad
  64554. * @param browserGamepad The browser gamepad
  64555. * @param leftStickX The x component of the left joystick
  64556. * @param leftStickY The y component of the left joystick
  64557. * @param rightStickX The x component of the right joystick
  64558. * @param rightStickY The y component of the right joystick
  64559. */
  64560. constructor(
  64561. /**
  64562. * The id of the gamepad
  64563. */
  64564. id: string,
  64565. /**
  64566. * The index of the gamepad
  64567. */
  64568. index: number,
  64569. /**
  64570. * The browser gamepad
  64571. */
  64572. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  64573. /**
  64574. * Callback triggered when the left joystick has changed
  64575. * @param callback
  64576. */
  64577. onleftstickchanged(callback: (values: StickValues) => void): void;
  64578. /**
  64579. * Callback triggered when the right joystick has changed
  64580. * @param callback
  64581. */
  64582. onrightstickchanged(callback: (values: StickValues) => void): void;
  64583. /**
  64584. * Gets the left joystick
  64585. */
  64586. /**
  64587. * Sets the left joystick values
  64588. */
  64589. leftStick: StickValues;
  64590. /**
  64591. * Gets the right joystick
  64592. */
  64593. /**
  64594. * Sets the right joystick value
  64595. */
  64596. rightStick: StickValues;
  64597. /**
  64598. * Updates the gamepad joystick positions
  64599. */
  64600. update(): void;
  64601. /**
  64602. * Disposes the gamepad
  64603. */
  64604. dispose(): void;
  64605. }
  64606. /**
  64607. * Represents a generic gamepad
  64608. */
  64609. export class GenericPad extends Gamepad {
  64610. private _buttons;
  64611. private _onbuttondown;
  64612. private _onbuttonup;
  64613. /**
  64614. * Observable triggered when a button has been pressed
  64615. */
  64616. onButtonDownObservable: Observable<number>;
  64617. /**
  64618. * Observable triggered when a button has been released
  64619. */
  64620. onButtonUpObservable: Observable<number>;
  64621. /**
  64622. * Callback triggered when a button has been pressed
  64623. * @param callback Called when a button has been pressed
  64624. */
  64625. onbuttondown(callback: (buttonPressed: number) => void): void;
  64626. /**
  64627. * Callback triggered when a button has been released
  64628. * @param callback Called when a button has been released
  64629. */
  64630. onbuttonup(callback: (buttonReleased: number) => void): void;
  64631. /**
  64632. * Initializes the generic gamepad
  64633. * @param id The id of the generic gamepad
  64634. * @param index The index of the generic gamepad
  64635. * @param browserGamepad The browser gamepad
  64636. */
  64637. constructor(id: string, index: number, browserGamepad: any);
  64638. private _setButtonValue;
  64639. /**
  64640. * Updates the generic gamepad
  64641. */
  64642. update(): void;
  64643. /**
  64644. * Disposes the generic gamepad
  64645. */
  64646. dispose(): void;
  64647. }
  64648. }
  64649. declare module BABYLON {
  64650. /**
  64651. * Raw texture can help creating a texture directly from an array of data.
  64652. * This can be super useful if you either get the data from an uncompressed source or
  64653. * if you wish to create your texture pixel by pixel.
  64654. */
  64655. export class RawTexture extends Texture {
  64656. /**
  64657. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  64658. */
  64659. format: number;
  64660. private _engine;
  64661. /**
  64662. * Instantiates a new RawTexture.
  64663. * Raw texture can help creating a texture directly from an array of data.
  64664. * This can be super useful if you either get the data from an uncompressed source or
  64665. * if you wish to create your texture pixel by pixel.
  64666. * @param data define the array of data to use to create the texture
  64667. * @param width define the width of the texture
  64668. * @param height define the height of the texture
  64669. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  64670. * @param scene define the scene the texture belongs to
  64671. * @param generateMipMaps define whether mip maps should be generated or not
  64672. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64673. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64674. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  64675. */
  64676. constructor(data: ArrayBufferView, width: number, height: number,
  64677. /**
  64678. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  64679. */
  64680. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  64681. /**
  64682. * Updates the texture underlying data.
  64683. * @param data Define the new data of the texture
  64684. */
  64685. update(data: ArrayBufferView): void;
  64686. /**
  64687. * Creates a luminance texture from some data.
  64688. * @param data Define the texture data
  64689. * @param width Define the width of the texture
  64690. * @param height Define the height of the texture
  64691. * @param scene Define the scene the texture belongs to
  64692. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64693. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64694. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64695. * @returns the luminance texture
  64696. */
  64697. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  64698. /**
  64699. * Creates a luminance alpha texture from some data.
  64700. * @param data Define the texture data
  64701. * @param width Define the width of the texture
  64702. * @param height Define the height of the texture
  64703. * @param scene Define the scene the texture belongs to
  64704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64707. * @returns the luminance alpha texture
  64708. */
  64709. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  64710. /**
  64711. * Creates an alpha texture from some data.
  64712. * @param data Define the texture data
  64713. * @param width Define the width of the texture
  64714. * @param height Define the height of the texture
  64715. * @param scene Define the scene the texture belongs to
  64716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64719. * @returns the alpha texture
  64720. */
  64721. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  64722. /**
  64723. * Creates a RGB texture from some data.
  64724. * @param data Define the texture data
  64725. * @param width Define the width of the texture
  64726. * @param height Define the height of the texture
  64727. * @param scene Define the scene the texture belongs to
  64728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64731. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  64732. * @returns the RGB alpha texture
  64733. */
  64734. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  64735. /**
  64736. * Creates a RGBA texture from some data.
  64737. * @param data Define the texture data
  64738. * @param width Define the width of the texture
  64739. * @param height Define the height of the texture
  64740. * @param scene Define the scene the texture belongs to
  64741. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64742. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64743. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64744. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  64745. * @returns the RGBA texture
  64746. */
  64747. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  64748. /**
  64749. * Creates a R texture from some data.
  64750. * @param data Define the texture data
  64751. * @param width Define the width of the texture
  64752. * @param height Define the height of the texture
  64753. * @param scene Define the scene the texture belongs to
  64754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  64755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  64756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  64757. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  64758. * @returns the R texture
  64759. */
  64760. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  64761. }
  64762. }
  64763. declare module BABYLON {
  64764. /**
  64765. * Class used to handle skinning animations
  64766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  64767. */
  64768. export class Skeleton implements IAnimatable {
  64769. /** defines the skeleton name */
  64770. name: string;
  64771. /** defines the skeleton Id */
  64772. id: string;
  64773. /**
  64774. * Defines the list of child bones
  64775. */
  64776. bones: Bone[];
  64777. /**
  64778. * Defines an estimate of the dimension of the skeleton at rest
  64779. */
  64780. dimensionsAtRest: Vector3;
  64781. /**
  64782. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  64783. */
  64784. needInitialSkinMatrix: boolean;
  64785. /**
  64786. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  64787. */
  64788. overrideMesh: Nullable<AbstractMesh>;
  64789. /**
  64790. * Gets the list of animations attached to this skeleton
  64791. */
  64792. animations: Array<Animation>;
  64793. private _scene;
  64794. private _isDirty;
  64795. private _transformMatrices;
  64796. private _transformMatrixTexture;
  64797. private _meshesWithPoseMatrix;
  64798. private _animatables;
  64799. private _identity;
  64800. private _synchronizedWithMesh;
  64801. private _ranges;
  64802. private _lastAbsoluteTransformsUpdateId;
  64803. private _canUseTextureForBones;
  64804. /** @hidden */
  64805. _numBonesWithLinkedTransformNode: number;
  64806. /**
  64807. * Specifies if the skeleton should be serialized
  64808. */
  64809. doNotSerialize: boolean;
  64810. /**
  64811. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  64812. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  64813. */
  64814. useTextureToStoreBoneMatrices: boolean;
  64815. private _animationPropertiesOverride;
  64816. /**
  64817. * Gets or sets the animation properties override
  64818. */
  64819. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64820. /**
  64821. * An observable triggered before computing the skeleton's matrices
  64822. */
  64823. onBeforeComputeObservable: Observable<Skeleton>;
  64824. /**
  64825. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  64826. */
  64827. readonly isUsingTextureForMatrices: boolean;
  64828. /**
  64829. * Creates a new skeleton
  64830. * @param name defines the skeleton name
  64831. * @param id defines the skeleton Id
  64832. * @param scene defines the hosting scene
  64833. */
  64834. constructor(
  64835. /** defines the skeleton name */
  64836. name: string,
  64837. /** defines the skeleton Id */
  64838. id: string, scene: Scene);
  64839. /**
  64840. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  64841. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  64842. * @returns a Float32Array containing matrices data
  64843. */
  64844. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  64845. /**
  64846. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  64847. * @returns a raw texture containing the data
  64848. */
  64849. getTransformMatrixTexture(): Nullable<RawTexture>;
  64850. /**
  64851. * Gets the current hosting scene
  64852. * @returns a scene object
  64853. */
  64854. getScene(): Scene;
  64855. /**
  64856. * Gets a string representing the current skeleton data
  64857. * @param fullDetails defines a boolean indicating if we want a verbose version
  64858. * @returns a string representing the current skeleton data
  64859. */
  64860. toString(fullDetails?: boolean): string;
  64861. /**
  64862. * Get bone's index searching by name
  64863. * @param name defines bone's name to search for
  64864. * @return the indice of the bone. Returns -1 if not found
  64865. */
  64866. getBoneIndexByName(name: string): number;
  64867. /**
  64868. * Creater a new animation range
  64869. * @param name defines the name of the range
  64870. * @param from defines the start key
  64871. * @param to defines the end key
  64872. */
  64873. createAnimationRange(name: string, from: number, to: number): void;
  64874. /**
  64875. * Delete a specific animation range
  64876. * @param name defines the name of the range
  64877. * @param deleteFrames defines if frames must be removed as well
  64878. */
  64879. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  64880. /**
  64881. * Gets a specific animation range
  64882. * @param name defines the name of the range to look for
  64883. * @returns the requested animation range or null if not found
  64884. */
  64885. getAnimationRange(name: string): Nullable<AnimationRange>;
  64886. /**
  64887. * Gets the list of all animation ranges defined on this skeleton
  64888. * @returns an array
  64889. */
  64890. getAnimationRanges(): Nullable<AnimationRange>[];
  64891. /**
  64892. * Copy animation range from a source skeleton.
  64893. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  64894. * @param source defines the source skeleton
  64895. * @param name defines the name of the range to copy
  64896. * @param rescaleAsRequired defines if rescaling must be applied if required
  64897. * @returns true if operation was successful
  64898. */
  64899. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  64900. /**
  64901. * Forces the skeleton to go to rest pose
  64902. */
  64903. returnToRest(): void;
  64904. private _getHighestAnimationFrame;
  64905. /**
  64906. * Begin a specific animation range
  64907. * @param name defines the name of the range to start
  64908. * @param loop defines if looping must be turned on (false by default)
  64909. * @param speedRatio defines the speed ratio to apply (1 by default)
  64910. * @param onAnimationEnd defines a callback which will be called when animation will end
  64911. * @returns a new animatable
  64912. */
  64913. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  64914. /** @hidden */
  64915. _markAsDirty(): void;
  64916. /** @hidden */
  64917. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  64918. /** @hidden */
  64919. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  64920. private _computeTransformMatrices;
  64921. /**
  64922. * Build all resources required to render a skeleton
  64923. */
  64924. prepare(): void;
  64925. /**
  64926. * Gets the list of animatables currently running for this skeleton
  64927. * @returns an array of animatables
  64928. */
  64929. getAnimatables(): IAnimatable[];
  64930. /**
  64931. * Clone the current skeleton
  64932. * @param name defines the name of the new skeleton
  64933. * @param id defines the id of the enw skeleton
  64934. * @returns the new skeleton
  64935. */
  64936. clone(name: string, id: string): Skeleton;
  64937. /**
  64938. * Enable animation blending for this skeleton
  64939. * @param blendingSpeed defines the blending speed to apply
  64940. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  64941. */
  64942. enableBlending(blendingSpeed?: number): void;
  64943. /**
  64944. * Releases all resources associated with the current skeleton
  64945. */
  64946. dispose(): void;
  64947. /**
  64948. * Serialize the skeleton in a JSON object
  64949. * @returns a JSON object
  64950. */
  64951. serialize(): any;
  64952. /**
  64953. * Creates a new skeleton from serialized data
  64954. * @param parsedSkeleton defines the serialized data
  64955. * @param scene defines the hosting scene
  64956. * @returns a new skeleton
  64957. */
  64958. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  64959. /**
  64960. * Compute all node absolute transforms
  64961. * @param forceUpdate defines if computation must be done even if cache is up to date
  64962. */
  64963. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  64964. /**
  64965. * Gets the root pose matrix
  64966. * @returns a matrix
  64967. */
  64968. getPoseMatrix(): Nullable<Matrix>;
  64969. /**
  64970. * Sorts bones per internal index
  64971. */
  64972. sortBones(): void;
  64973. private _sortBones;
  64974. }
  64975. }
  64976. declare module BABYLON {
  64977. /**
  64978. * Class used to store bone information
  64979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  64980. */
  64981. export class Bone extends Node {
  64982. /**
  64983. * defines the bone name
  64984. */
  64985. name: string;
  64986. private static _tmpVecs;
  64987. private static _tmpQuat;
  64988. private static _tmpMats;
  64989. /**
  64990. * Gets the list of child bones
  64991. */
  64992. children: Bone[];
  64993. /** Gets the animations associated with this bone */
  64994. animations: Animation[];
  64995. /**
  64996. * Gets or sets bone length
  64997. */
  64998. length: number;
  64999. /**
  65000. * @hidden Internal only
  65001. * Set this value to map this bone to a different index in the transform matrices
  65002. * Set this value to -1 to exclude the bone from the transform matrices
  65003. */
  65004. _index: Nullable<number>;
  65005. private _skeleton;
  65006. private _localMatrix;
  65007. private _restPose;
  65008. private _baseMatrix;
  65009. private _absoluteTransform;
  65010. private _invertedAbsoluteTransform;
  65011. private _parent;
  65012. private _scalingDeterminant;
  65013. private _worldTransform;
  65014. private _localScaling;
  65015. private _localRotation;
  65016. private _localPosition;
  65017. private _needToDecompose;
  65018. private _needToCompose;
  65019. /** @hidden */
  65020. _linkedTransformNode: Nullable<TransformNode>;
  65021. /** @hidden */
  65022. /** @hidden */
  65023. _matrix: Matrix;
  65024. /**
  65025. * Create a new bone
  65026. * @param name defines the bone name
  65027. * @param skeleton defines the parent skeleton
  65028. * @param parentBone defines the parent (can be null if the bone is the root)
  65029. * @param localMatrix defines the local matrix
  65030. * @param restPose defines the rest pose matrix
  65031. * @param baseMatrix defines the base matrix
  65032. * @param index defines index of the bone in the hiearchy
  65033. */
  65034. constructor(
  65035. /**
  65036. * defines the bone name
  65037. */
  65038. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65039. /**
  65040. * Gets the parent skeleton
  65041. * @returns a skeleton
  65042. */
  65043. getSkeleton(): Skeleton;
  65044. /**
  65045. * Gets parent bone
  65046. * @returns a bone or null if the bone is the root of the bone hierarchy
  65047. */
  65048. getParent(): Nullable<Bone>;
  65049. /**
  65050. * Sets the parent bone
  65051. * @param parent defines the parent (can be null if the bone is the root)
  65052. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65053. */
  65054. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65055. /**
  65056. * Gets the local matrix
  65057. * @returns a matrix
  65058. */
  65059. getLocalMatrix(): Matrix;
  65060. /**
  65061. * Gets the base matrix (initial matrix which remains unchanged)
  65062. * @returns a matrix
  65063. */
  65064. getBaseMatrix(): Matrix;
  65065. /**
  65066. * Gets the rest pose matrix
  65067. * @returns a matrix
  65068. */
  65069. getRestPose(): Matrix;
  65070. /**
  65071. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65072. */
  65073. getWorldMatrix(): Matrix;
  65074. /**
  65075. * Sets the local matrix to rest pose matrix
  65076. */
  65077. returnToRest(): void;
  65078. /**
  65079. * Gets the inverse of the absolute transform matrix.
  65080. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65081. * @returns a matrix
  65082. */
  65083. getInvertedAbsoluteTransform(): Matrix;
  65084. /**
  65085. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65086. * @returns a matrix
  65087. */
  65088. getAbsoluteTransform(): Matrix;
  65089. /**
  65090. * Links with the given transform node.
  65091. * The local matrix of this bone is copied from the transform node every frame.
  65092. * @param transformNode defines the transform node to link to
  65093. */
  65094. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65095. /** Gets or sets current position (in local space) */
  65096. position: Vector3;
  65097. /** Gets or sets current rotation (in local space) */
  65098. rotation: Vector3;
  65099. /** Gets or sets current rotation quaternion (in local space) */
  65100. rotationQuaternion: Quaternion;
  65101. /** Gets or sets current scaling (in local space) */
  65102. scaling: Vector3;
  65103. /**
  65104. * Gets the animation properties override
  65105. */
  65106. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65107. private _decompose;
  65108. private _compose;
  65109. /**
  65110. * Update the base and local matrices
  65111. * @param matrix defines the new base or local matrix
  65112. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65113. * @param updateLocalMatrix defines if the local matrix should be updated
  65114. */
  65115. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65116. /** @hidden */
  65117. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65118. /**
  65119. * Flag the bone as dirty (Forcing it to update everything)
  65120. */
  65121. markAsDirty(): void;
  65122. private _markAsDirtyAndCompose;
  65123. private _markAsDirtyAndDecompose;
  65124. /**
  65125. * Copy an animation range from another bone
  65126. * @param source defines the source bone
  65127. * @param rangeName defines the range name to copy
  65128. * @param frameOffset defines the frame offset
  65129. * @param rescaleAsRequired defines if rescaling must be applied if required
  65130. * @param skelDimensionsRatio defines the scaling ratio
  65131. * @returns true if operation was successful
  65132. */
  65133. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  65134. /**
  65135. * Translate the bone in local or world space
  65136. * @param vec The amount to translate the bone
  65137. * @param space The space that the translation is in
  65138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65139. */
  65140. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65141. /**
  65142. * Set the postion of the bone in local or world space
  65143. * @param position The position to set the bone
  65144. * @param space The space that the position is in
  65145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65146. */
  65147. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65148. /**
  65149. * Set the absolute position of the bone (world space)
  65150. * @param position The position to set the bone
  65151. * @param mesh The mesh that this bone is attached to
  65152. */
  65153. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65154. /**
  65155. * Scale the bone on the x, y and z axes (in local space)
  65156. * @param x The amount to scale the bone on the x axis
  65157. * @param y The amount to scale the bone on the y axis
  65158. * @param z The amount to scale the bone on the z axis
  65159. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65160. */
  65161. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65162. /**
  65163. * Set the bone scaling in local space
  65164. * @param scale defines the scaling vector
  65165. */
  65166. setScale(scale: Vector3): void;
  65167. /**
  65168. * Gets the current scaling in local space
  65169. * @returns the current scaling vector
  65170. */
  65171. getScale(): Vector3;
  65172. /**
  65173. * Gets the current scaling in local space and stores it in a target vector
  65174. * @param result defines the target vector
  65175. */
  65176. getScaleToRef(result: Vector3): void;
  65177. /**
  65178. * Set the yaw, pitch, and roll of the bone in local or world space
  65179. * @param yaw The rotation of the bone on the y axis
  65180. * @param pitch The rotation of the bone on the x axis
  65181. * @param roll The rotation of the bone on the z axis
  65182. * @param space The space that the axes of rotation are in
  65183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65184. */
  65185. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65186. /**
  65187. * Add a rotation to the bone on an axis in local or world space
  65188. * @param axis The axis to rotate the bone on
  65189. * @param amount The amount to rotate the bone
  65190. * @param space The space that the axis is in
  65191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65192. */
  65193. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65194. /**
  65195. * Set the rotation of the bone to a particular axis angle in local or world space
  65196. * @param axis The axis to rotate the bone on
  65197. * @param angle The angle that the bone should be rotated to
  65198. * @param space The space that the axis is in
  65199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65200. */
  65201. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65202. /**
  65203. * Set the euler rotation of the bone in local of world space
  65204. * @param rotation The euler rotation that the bone should be set to
  65205. * @param space The space that the rotation is in
  65206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65207. */
  65208. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65209. /**
  65210. * Set the quaternion rotation of the bone in local of world space
  65211. * @param quat The quaternion rotation that the bone should be set to
  65212. * @param space The space that the rotation is in
  65213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65214. */
  65215. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65216. /**
  65217. * Set the rotation matrix of the bone in local of world space
  65218. * @param rotMat The rotation matrix that the bone should be set to
  65219. * @param space The space that the rotation is in
  65220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65221. */
  65222. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65223. private _rotateWithMatrix;
  65224. private _getNegativeRotationToRef;
  65225. /**
  65226. * Get the position of the bone in local or world space
  65227. * @param space The space that the returned position is in
  65228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65229. * @returns The position of the bone
  65230. */
  65231. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65232. /**
  65233. * Copy the position of the bone to a vector3 in local or world space
  65234. * @param space The space that the returned position is in
  65235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65236. * @param result The vector3 to copy the position to
  65237. */
  65238. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65239. /**
  65240. * Get the absolute position of the bone (world space)
  65241. * @param mesh The mesh that this bone is attached to
  65242. * @returns The absolute position of the bone
  65243. */
  65244. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65245. /**
  65246. * Copy the absolute position of the bone (world space) to the result param
  65247. * @param mesh The mesh that this bone is attached to
  65248. * @param result The vector3 to copy the absolute position to
  65249. */
  65250. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65251. /**
  65252. * Compute the absolute transforms of this bone and its children
  65253. */
  65254. computeAbsoluteTransforms(): void;
  65255. /**
  65256. * Get the world direction from an axis that is in the local space of the bone
  65257. * @param localAxis The local direction that is used to compute the world direction
  65258. * @param mesh The mesh that this bone is attached to
  65259. * @returns The world direction
  65260. */
  65261. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65262. /**
  65263. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65264. * @param localAxis The local direction that is used to compute the world direction
  65265. * @param mesh The mesh that this bone is attached to
  65266. * @param result The vector3 that the world direction will be copied to
  65267. */
  65268. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65269. /**
  65270. * Get the euler rotation of the bone in local or world space
  65271. * @param space The space that the rotation should be in
  65272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65273. * @returns The euler rotation
  65274. */
  65275. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65276. /**
  65277. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65278. * @param space The space that the rotation should be in
  65279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65280. * @param result The vector3 that the rotation should be copied to
  65281. */
  65282. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65283. /**
  65284. * Get the quaternion rotation of the bone in either local or world space
  65285. * @param space The space that the rotation should be in
  65286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65287. * @returns The quaternion rotation
  65288. */
  65289. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65290. /**
  65291. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65292. * @param space The space that the rotation should be in
  65293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65294. * @param result The quaternion that the rotation should be copied to
  65295. */
  65296. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65297. /**
  65298. * Get the rotation matrix of the bone in local or world space
  65299. * @param space The space that the rotation should be in
  65300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65301. * @returns The rotation matrix
  65302. */
  65303. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65304. /**
  65305. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65306. * @param space The space that the rotation should be in
  65307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65308. * @param result The quaternion that the rotation should be copied to
  65309. */
  65310. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65311. /**
  65312. * Get the world position of a point that is in the local space of the bone
  65313. * @param position The local position
  65314. * @param mesh The mesh that this bone is attached to
  65315. * @returns The world position
  65316. */
  65317. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65318. /**
  65319. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65320. * @param position The local position
  65321. * @param mesh The mesh that this bone is attached to
  65322. * @param result The vector3 that the world position should be copied to
  65323. */
  65324. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65325. /**
  65326. * Get the local position of a point that is in world space
  65327. * @param position The world position
  65328. * @param mesh The mesh that this bone is attached to
  65329. * @returns The local position
  65330. */
  65331. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65332. /**
  65333. * Get the local position of a point that is in world space and copy it to the result param
  65334. * @param position The world position
  65335. * @param mesh The mesh that this bone is attached to
  65336. * @param result The vector3 that the local position should be copied to
  65337. */
  65338. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65339. }
  65340. }
  65341. declare module BABYLON {
  65342. /**
  65343. * 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.
  65344. * @see https://doc.babylonjs.com/how_to/transformnode
  65345. */
  65346. export class TransformNode extends Node {
  65347. /**
  65348. * Object will not rotate to face the camera
  65349. */
  65350. static BILLBOARDMODE_NONE: number;
  65351. /**
  65352. * Object will rotate to face the camera but only on the x axis
  65353. */
  65354. static BILLBOARDMODE_X: number;
  65355. /**
  65356. * Object will rotate to face the camera but only on the y axis
  65357. */
  65358. static BILLBOARDMODE_Y: number;
  65359. /**
  65360. * Object will rotate to face the camera but only on the z axis
  65361. */
  65362. static BILLBOARDMODE_Z: number;
  65363. /**
  65364. * Object will rotate to face the camera
  65365. */
  65366. static BILLBOARDMODE_ALL: number;
  65367. private _forward;
  65368. private _forwardInverted;
  65369. private _up;
  65370. private _right;
  65371. private _rightInverted;
  65372. private _position;
  65373. private _rotation;
  65374. private _rotationQuaternion;
  65375. protected _scaling: Vector3;
  65376. protected _isDirty: boolean;
  65377. private _transformToBoneReferal;
  65378. /**
  65379. * Set the billboard mode. Default is 0.
  65380. *
  65381. * | Value | Type | Description |
  65382. * | --- | --- | --- |
  65383. * | 0 | BILLBOARDMODE_NONE | |
  65384. * | 1 | BILLBOARDMODE_X | |
  65385. * | 2 | BILLBOARDMODE_Y | |
  65386. * | 4 | BILLBOARDMODE_Z | |
  65387. * | 7 | BILLBOARDMODE_ALL | |
  65388. *
  65389. */
  65390. billboardMode: number;
  65391. /**
  65392. * 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
  65393. */
  65394. scalingDeterminant: number;
  65395. /**
  65396. * Sets the distance of the object to max, often used by skybox
  65397. */
  65398. infiniteDistance: boolean;
  65399. /**
  65400. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65401. * By default the system will update normals to compensate
  65402. */
  65403. ignoreNonUniformScaling: boolean;
  65404. /** @hidden */
  65405. _poseMatrix: Matrix;
  65406. /** @hidden */
  65407. _localMatrix: Matrix;
  65408. private _absolutePosition;
  65409. private _pivotMatrix;
  65410. private _pivotMatrixInverse;
  65411. protected _postMultiplyPivotMatrix: boolean;
  65412. protected _isWorldMatrixFrozen: boolean;
  65413. /** @hidden */
  65414. _indexInSceneTransformNodesArray: number;
  65415. /**
  65416. * An event triggered after the world matrix is updated
  65417. */
  65418. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65419. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65420. /**
  65421. * Gets a string identifying the name of the class
  65422. * @returns "TransformNode" string
  65423. */
  65424. getClassName(): string;
  65425. /**
  65426. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65427. */
  65428. position: Vector3;
  65429. /**
  65430. * 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)).
  65431. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65432. */
  65433. rotation: Vector3;
  65434. /**
  65435. * 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)).
  65436. */
  65437. scaling: Vector3;
  65438. /**
  65439. * 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).
  65440. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65441. */
  65442. rotationQuaternion: Nullable<Quaternion>;
  65443. /**
  65444. * The forward direction of that transform in world space.
  65445. */
  65446. readonly forward: Vector3;
  65447. /**
  65448. * The up direction of that transform in world space.
  65449. */
  65450. readonly up: Vector3;
  65451. /**
  65452. * The right direction of that transform in world space.
  65453. */
  65454. readonly right: Vector3;
  65455. /**
  65456. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65457. * @param matrix the matrix to copy the pose from
  65458. * @returns this TransformNode.
  65459. */
  65460. updatePoseMatrix(matrix: Matrix): TransformNode;
  65461. /**
  65462. * Returns the mesh Pose matrix.
  65463. * @returns the pose matrix
  65464. */
  65465. getPoseMatrix(): Matrix;
  65466. /** @hidden */
  65467. _isSynchronized(): boolean;
  65468. /** @hidden */
  65469. _initCache(): void;
  65470. /**
  65471. * Flag the transform node as dirty (Forcing it to update everything)
  65472. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65473. * @returns this transform node
  65474. */
  65475. markAsDirty(property: string): TransformNode;
  65476. /**
  65477. * Returns the current mesh absolute position.
  65478. * Returns a Vector3.
  65479. */
  65480. readonly absolutePosition: Vector3;
  65481. /**
  65482. * Sets a new matrix to apply before all other transformation
  65483. * @param matrix defines the transform matrix
  65484. * @returns the current TransformNode
  65485. */
  65486. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65487. /**
  65488. * Sets a new pivot matrix to the current node
  65489. * @param matrix defines the new pivot matrix to use
  65490. * @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
  65491. * @returns the current TransformNode
  65492. */
  65493. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65494. /**
  65495. * Returns the mesh pivot matrix.
  65496. * Default : Identity.
  65497. * @returns the matrix
  65498. */
  65499. getPivotMatrix(): Matrix;
  65500. /**
  65501. * Prevents the World matrix to be computed any longer.
  65502. * @returns the TransformNode.
  65503. */
  65504. freezeWorldMatrix(): TransformNode;
  65505. /**
  65506. * Allows back the World matrix computation.
  65507. * @returns the TransformNode.
  65508. */
  65509. unfreezeWorldMatrix(): this;
  65510. /**
  65511. * True if the World matrix has been frozen.
  65512. */
  65513. readonly isWorldMatrixFrozen: boolean;
  65514. /**
  65515. * Retuns the mesh absolute position in the World.
  65516. * @returns a Vector3.
  65517. */
  65518. getAbsolutePosition(): Vector3;
  65519. /**
  65520. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65521. * @param absolutePosition the absolute position to set
  65522. * @returns the TransformNode.
  65523. */
  65524. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65525. /**
  65526. * Sets the mesh position in its local space.
  65527. * @param vector3 the position to set in localspace
  65528. * @returns the TransformNode.
  65529. */
  65530. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65531. /**
  65532. * Returns the mesh position in the local space from the current World matrix values.
  65533. * @returns a new Vector3.
  65534. */
  65535. getPositionExpressedInLocalSpace(): Vector3;
  65536. /**
  65537. * Translates the mesh along the passed Vector3 in its local space.
  65538. * @param vector3 the distance to translate in localspace
  65539. * @returns the TransformNode.
  65540. */
  65541. locallyTranslate(vector3: Vector3): TransformNode;
  65542. private static _lookAtVectorCache;
  65543. /**
  65544. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65545. * @param targetPoint the position (must be in same space as current mesh) to look at
  65546. * @param yawCor optional yaw (y-axis) correction in radians
  65547. * @param pitchCor optional pitch (x-axis) correction in radians
  65548. * @param rollCor optional roll (z-axis) correction in radians
  65549. * @param space the choosen space of the target
  65550. * @returns the TransformNode.
  65551. */
  65552. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65553. /**
  65554. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65555. * This Vector3 is expressed in the World space.
  65556. * @param localAxis axis to rotate
  65557. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65558. */
  65559. getDirection(localAxis: Vector3): Vector3;
  65560. /**
  65561. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65562. * localAxis is expressed in the mesh local space.
  65563. * result is computed in the Wordl space from the mesh World matrix.
  65564. * @param localAxis axis to rotate
  65565. * @param result the resulting transformnode
  65566. * @returns this TransformNode.
  65567. */
  65568. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65569. /**
  65570. * Sets this transform node rotation to the given local axis.
  65571. * @param localAxis the axis in local space
  65572. * @param yawCor optional yaw (y-axis) correction in radians
  65573. * @param pitchCor optional pitch (x-axis) correction in radians
  65574. * @param rollCor optional roll (z-axis) correction in radians
  65575. * @returns this TransformNode
  65576. */
  65577. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65578. /**
  65579. * Sets a new pivot point to the current node
  65580. * @param point defines the new pivot point to use
  65581. * @param space defines if the point is in world or local space (local by default)
  65582. * @returns the current TransformNode
  65583. */
  65584. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65585. /**
  65586. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65587. * @returns the pivot point
  65588. */
  65589. getPivotPoint(): Vector3;
  65590. /**
  65591. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65592. * @param result the vector3 to store the result
  65593. * @returns this TransformNode.
  65594. */
  65595. getPivotPointToRef(result: Vector3): TransformNode;
  65596. /**
  65597. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65598. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65599. */
  65600. getAbsolutePivotPoint(): Vector3;
  65601. /**
  65602. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65603. * @param result vector3 to store the result
  65604. * @returns this TransformNode.
  65605. */
  65606. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65607. /**
  65608. * Defines the passed node as the parent of the current node.
  65609. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65610. * @param node the node ot set as the parent
  65611. * @returns this TransformNode.
  65612. */
  65613. setParent(node: Nullable<Node>): TransformNode;
  65614. private _nonUniformScaling;
  65615. /**
  65616. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65617. */
  65618. readonly nonUniformScaling: boolean;
  65619. /** @hidden */
  65620. _updateNonUniformScalingState(value: boolean): boolean;
  65621. /**
  65622. * Attach the current TransformNode to another TransformNode associated with a bone
  65623. * @param bone Bone affecting the TransformNode
  65624. * @param affectedTransformNode TransformNode associated with the bone
  65625. * @returns this object
  65626. */
  65627. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65628. /**
  65629. * Detach the transform node if its associated with a bone
  65630. * @returns this object
  65631. */
  65632. detachFromBone(): TransformNode;
  65633. private static _rotationAxisCache;
  65634. /**
  65635. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65636. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65637. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65638. * The passed axis is also normalized.
  65639. * @param axis the axis to rotate around
  65640. * @param amount the amount to rotate in radians
  65641. * @param space Space to rotate in (Default: local)
  65642. * @returns the TransformNode.
  65643. */
  65644. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65645. /**
  65646. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65647. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65648. * The passed axis is also normalized. .
  65649. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65650. * @param point the point to rotate around
  65651. * @param axis the axis to rotate around
  65652. * @param amount the amount to rotate in radians
  65653. * @returns the TransformNode
  65654. */
  65655. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65656. /**
  65657. * Translates the mesh along the axis vector for the passed distance in the given space.
  65658. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65659. * @param axis the axis to translate in
  65660. * @param distance the distance to translate
  65661. * @param space Space to rotate in (Default: local)
  65662. * @returns the TransformNode.
  65663. */
  65664. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65665. /**
  65666. * Adds a rotation step to the mesh current rotation.
  65667. * x, y, z are Euler angles expressed in radians.
  65668. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65669. * This means this rotation is made in the mesh local space only.
  65670. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65671. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65672. * ```javascript
  65673. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65674. * ```
  65675. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65676. * 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.
  65677. * @param x Rotation to add
  65678. * @param y Rotation to add
  65679. * @param z Rotation to add
  65680. * @returns the TransformNode.
  65681. */
  65682. addRotation(x: number, y: number, z: number): TransformNode;
  65683. /**
  65684. * Computes the world matrix of the node
  65685. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65686. * @returns the world matrix
  65687. */
  65688. computeWorldMatrix(force?: boolean): Matrix;
  65689. protected _afterComputeWorldMatrix(): void;
  65690. /**
  65691. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65692. * @param func callback function to add
  65693. *
  65694. * @returns the TransformNode.
  65695. */
  65696. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65697. /**
  65698. * Removes a registered callback function.
  65699. * @param func callback function to remove
  65700. * @returns the TransformNode.
  65701. */
  65702. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65703. /**
  65704. * Gets the position of the current mesh in camera space
  65705. * @param camera defines the camera to use
  65706. * @returns a position
  65707. */
  65708. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65709. /**
  65710. * Returns the distance from the mesh to the active camera
  65711. * @param camera defines the camera to use
  65712. * @returns the distance
  65713. */
  65714. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65715. /**
  65716. * Clone the current transform node
  65717. * @param name Name of the new clone
  65718. * @param newParent New parent for the clone
  65719. * @param doNotCloneChildren Do not clone children hierarchy
  65720. * @returns the new transform node
  65721. */
  65722. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65723. /**
  65724. * Serializes the objects information.
  65725. * @param currentSerializationObject defines the object to serialize in
  65726. * @returns the serialized object
  65727. */
  65728. serialize(currentSerializationObject?: any): any;
  65729. /**
  65730. * Returns a new TransformNode object parsed from the source provided.
  65731. * @param parsedTransformNode is the source.
  65732. * @param scene the scne the object belongs to
  65733. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65734. * @returns a new TransformNode object parsed from the source provided.
  65735. */
  65736. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65737. /**
  65738. * Get all child-transformNodes of this node
  65739. * @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
  65740. * @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
  65741. * @returns an array of TransformNode
  65742. */
  65743. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65744. /**
  65745. * Releases resources associated with this transform node.
  65746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65748. */
  65749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65750. }
  65751. }
  65752. declare module BABYLON {
  65753. /**
  65754. * Defines the types of pose enabled controllers that are supported
  65755. */
  65756. export enum PoseEnabledControllerType {
  65757. /**
  65758. * HTC Vive
  65759. */
  65760. VIVE = 0,
  65761. /**
  65762. * Oculus Rift
  65763. */
  65764. OCULUS = 1,
  65765. /**
  65766. * Windows mixed reality
  65767. */
  65768. WINDOWS = 2,
  65769. /**
  65770. * Samsung gear VR
  65771. */
  65772. GEAR_VR = 3,
  65773. /**
  65774. * Google Daydream
  65775. */
  65776. DAYDREAM = 4,
  65777. /**
  65778. * Generic
  65779. */
  65780. GENERIC = 5
  65781. }
  65782. /**
  65783. * Defines the MutableGamepadButton interface for the state of a gamepad button
  65784. */
  65785. export interface MutableGamepadButton {
  65786. /**
  65787. * Value of the button/trigger
  65788. */
  65789. value: number;
  65790. /**
  65791. * If the button/trigger is currently touched
  65792. */
  65793. touched: boolean;
  65794. /**
  65795. * If the button/trigger is currently pressed
  65796. */
  65797. pressed: boolean;
  65798. }
  65799. /**
  65800. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  65801. * @hidden
  65802. */
  65803. export interface ExtendedGamepadButton extends GamepadButton {
  65804. /**
  65805. * If the button/trigger is currently pressed
  65806. */
  65807. readonly pressed: boolean;
  65808. /**
  65809. * If the button/trigger is currently touched
  65810. */
  65811. readonly touched: boolean;
  65812. /**
  65813. * Value of the button/trigger
  65814. */
  65815. readonly value: number;
  65816. }
  65817. /** @hidden */
  65818. export interface _GamePadFactory {
  65819. /**
  65820. * Returns wether or not the current gamepad can be created for this type of controller.
  65821. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  65822. * @returns true if it can be created, otherwise false
  65823. */
  65824. canCreate(gamepadInfo: any): boolean;
  65825. /**
  65826. * Creates a new instance of the Gamepad.
  65827. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  65828. * @returns the new gamepad instance
  65829. */
  65830. create(gamepadInfo: any): Gamepad;
  65831. }
  65832. /**
  65833. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  65834. */
  65835. export class PoseEnabledControllerHelper {
  65836. /** @hidden */
  65837. static _ControllerFactories: _GamePadFactory[];
  65838. /** @hidden */
  65839. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  65840. /**
  65841. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  65842. * @param vrGamepad the gamepad to initialized
  65843. * @returns a vr controller of the type the gamepad identified as
  65844. */
  65845. static InitiateController(vrGamepad: any): Gamepad;
  65846. }
  65847. /**
  65848. * Defines the PoseEnabledController object that contains state of a vr capable controller
  65849. */
  65850. export class PoseEnabledController extends Gamepad implements PoseControlled {
  65851. private _deviceRoomPosition;
  65852. private _deviceRoomRotationQuaternion;
  65853. /**
  65854. * The device position in babylon space
  65855. */
  65856. devicePosition: Vector3;
  65857. /**
  65858. * The device rotation in babylon space
  65859. */
  65860. deviceRotationQuaternion: Quaternion;
  65861. /**
  65862. * The scale factor of the device in babylon space
  65863. */
  65864. deviceScaleFactor: number;
  65865. /**
  65866. * (Likely devicePosition should be used instead) The device position in its room space
  65867. */
  65868. position: Vector3;
  65869. /**
  65870. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  65871. */
  65872. rotationQuaternion: Quaternion;
  65873. /**
  65874. * The type of controller (Eg. Windows mixed reality)
  65875. */
  65876. controllerType: PoseEnabledControllerType;
  65877. protected _calculatedPosition: Vector3;
  65878. private _calculatedRotation;
  65879. /**
  65880. * The raw pose from the device
  65881. */
  65882. rawPose: DevicePose;
  65883. private _trackPosition;
  65884. private _maxRotationDistFromHeadset;
  65885. private _draggedRoomRotation;
  65886. /**
  65887. * @hidden
  65888. */
  65889. _disableTrackPosition(fixedPosition: Vector3): void;
  65890. /**
  65891. * Internal, the mesh attached to the controller
  65892. * @hidden
  65893. */
  65894. _mesh: Nullable<AbstractMesh>;
  65895. private _poseControlledCamera;
  65896. private _leftHandSystemQuaternion;
  65897. /**
  65898. * Internal, matrix used to convert room space to babylon space
  65899. * @hidden
  65900. */
  65901. _deviceToWorld: Matrix;
  65902. /**
  65903. * Node to be used when casting a ray from the controller
  65904. * @hidden
  65905. */
  65906. _pointingPoseNode: Nullable<TransformNode>;
  65907. /**
  65908. * Name of the child mesh that can be used to cast a ray from the controller
  65909. */
  65910. static readonly POINTING_POSE: string;
  65911. /**
  65912. * Creates a new PoseEnabledController from a gamepad
  65913. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  65914. */
  65915. constructor(browserGamepad: any);
  65916. private _workingMatrix;
  65917. /**
  65918. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  65919. */
  65920. update(): void;
  65921. /**
  65922. * Updates only the pose device and mesh without doing any button event checking
  65923. */
  65924. protected _updatePoseAndMesh(): void;
  65925. /**
  65926. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  65927. * @param poseData raw pose fromthe device
  65928. */
  65929. updateFromDevice(poseData: DevicePose): void;
  65930. /**
  65931. * @hidden
  65932. */
  65933. _meshAttachedObservable: Observable<AbstractMesh>;
  65934. /**
  65935. * Attaches a mesh to the controller
  65936. * @param mesh the mesh to be attached
  65937. */
  65938. attachToMesh(mesh: AbstractMesh): void;
  65939. /**
  65940. * Attaches the controllers mesh to a camera
  65941. * @param camera the camera the mesh should be attached to
  65942. */
  65943. attachToPoseControlledCamera(camera: TargetCamera): void;
  65944. /**
  65945. * Disposes of the controller
  65946. */
  65947. dispose(): void;
  65948. /**
  65949. * The mesh that is attached to the controller
  65950. */
  65951. readonly mesh: Nullable<AbstractMesh>;
  65952. /**
  65953. * Gets the ray of the controller in the direction the controller is pointing
  65954. * @param length the length the resulting ray should be
  65955. * @returns a ray in the direction the controller is pointing
  65956. */
  65957. getForwardRay(length?: number): Ray;
  65958. }
  65959. }
  65960. declare module BABYLON {
  65961. /**
  65962. * Defines the WebVRController object that represents controllers tracked in 3D space
  65963. */
  65964. export abstract class WebVRController extends PoseEnabledController {
  65965. /**
  65966. * Internal, the default controller model for the controller
  65967. */
  65968. protected _defaultModel: AbstractMesh;
  65969. /**
  65970. * Fired when the trigger state has changed
  65971. */
  65972. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  65973. /**
  65974. * Fired when the main button state has changed
  65975. */
  65976. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  65977. /**
  65978. * Fired when the secondary button state has changed
  65979. */
  65980. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  65981. /**
  65982. * Fired when the pad state has changed
  65983. */
  65984. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  65985. /**
  65986. * Fired when controllers stick values have changed
  65987. */
  65988. onPadValuesChangedObservable: Observable<StickValues>;
  65989. /**
  65990. * Array of button availible on the controller
  65991. */
  65992. protected _buttons: Array<MutableGamepadButton>;
  65993. private _onButtonStateChange;
  65994. /**
  65995. * Fired when a controller button's state has changed
  65996. * @param callback the callback containing the button that was modified
  65997. */
  65998. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  65999. /**
  66000. * X and Y axis corrisponding to the controllers joystick
  66001. */
  66002. pad: StickValues;
  66003. /**
  66004. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  66005. */
  66006. hand: string;
  66007. /**
  66008. * The default controller model for the controller
  66009. */
  66010. readonly defaultModel: AbstractMesh;
  66011. /**
  66012. * Creates a new WebVRController from a gamepad
  66013. * @param vrGamepad the gamepad that the WebVRController should be created from
  66014. */
  66015. constructor(vrGamepad: any);
  66016. /**
  66017. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  66018. */
  66019. update(): void;
  66020. /**
  66021. * Function to be called when a button is modified
  66022. */
  66023. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  66024. /**
  66025. * Loads a mesh and attaches it to the controller
  66026. * @param scene the scene the mesh should be added to
  66027. * @param meshLoaded callback for when the mesh has been loaded
  66028. */
  66029. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  66030. private _setButtonValue;
  66031. private _changes;
  66032. private _checkChanges;
  66033. /**
  66034. * Disposes of th webVRCOntroller
  66035. */
  66036. dispose(): void;
  66037. }
  66038. }
  66039. declare module BABYLON {
  66040. /**
  66041. * Interface describing all the common properties and methods a shadow light needs to implement.
  66042. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66043. * as well as binding the different shadow properties to the effects.
  66044. */
  66045. export interface IShadowLight extends Light {
  66046. /**
  66047. * The light id in the scene (used in scene.findLighById for instance)
  66048. */
  66049. id: string;
  66050. /**
  66051. * The position the shdow will be casted from.
  66052. */
  66053. position: Vector3;
  66054. /**
  66055. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66056. */
  66057. direction: Vector3;
  66058. /**
  66059. * The transformed position. Position of the light in world space taking parenting in account.
  66060. */
  66061. transformedPosition: Vector3;
  66062. /**
  66063. * The transformed direction. Direction of the light in world space taking parenting in account.
  66064. */
  66065. transformedDirection: Vector3;
  66066. /**
  66067. * The friendly name of the light in the scene.
  66068. */
  66069. name: string;
  66070. /**
  66071. * Defines the shadow projection clipping minimum z value.
  66072. */
  66073. shadowMinZ: number;
  66074. /**
  66075. * Defines the shadow projection clipping maximum z value.
  66076. */
  66077. shadowMaxZ: number;
  66078. /**
  66079. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66080. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66081. */
  66082. computeTransformedInformation(): boolean;
  66083. /**
  66084. * Gets the scene the light belongs to.
  66085. * @returns The scene
  66086. */
  66087. getScene(): Scene;
  66088. /**
  66089. * Callback defining a custom Projection Matrix Builder.
  66090. * This can be used to override the default projection matrix computation.
  66091. */
  66092. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66093. /**
  66094. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66095. * @param matrix The materix to updated with the projection information
  66096. * @param viewMatrix The transform matrix of the light
  66097. * @param renderList The list of mesh to render in the map
  66098. * @returns The current light
  66099. */
  66100. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66101. /**
  66102. * Gets the current depth scale used in ESM.
  66103. * @returns The scale
  66104. */
  66105. getDepthScale(): number;
  66106. /**
  66107. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66108. * @returns true if a cube texture needs to be use
  66109. */
  66110. needCube(): boolean;
  66111. /**
  66112. * Detects if the projection matrix requires to be recomputed this frame.
  66113. * @returns true if it requires to be recomputed otherwise, false.
  66114. */
  66115. needProjectionMatrixCompute(): boolean;
  66116. /**
  66117. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66118. */
  66119. forceProjectionMatrixCompute(): void;
  66120. /**
  66121. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66122. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66123. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66124. */
  66125. getShadowDirection(faceIndex?: number): Vector3;
  66126. /**
  66127. * Gets the minZ used for shadow according to both the scene and the light.
  66128. * @param activeCamera The camera we are returning the min for
  66129. * @returns the depth min z
  66130. */
  66131. getDepthMinZ(activeCamera: Camera): number;
  66132. /**
  66133. * Gets the maxZ used for shadow according to both the scene and the light.
  66134. * @param activeCamera The camera we are returning the max for
  66135. * @returns the depth max z
  66136. */
  66137. getDepthMaxZ(activeCamera: Camera): number;
  66138. }
  66139. /**
  66140. * Base implementation IShadowLight
  66141. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66142. */
  66143. export abstract class ShadowLight extends Light implements IShadowLight {
  66144. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66145. protected _position: Vector3;
  66146. protected _setPosition(value: Vector3): void;
  66147. /**
  66148. * Sets the position the shadow will be casted from. Also use as the light position for both
  66149. * point and spot lights.
  66150. */
  66151. /**
  66152. * Sets the position the shadow will be casted from. Also use as the light position for both
  66153. * point and spot lights.
  66154. */
  66155. position: Vector3;
  66156. protected _direction: Vector3;
  66157. protected _setDirection(value: Vector3): void;
  66158. /**
  66159. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66160. * Also use as the light direction on spot and directional lights.
  66161. */
  66162. /**
  66163. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66164. * Also use as the light direction on spot and directional lights.
  66165. */
  66166. direction: Vector3;
  66167. private _shadowMinZ;
  66168. /**
  66169. * Gets the shadow projection clipping minimum z value.
  66170. */
  66171. /**
  66172. * Sets the shadow projection clipping minimum z value.
  66173. */
  66174. shadowMinZ: number;
  66175. private _shadowMaxZ;
  66176. /**
  66177. * Sets the shadow projection clipping maximum z value.
  66178. */
  66179. /**
  66180. * Gets the shadow projection clipping maximum z value.
  66181. */
  66182. shadowMaxZ: number;
  66183. /**
  66184. * Callback defining a custom Projection Matrix Builder.
  66185. * This can be used to override the default projection matrix computation.
  66186. */
  66187. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66188. /**
  66189. * The transformed position. Position of the light in world space taking parenting in account.
  66190. */
  66191. transformedPosition: Vector3;
  66192. /**
  66193. * The transformed direction. Direction of the light in world space taking parenting in account.
  66194. */
  66195. transformedDirection: Vector3;
  66196. private _needProjectionMatrixCompute;
  66197. /**
  66198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66200. */
  66201. computeTransformedInformation(): boolean;
  66202. /**
  66203. * Return the depth scale used for the shadow map.
  66204. * @returns the depth scale.
  66205. */
  66206. getDepthScale(): number;
  66207. /**
  66208. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66209. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66210. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66211. */
  66212. getShadowDirection(faceIndex?: number): Vector3;
  66213. /**
  66214. * Returns the ShadowLight absolute position in the World.
  66215. * @returns the position vector in world space
  66216. */
  66217. getAbsolutePosition(): Vector3;
  66218. /**
  66219. * Sets the ShadowLight direction toward the passed target.
  66220. * @param target The point tot target in local space
  66221. * @returns the updated ShadowLight direction
  66222. */
  66223. setDirectionToTarget(target: Vector3): Vector3;
  66224. /**
  66225. * Returns the light rotation in euler definition.
  66226. * @returns the x y z rotation in local space.
  66227. */
  66228. getRotation(): Vector3;
  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. /** @hidden */
  66244. _initCache(): void;
  66245. /** @hidden */
  66246. _isSynchronized(): boolean;
  66247. /**
  66248. * Computes the world matrix of the node
  66249. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66250. * @returns the world matrix
  66251. */
  66252. computeWorldMatrix(force?: boolean): Matrix;
  66253. /**
  66254. * Gets the minZ used for shadow according to both the scene and the light.
  66255. * @param activeCamera The camera we are returning the min for
  66256. * @returns the depth min z
  66257. */
  66258. getDepthMinZ(activeCamera: Camera): number;
  66259. /**
  66260. * Gets the maxZ used for shadow according to both the scene and the light.
  66261. * @param activeCamera The camera we are returning the max for
  66262. * @returns the depth max z
  66263. */
  66264. getDepthMaxZ(activeCamera: Camera): number;
  66265. /**
  66266. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66267. * @param matrix The materix to updated with the projection information
  66268. * @param viewMatrix The transform matrix of the light
  66269. * @param renderList The list of mesh to render in the map
  66270. * @returns The current light
  66271. */
  66272. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66273. }
  66274. }
  66275. declare module BABYLON {
  66276. /**
  66277. * "Static Class" containing the most commonly used helper while dealing with material for
  66278. * rendering purpose.
  66279. *
  66280. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66281. *
  66282. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66283. */
  66284. export class MaterialHelper {
  66285. /**
  66286. * Bind the current view position to an effect.
  66287. * @param effect The effect to be bound
  66288. * @param scene The scene the eyes position is used from
  66289. */
  66290. static BindEyePosition(effect: Effect, scene: Scene): void;
  66291. /**
  66292. * Helps preparing the defines values about the UVs in used in the effect.
  66293. * UVs are shared as much as we can accross channels in the shaders.
  66294. * @param texture The texture we are preparing the UVs for
  66295. * @param defines The defines to update
  66296. * @param key The channel key "diffuse", "specular"... used in the shader
  66297. */
  66298. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66299. /**
  66300. * Binds a texture matrix value to its corrsponding uniform
  66301. * @param texture The texture to bind the matrix for
  66302. * @param uniformBuffer The uniform buffer receivin the data
  66303. * @param key The channel key "diffuse", "specular"... used in the shader
  66304. */
  66305. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66306. /**
  66307. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66308. * @param mesh defines the current mesh
  66309. * @param scene defines the current scene
  66310. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66311. * @param pointsCloud defines if point cloud rendering has to be turned on
  66312. * @param fogEnabled defines if fog has to be turned on
  66313. * @param alphaTest defines if alpha testing has to be turned on
  66314. * @param defines defines the current list of defines
  66315. */
  66316. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66317. /**
  66318. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66319. * @param scene defines the current scene
  66320. * @param engine defines the current engine
  66321. * @param defines specifies the list of active defines
  66322. * @param useInstances defines if instances have to be turned on
  66323. * @param useClipPlane defines if clip plane have to be turned on
  66324. */
  66325. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66326. /**
  66327. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66328. * @param mesh The mesh containing the geometry data we will draw
  66329. * @param defines The defines to update
  66330. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66331. * @param useBones Precise whether bones should be used or not (override mesh info)
  66332. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66333. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66334. * @returns false if defines are considered not dirty and have not been checked
  66335. */
  66336. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66337. /**
  66338. * Prepares the defines related to the light information passed in parameter
  66339. * @param scene The scene we are intending to draw
  66340. * @param mesh The mesh the effect is compiling for
  66341. * @param defines The defines to update
  66342. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66343. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66344. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66345. * @returns true if normals will be required for the rest of the effect
  66346. */
  66347. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66348. /**
  66349. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66350. * that won t be acctive due to defines being turned off.
  66351. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66352. * @param samplersList The samplers list
  66353. * @param defines The defines helping in the list generation
  66354. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66355. */
  66356. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66357. /**
  66358. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66359. * @param defines The defines to update while falling back
  66360. * @param fallbacks The authorized effect fallbacks
  66361. * @param maxSimultaneousLights The maximum number of lights allowed
  66362. * @param rank the current rank of the Effect
  66363. * @returns The newly affected rank
  66364. */
  66365. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66366. /**
  66367. * Prepares the list of attributes required for morph targets according to the effect defines.
  66368. * @param attribs The current list of supported attribs
  66369. * @param mesh The mesh to prepare the morph targets attributes for
  66370. * @param defines The current Defines of the effect
  66371. */
  66372. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66373. /**
  66374. * Prepares the list of attributes required for bones according to the effect defines.
  66375. * @param attribs The current list of supported attribs
  66376. * @param mesh The mesh to prepare the bones attributes for
  66377. * @param defines The current Defines of the effect
  66378. * @param fallbacks The current efffect fallback strategy
  66379. */
  66380. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66381. /**
  66382. * Prepares the list of attributes required for instances according to the effect defines.
  66383. * @param attribs The current list of supported attribs
  66384. * @param defines The current Defines of the effect
  66385. */
  66386. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66387. /**
  66388. * Binds the light shadow information to the effect for the given mesh.
  66389. * @param light The light containing the generator
  66390. * @param scene The scene the lights belongs to
  66391. * @param mesh The mesh we are binding the information to render
  66392. * @param lightIndex The light index in the effect used to render the mesh
  66393. * @param effect The effect we are binding the data to
  66394. */
  66395. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66396. /**
  66397. * Binds the light information to the effect.
  66398. * @param light The light containing the generator
  66399. * @param effect The effect we are binding the data to
  66400. * @param lightIndex The light index in the effect used to render
  66401. */
  66402. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66403. /**
  66404. * Binds the lights information from the scene to the effect for the given mesh.
  66405. * @param scene The scene the lights belongs to
  66406. * @param mesh The mesh we are binding the information to render
  66407. * @param effect The effect we are binding the data to
  66408. * @param defines The generated defines for the effect
  66409. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66410. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66411. */
  66412. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66413. private static _tempFogColor;
  66414. /**
  66415. * Binds the fog information from the scene to the effect for the given mesh.
  66416. * @param scene The scene the lights belongs to
  66417. * @param mesh The mesh we are binding the information to render
  66418. * @param effect The effect we are binding the data to
  66419. * @param linearSpace Defines if the fog effect is applied in linear space
  66420. */
  66421. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66422. /**
  66423. * Binds the bones information from the mesh to the effect.
  66424. * @param mesh The mesh we are binding the information to render
  66425. * @param effect The effect we are binding the data to
  66426. */
  66427. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66428. /**
  66429. * Binds the morph targets information from the mesh to the effect.
  66430. * @param abstractMesh The mesh we are binding the information to render
  66431. * @param effect The effect we are binding the data to
  66432. */
  66433. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66434. /**
  66435. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66436. * @param defines The generated defines used in the effect
  66437. * @param effect The effect we are binding the data to
  66438. * @param scene The scene we are willing to render with logarithmic scale for
  66439. */
  66440. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66441. /**
  66442. * Binds the clip plane information from the scene to the effect.
  66443. * @param scene The scene the clip plane information are extracted from
  66444. * @param effect The effect we are binding the data to
  66445. */
  66446. static BindClipPlane(effect: Effect, scene: Scene): void;
  66447. }
  66448. }
  66449. declare module BABYLON {
  66450. /** @hidden */
  66451. export var shadowMapPixelShader: {
  66452. name: string;
  66453. shader: string;
  66454. };
  66455. }
  66456. declare module BABYLON {
  66457. /** @hidden */
  66458. export var bonesDeclaration: {
  66459. name: string;
  66460. shader: string;
  66461. };
  66462. }
  66463. declare module BABYLON {
  66464. /** @hidden */
  66465. export var morphTargetsVertexGlobalDeclaration: {
  66466. name: string;
  66467. shader: string;
  66468. };
  66469. }
  66470. declare module BABYLON {
  66471. /** @hidden */
  66472. export var morphTargetsVertexDeclaration: {
  66473. name: string;
  66474. shader: string;
  66475. };
  66476. }
  66477. declare module BABYLON {
  66478. /** @hidden */
  66479. export var instancesDeclaration: {
  66480. name: string;
  66481. shader: string;
  66482. };
  66483. }
  66484. declare module BABYLON {
  66485. /** @hidden */
  66486. export var helperFunctions: {
  66487. name: string;
  66488. shader: string;
  66489. };
  66490. }
  66491. declare module BABYLON {
  66492. /** @hidden */
  66493. export var morphTargetsVertex: {
  66494. name: string;
  66495. shader: string;
  66496. };
  66497. }
  66498. declare module BABYLON {
  66499. /** @hidden */
  66500. export var instancesVertex: {
  66501. name: string;
  66502. shader: string;
  66503. };
  66504. }
  66505. declare module BABYLON {
  66506. /** @hidden */
  66507. export var bonesVertex: {
  66508. name: string;
  66509. shader: string;
  66510. };
  66511. }
  66512. declare module BABYLON {
  66513. /** @hidden */
  66514. export var shadowMapVertexShader: {
  66515. name: string;
  66516. shader: string;
  66517. };
  66518. }
  66519. declare module BABYLON {
  66520. /** @hidden */
  66521. export var depthBoxBlurPixelShader: {
  66522. name: string;
  66523. shader: string;
  66524. };
  66525. }
  66526. declare module BABYLON {
  66527. /**
  66528. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66529. */
  66530. export interface ICustomShaderOptions {
  66531. /**
  66532. * Gets or sets the custom shader name to use
  66533. */
  66534. shaderName: string;
  66535. /**
  66536. * The list of attribute names used in the shader
  66537. */
  66538. attributes?: string[];
  66539. /**
  66540. * The list of unifrom names used in the shader
  66541. */
  66542. uniforms?: string[];
  66543. /**
  66544. * The list of sampler names used in the shader
  66545. */
  66546. samplers?: string[];
  66547. /**
  66548. * The list of defines used in the shader
  66549. */
  66550. defines?: string[];
  66551. }
  66552. /**
  66553. * Interface to implement to create a shadow generator compatible with BJS.
  66554. */
  66555. export interface IShadowGenerator {
  66556. /**
  66557. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66558. * @returns The render target texture if present otherwise, null
  66559. */
  66560. getShadowMap(): Nullable<RenderTargetTexture>;
  66561. /**
  66562. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66563. * @returns The render target texture if the shadow map is present otherwise, null
  66564. */
  66565. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66566. /**
  66567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66568. * @param subMesh The submesh we want to render in the shadow map
  66569. * @param useInstances Defines wether will draw in the map using instances
  66570. * @returns true if ready otherwise, false
  66571. */
  66572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66573. /**
  66574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66575. * @param defines Defines of the material we want to update
  66576. * @param lightIndex Index of the light in the enabled light list of the material
  66577. */
  66578. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66579. /**
  66580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66581. * defined in the generator but impacting the effect).
  66582. * It implies the unifroms available on the materials are the standard BJS ones.
  66583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66584. * @param effect The effect we are binfing the information for
  66585. */
  66586. bindShadowLight(lightIndex: string, effect: Effect): void;
  66587. /**
  66588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66589. * (eq to shadow prjection matrix * light transform matrix)
  66590. * @returns The transform matrix used to create the shadow map
  66591. */
  66592. getTransformMatrix(): Matrix;
  66593. /**
  66594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66595. * Cube and 2D textures for instance.
  66596. */
  66597. recreateShadowMap(): void;
  66598. /**
  66599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66600. * @param onCompiled Callback triggered at the and of the effects compilation
  66601. * @param options Sets of optional options forcing the compilation with different modes
  66602. */
  66603. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66604. useInstances: boolean;
  66605. }>): void;
  66606. /**
  66607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66608. * @param options Sets of optional options forcing the compilation with different modes
  66609. * @returns A promise that resolves when the compilation completes
  66610. */
  66611. forceCompilationAsync(options?: Partial<{
  66612. useInstances: boolean;
  66613. }>): Promise<void>;
  66614. /**
  66615. * Serializes the shadow generator setup to a json object.
  66616. * @returns The serialized JSON object
  66617. */
  66618. serialize(): any;
  66619. /**
  66620. * Disposes the Shadow map and related Textures and effects.
  66621. */
  66622. dispose(): void;
  66623. }
  66624. /**
  66625. * Default implementation IShadowGenerator.
  66626. * This is the main object responsible of generating shadows in the framework.
  66627. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66628. */
  66629. export class ShadowGenerator implements IShadowGenerator {
  66630. /**
  66631. * Shadow generator mode None: no filtering applied.
  66632. */
  66633. static readonly FILTER_NONE: number;
  66634. /**
  66635. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66636. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66637. */
  66638. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66639. /**
  66640. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66641. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66642. */
  66643. static readonly FILTER_POISSONSAMPLING: number;
  66644. /**
  66645. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66646. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66647. */
  66648. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66649. /**
  66650. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66651. * edge artifacts on steep falloff.
  66652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66653. */
  66654. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66655. /**
  66656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66657. * edge artifacts on steep falloff.
  66658. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66659. */
  66660. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66661. /**
  66662. * Shadow generator mode PCF: Percentage Closer Filtering
  66663. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66664. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66665. */
  66666. static readonly FILTER_PCF: number;
  66667. /**
  66668. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66669. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66670. * Contact Hardening
  66671. */
  66672. static readonly FILTER_PCSS: number;
  66673. /**
  66674. * Reserved for PCF and PCSS
  66675. * Highest Quality.
  66676. *
  66677. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66678. *
  66679. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66680. */
  66681. static readonly QUALITY_HIGH: number;
  66682. /**
  66683. * Reserved for PCF and PCSS
  66684. * Good tradeoff for quality/perf cross devices
  66685. *
  66686. * Execute PCF on a 3*3 kernel.
  66687. *
  66688. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66689. */
  66690. static readonly QUALITY_MEDIUM: number;
  66691. /**
  66692. * Reserved for PCF and PCSS
  66693. * The lowest quality but the fastest.
  66694. *
  66695. * Execute PCF on a 1*1 kernel.
  66696. *
  66697. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66698. */
  66699. static readonly QUALITY_LOW: number;
  66700. /** Gets or sets the custom shader name to use */
  66701. customShaderOptions: ICustomShaderOptions;
  66702. /**
  66703. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66704. */
  66705. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66706. private _bias;
  66707. /**
  66708. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66709. */
  66710. /**
  66711. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66712. */
  66713. bias: number;
  66714. private _normalBias;
  66715. /**
  66716. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66717. */
  66718. /**
  66719. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66720. */
  66721. normalBias: number;
  66722. private _blurBoxOffset;
  66723. /**
  66724. * Gets the blur box offset: offset applied during the blur pass.
  66725. * Only useful if useKernelBlur = false
  66726. */
  66727. /**
  66728. * Sets the blur box offset: offset applied during the blur pass.
  66729. * Only useful if useKernelBlur = false
  66730. */
  66731. blurBoxOffset: number;
  66732. private _blurScale;
  66733. /**
  66734. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66735. * 2 means half of the size.
  66736. */
  66737. /**
  66738. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66739. * 2 means half of the size.
  66740. */
  66741. blurScale: number;
  66742. private _blurKernel;
  66743. /**
  66744. * Gets the blur kernel: kernel size of the blur pass.
  66745. * Only useful if useKernelBlur = true
  66746. */
  66747. /**
  66748. * Sets the blur kernel: kernel size of the blur pass.
  66749. * Only useful if useKernelBlur = true
  66750. */
  66751. blurKernel: number;
  66752. private _useKernelBlur;
  66753. /**
  66754. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66755. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66756. */
  66757. /**
  66758. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66759. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66760. */
  66761. useKernelBlur: boolean;
  66762. private _depthScale;
  66763. /**
  66764. * Gets the depth scale used in ESM mode.
  66765. */
  66766. /**
  66767. * Sets the depth scale used in ESM mode.
  66768. * This can override the scale stored on the light.
  66769. */
  66770. depthScale: number;
  66771. private _filter;
  66772. /**
  66773. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66774. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66775. */
  66776. /**
  66777. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66778. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66779. */
  66780. filter: number;
  66781. /**
  66782. * Gets if the current filter is set to Poisson Sampling.
  66783. */
  66784. /**
  66785. * Sets the current filter to Poisson Sampling.
  66786. */
  66787. usePoissonSampling: boolean;
  66788. /**
  66789. * Gets if the current filter is set to ESM.
  66790. */
  66791. /**
  66792. * Sets the current filter is to ESM.
  66793. */
  66794. useExponentialShadowMap: boolean;
  66795. /**
  66796. * Gets if the current filter is set to filtered ESM.
  66797. */
  66798. /**
  66799. * Gets if the current filter is set to filtered ESM.
  66800. */
  66801. useBlurExponentialShadowMap: boolean;
  66802. /**
  66803. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66804. * exponential to prevent steep falloff artifacts).
  66805. */
  66806. /**
  66807. * Sets the current filter to "close ESM" (using the inverse of the
  66808. * exponential to prevent steep falloff artifacts).
  66809. */
  66810. useCloseExponentialShadowMap: boolean;
  66811. /**
  66812. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66813. * exponential to prevent steep falloff artifacts).
  66814. */
  66815. /**
  66816. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66817. * exponential to prevent steep falloff artifacts).
  66818. */
  66819. useBlurCloseExponentialShadowMap: boolean;
  66820. /**
  66821. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66822. */
  66823. /**
  66824. * Sets the current filter to "PCF" (percentage closer filtering).
  66825. */
  66826. usePercentageCloserFiltering: boolean;
  66827. private _filteringQuality;
  66828. /**
  66829. * Gets the PCF or PCSS Quality.
  66830. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66831. */
  66832. /**
  66833. * Sets the PCF or PCSS Quality.
  66834. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66835. */
  66836. filteringQuality: number;
  66837. /**
  66838. * Gets if the current filter is set to "PCSS" (contact hardening).
  66839. */
  66840. /**
  66841. * Sets the current filter to "PCSS" (contact hardening).
  66842. */
  66843. useContactHardeningShadow: boolean;
  66844. private _contactHardeningLightSizeUVRatio;
  66845. /**
  66846. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66847. * Using a ratio helps keeping shape stability independently of the map size.
  66848. *
  66849. * It does not account for the light projection as it was having too much
  66850. * instability during the light setup or during light position changes.
  66851. *
  66852. * Only valid if useContactHardeningShadow is true.
  66853. */
  66854. /**
  66855. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66856. * Using a ratio helps keeping shape stability independently of the map size.
  66857. *
  66858. * It does not account for the light projection as it was having too much
  66859. * instability during the light setup or during light position changes.
  66860. *
  66861. * Only valid if useContactHardeningShadow is true.
  66862. */
  66863. contactHardeningLightSizeUVRatio: number;
  66864. private _darkness;
  66865. /**
  66866. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66867. * 0 means strongest and 1 would means no shadow.
  66868. * @returns the darkness.
  66869. */
  66870. getDarkness(): number;
  66871. /**
  66872. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66873. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66874. * @returns the shadow generator allowing fluent coding.
  66875. */
  66876. setDarkness(darkness: number): ShadowGenerator;
  66877. private _transparencyShadow;
  66878. /**
  66879. * Sets the ability to have transparent shadow (boolean).
  66880. * @param transparent True if transparent else False
  66881. * @returns the shadow generator allowing fluent coding
  66882. */
  66883. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66884. private _shadowMap;
  66885. private _shadowMap2;
  66886. /**
  66887. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66888. * @returns The render target texture if present otherwise, null
  66889. */
  66890. getShadowMap(): Nullable<RenderTargetTexture>;
  66891. /**
  66892. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66893. * @returns The render target texture if the shadow map is present otherwise, null
  66894. */
  66895. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66896. /**
  66897. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66898. * @param mesh Mesh to add
  66899. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66900. * @returns the Shadow Generator itself
  66901. */
  66902. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66903. /**
  66904. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66905. * @param mesh Mesh to remove
  66906. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66907. * @returns the Shadow Generator itself
  66908. */
  66909. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66910. /**
  66911. * Controls the extent to which the shadows fade out at the edge of the frustum
  66912. * Used only by directionals and spots
  66913. */
  66914. frustumEdgeFalloff: number;
  66915. private _light;
  66916. /**
  66917. * Returns the associated light object.
  66918. * @returns the light generating the shadow
  66919. */
  66920. getLight(): IShadowLight;
  66921. /**
  66922. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66923. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66924. * It might on the other hand introduce peter panning.
  66925. */
  66926. forceBackFacesOnly: boolean;
  66927. private _scene;
  66928. private _lightDirection;
  66929. private _effect;
  66930. private _viewMatrix;
  66931. private _projectionMatrix;
  66932. private _transformMatrix;
  66933. private _cachedPosition;
  66934. private _cachedDirection;
  66935. private _cachedDefines;
  66936. private _currentRenderID;
  66937. private _boxBlurPostprocess;
  66938. private _kernelBlurXPostprocess;
  66939. private _kernelBlurYPostprocess;
  66940. private _blurPostProcesses;
  66941. private _mapSize;
  66942. private _currentFaceIndex;
  66943. private _currentFaceIndexCache;
  66944. private _textureType;
  66945. private _defaultTextureMatrix;
  66946. /** @hidden */
  66947. static _SceneComponentInitialization: (scene: Scene) => void;
  66948. /**
  66949. * Creates a ShadowGenerator object.
  66950. * A ShadowGenerator is the required tool to use the shadows.
  66951. * Each light casting shadows needs to use its own ShadowGenerator.
  66952. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66953. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66954. * @param light The light object generating the shadows.
  66955. * @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.
  66956. */
  66957. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66958. private _initializeGenerator;
  66959. private _initializeShadowMap;
  66960. private _initializeBlurRTTAndPostProcesses;
  66961. private _renderForShadowMap;
  66962. private _renderSubMeshForShadowMap;
  66963. private _applyFilterValues;
  66964. /**
  66965. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66966. * @param onCompiled Callback triggered at the and of the effects compilation
  66967. * @param options Sets of optional options forcing the compilation with different modes
  66968. */
  66969. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66970. useInstances: boolean;
  66971. }>): void;
  66972. /**
  66973. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66974. * @param options Sets of optional options forcing the compilation with different modes
  66975. * @returns A promise that resolves when the compilation completes
  66976. */
  66977. forceCompilationAsync(options?: Partial<{
  66978. useInstances: boolean;
  66979. }>): Promise<void>;
  66980. /**
  66981. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66982. * @param subMesh The submesh we want to render in the shadow map
  66983. * @param useInstances Defines wether will draw in the map using instances
  66984. * @returns true if ready otherwise, false
  66985. */
  66986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66987. /**
  66988. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66989. * @param defines Defines of the material we want to update
  66990. * @param lightIndex Index of the light in the enabled light list of the material
  66991. */
  66992. prepareDefines(defines: any, lightIndex: number): void;
  66993. /**
  66994. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66995. * defined in the generator but impacting the effect).
  66996. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66997. * @param effect The effect we are binfing the information for
  66998. */
  66999. bindShadowLight(lightIndex: string, effect: Effect): void;
  67000. /**
  67001. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67002. * (eq to shadow prjection matrix * light transform matrix)
  67003. * @returns The transform matrix used to create the shadow map
  67004. */
  67005. getTransformMatrix(): Matrix;
  67006. /**
  67007. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67008. * Cube and 2D textures for instance.
  67009. */
  67010. recreateShadowMap(): void;
  67011. private _disposeBlurPostProcesses;
  67012. private _disposeRTTandPostProcesses;
  67013. /**
  67014. * Disposes the ShadowGenerator.
  67015. * Returns nothing.
  67016. */
  67017. dispose(): void;
  67018. /**
  67019. * Serializes the shadow generator setup to a json object.
  67020. * @returns The serialized JSON object
  67021. */
  67022. serialize(): any;
  67023. /**
  67024. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67025. * @param parsedShadowGenerator The JSON object to parse
  67026. * @param scene The scene to create the shadow map for
  67027. * @returns The parsed shadow generator
  67028. */
  67029. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /**
  67034. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67035. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67036. * 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.
  67037. */
  67038. export abstract class Light extends Node {
  67039. /**
  67040. * Falloff Default: light is falling off following the material specification:
  67041. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67042. */
  67043. static readonly FALLOFF_DEFAULT: number;
  67044. /**
  67045. * Falloff Physical: light is falling off following the inverse squared distance law.
  67046. */
  67047. static readonly FALLOFF_PHYSICAL: number;
  67048. /**
  67049. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67050. * to enhance interoperability with other engines.
  67051. */
  67052. static readonly FALLOFF_GLTF: number;
  67053. /**
  67054. * Falloff Standard: light is falling off like in the standard material
  67055. * to enhance interoperability with other materials.
  67056. */
  67057. static readonly FALLOFF_STANDARD: number;
  67058. /**
  67059. * If every light affecting the material is in this lightmapMode,
  67060. * material.lightmapTexture adds or multiplies
  67061. * (depends on material.useLightmapAsShadowmap)
  67062. * after every other light calculations.
  67063. */
  67064. static readonly LIGHTMAP_DEFAULT: number;
  67065. /**
  67066. * material.lightmapTexture as only diffuse lighting from this light
  67067. * adds only specular lighting from this light
  67068. * adds dynamic shadows
  67069. */
  67070. static readonly LIGHTMAP_SPECULAR: number;
  67071. /**
  67072. * material.lightmapTexture as only lighting
  67073. * no light calculation from this light
  67074. * only adds dynamic shadows from this light
  67075. */
  67076. static readonly LIGHTMAP_SHADOWSONLY: number;
  67077. /**
  67078. * Each light type uses the default quantity according to its type:
  67079. * point/spot lights use luminous intensity
  67080. * directional lights use illuminance
  67081. */
  67082. static readonly INTENSITYMODE_AUTOMATIC: number;
  67083. /**
  67084. * lumen (lm)
  67085. */
  67086. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67087. /**
  67088. * candela (lm/sr)
  67089. */
  67090. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67091. /**
  67092. * lux (lm/m^2)
  67093. */
  67094. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67095. /**
  67096. * nit (cd/m^2)
  67097. */
  67098. static readonly INTENSITYMODE_LUMINANCE: number;
  67099. /**
  67100. * Light type const id of the point light.
  67101. */
  67102. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67103. /**
  67104. * Light type const id of the directional light.
  67105. */
  67106. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67107. /**
  67108. * Light type const id of the spot light.
  67109. */
  67110. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67111. /**
  67112. * Light type const id of the hemispheric light.
  67113. */
  67114. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67115. /**
  67116. * Diffuse gives the basic color to an object.
  67117. */
  67118. diffuse: Color3;
  67119. /**
  67120. * Specular produces a highlight color on an object.
  67121. * Note: This is note affecting PBR materials.
  67122. */
  67123. specular: Color3;
  67124. /**
  67125. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67126. * falling off base on range or angle.
  67127. * This can be set to any values in Light.FALLOFF_x.
  67128. *
  67129. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67130. * other types of materials.
  67131. */
  67132. falloffType: number;
  67133. /**
  67134. * Strength of the light.
  67135. * Note: By default it is define in the framework own unit.
  67136. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67137. */
  67138. intensity: number;
  67139. private _range;
  67140. protected _inverseSquaredRange: number;
  67141. /**
  67142. * Defines how far from the source the light is impacting in scene units.
  67143. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67144. */
  67145. /**
  67146. * Defines how far from the source the light is impacting in scene units.
  67147. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67148. */
  67149. range: number;
  67150. /**
  67151. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67152. * of light.
  67153. */
  67154. private _photometricScale;
  67155. private _intensityMode;
  67156. /**
  67157. * Gets the photometric scale used to interpret the intensity.
  67158. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67159. */
  67160. /**
  67161. * Sets the photometric scale used to interpret the intensity.
  67162. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67163. */
  67164. intensityMode: number;
  67165. private _radius;
  67166. /**
  67167. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67168. */
  67169. /**
  67170. * sets the light radius used by PBR Materials to simulate soft area lights.
  67171. */
  67172. radius: number;
  67173. private _renderPriority;
  67174. /**
  67175. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67176. * exceeding the number allowed of the materials.
  67177. */
  67178. renderPriority: number;
  67179. private _shadowEnabled;
  67180. /**
  67181. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67182. * the current shadow generator.
  67183. */
  67184. /**
  67185. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67186. * the current shadow generator.
  67187. */
  67188. shadowEnabled: boolean;
  67189. private _includedOnlyMeshes;
  67190. /**
  67191. * Gets the only meshes impacted by this light.
  67192. */
  67193. /**
  67194. * Sets the only meshes impacted by this light.
  67195. */
  67196. includedOnlyMeshes: AbstractMesh[];
  67197. private _excludedMeshes;
  67198. /**
  67199. * Gets the meshes not impacted by this light.
  67200. */
  67201. /**
  67202. * Sets the meshes not impacted by this light.
  67203. */
  67204. excludedMeshes: AbstractMesh[];
  67205. private _excludeWithLayerMask;
  67206. /**
  67207. * Gets the layer id use to find what meshes are not impacted by the light.
  67208. * Inactive if 0
  67209. */
  67210. /**
  67211. * Sets the layer id use to find what meshes are not impacted by the light.
  67212. * Inactive if 0
  67213. */
  67214. excludeWithLayerMask: number;
  67215. private _includeOnlyWithLayerMask;
  67216. /**
  67217. * Gets the layer id use to find what meshes are impacted by the light.
  67218. * Inactive if 0
  67219. */
  67220. /**
  67221. * Sets the layer id use to find what meshes are impacted by the light.
  67222. * Inactive if 0
  67223. */
  67224. includeOnlyWithLayerMask: number;
  67225. private _lightmapMode;
  67226. /**
  67227. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67228. */
  67229. /**
  67230. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67231. */
  67232. lightmapMode: number;
  67233. /**
  67234. * Shadow generator associted to the light.
  67235. * @hidden Internal use only.
  67236. */
  67237. _shadowGenerator: Nullable<IShadowGenerator>;
  67238. /**
  67239. * @hidden Internal use only.
  67240. */
  67241. _excludedMeshesIds: string[];
  67242. /**
  67243. * @hidden Internal use only.
  67244. */
  67245. _includedOnlyMeshesIds: string[];
  67246. /**
  67247. * The current light unifom buffer.
  67248. * @hidden Internal use only.
  67249. */
  67250. _uniformBuffer: UniformBuffer;
  67251. /**
  67252. * Creates a Light object in the scene.
  67253. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67254. * @param name The firendly name of the light
  67255. * @param scene The scene the light belongs too
  67256. */
  67257. constructor(name: string, scene: Scene);
  67258. protected abstract _buildUniformLayout(): void;
  67259. /**
  67260. * Sets the passed Effect "effect" with the Light information.
  67261. * @param effect The effect to update
  67262. * @param lightIndex The index of the light in the effect to update
  67263. * @returns The light
  67264. */
  67265. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67266. /**
  67267. * Returns the string "Light".
  67268. * @returns the class name
  67269. */
  67270. getClassName(): string;
  67271. /** @hidden */
  67272. readonly _isLight: boolean;
  67273. /**
  67274. * Converts the light information to a readable string for debug purpose.
  67275. * @param fullDetails Supports for multiple levels of logging within scene loading
  67276. * @returns the human readable light info
  67277. */
  67278. toString(fullDetails?: boolean): string;
  67279. /** @hidden */
  67280. protected _syncParentEnabledState(): void;
  67281. /**
  67282. * Set the enabled state of this node.
  67283. * @param value - the new enabled state
  67284. */
  67285. setEnabled(value: boolean): void;
  67286. /**
  67287. * Returns the Light associated shadow generator if any.
  67288. * @return the associated shadow generator.
  67289. */
  67290. getShadowGenerator(): Nullable<IShadowGenerator>;
  67291. /**
  67292. * Returns a Vector3, the absolute light position in the World.
  67293. * @returns the world space position of the light
  67294. */
  67295. getAbsolutePosition(): Vector3;
  67296. /**
  67297. * Specifies if the light will affect the passed mesh.
  67298. * @param mesh The mesh to test against the light
  67299. * @return true the mesh is affected otherwise, false.
  67300. */
  67301. canAffectMesh(mesh: AbstractMesh): boolean;
  67302. /**
  67303. * Sort function to order lights for rendering.
  67304. * @param a First Light object to compare to second.
  67305. * @param b Second Light object to compare first.
  67306. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67307. */
  67308. static CompareLightsPriority(a: Light, b: Light): number;
  67309. /**
  67310. * Releases resources associated with this node.
  67311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67313. */
  67314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67315. /**
  67316. * Returns the light type ID (integer).
  67317. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67318. */
  67319. getTypeID(): number;
  67320. /**
  67321. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67322. * @returns the scaled intensity in intensity mode unit
  67323. */
  67324. getScaledIntensity(): number;
  67325. /**
  67326. * Returns a new Light object, named "name", from the current one.
  67327. * @param name The name of the cloned light
  67328. * @returns the new created light
  67329. */
  67330. clone(name: string): Nullable<Light>;
  67331. /**
  67332. * Serializes the current light into a Serialization object.
  67333. * @returns the serialized object.
  67334. */
  67335. serialize(): any;
  67336. /**
  67337. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67338. * This new light is named "name" and added to the passed scene.
  67339. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67340. * @param name The friendly name of the light
  67341. * @param scene The scene the new light will belong to
  67342. * @returns the constructor function
  67343. */
  67344. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67345. /**
  67346. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67347. * @param parsedLight The JSON representation of the light
  67348. * @param scene The scene to create the parsed light in
  67349. * @returns the created light after parsing
  67350. */
  67351. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67352. private _hookArrayForExcluded;
  67353. private _hookArrayForIncludedOnly;
  67354. private _resyncMeshes;
  67355. /**
  67356. * Forces the meshes to update their light related information in their rendering used effects
  67357. * @hidden Internal Use Only
  67358. */
  67359. _markMeshesAsLightDirty(): void;
  67360. /**
  67361. * Recomputes the cached photometric scale if needed.
  67362. */
  67363. private _computePhotometricScale;
  67364. /**
  67365. * Returns the Photometric Scale according to the light type and intensity mode.
  67366. */
  67367. private _getPhotometricScale;
  67368. /**
  67369. * Reorder the light in the scene according to their defined priority.
  67370. * @hidden Internal Use Only
  67371. */
  67372. _reorderLightsInScene(): void;
  67373. /**
  67374. * Prepares the list of defines specific to the light type.
  67375. * @param defines the list of defines
  67376. * @param lightIndex defines the index of the light for the effect
  67377. */
  67378. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67379. }
  67380. }
  67381. declare module BABYLON {
  67382. /**
  67383. * The HemisphericLight simulates the ambient environment light,
  67384. * so the passed direction is the light reflection direction, not the incoming direction.
  67385. */
  67386. export class HemisphericLight extends Light {
  67387. /**
  67388. * The groundColor is the light in the opposite direction to the one specified during creation.
  67389. * 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.
  67390. */
  67391. groundColor: Color3;
  67392. /**
  67393. * The light reflection direction, not the incoming direction.
  67394. */
  67395. direction: Vector3;
  67396. /**
  67397. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  67398. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  67399. * The HemisphericLight can't cast shadows.
  67400. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67401. * @param name The friendly name of the light
  67402. * @param direction The direction of the light reflection
  67403. * @param scene The scene the light belongs to
  67404. */
  67405. constructor(name: string, direction: Vector3, scene: Scene);
  67406. protected _buildUniformLayout(): void;
  67407. /**
  67408. * Returns the string "HemisphericLight".
  67409. * @return The class name
  67410. */
  67411. getClassName(): string;
  67412. /**
  67413. * Sets the HemisphericLight direction towards the passed target (Vector3).
  67414. * Returns the updated direction.
  67415. * @param target The target the direction should point to
  67416. * @return The computed direction
  67417. */
  67418. setDirectionToTarget(target: Vector3): Vector3;
  67419. /**
  67420. * Returns the shadow generator associated to the light.
  67421. * @returns Always null for hemispheric lights because it does not support shadows.
  67422. */
  67423. getShadowGenerator(): Nullable<IShadowGenerator>;
  67424. /**
  67425. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  67426. * @param effect The effect to update
  67427. * @param lightIndex The index of the light in the effect to update
  67428. * @returns The hemispheric light
  67429. */
  67430. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  67431. /**
  67432. * Computes the world matrix of the node
  67433. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67434. * @param useWasUpdatedFlag defines a reserved property
  67435. * @returns the world matrix
  67436. */
  67437. computeWorldMatrix(): Matrix;
  67438. /**
  67439. * Returns the integer 3.
  67440. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67441. */
  67442. getTypeID(): number;
  67443. /**
  67444. * Prepares the list of defines specific to the light type.
  67445. * @param defines the list of defines
  67446. * @param lightIndex defines the index of the light for the effect
  67447. */
  67448. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /**
  67453. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  67454. * IMPORTANT!! The data is right-hand data.
  67455. * @export
  67456. * @interface DevicePose
  67457. */
  67458. export interface DevicePose {
  67459. /**
  67460. * The position of the device, values in array are [x,y,z].
  67461. */
  67462. readonly position: Nullable<Float32Array>;
  67463. /**
  67464. * The linearVelocity of the device, values in array are [x,y,z].
  67465. */
  67466. readonly linearVelocity: Nullable<Float32Array>;
  67467. /**
  67468. * The linearAcceleration of the device, values in array are [x,y,z].
  67469. */
  67470. readonly linearAcceleration: Nullable<Float32Array>;
  67471. /**
  67472. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  67473. */
  67474. readonly orientation: Nullable<Float32Array>;
  67475. /**
  67476. * The angularVelocity of the device, values in array are [x,y,z].
  67477. */
  67478. readonly angularVelocity: Nullable<Float32Array>;
  67479. /**
  67480. * The angularAcceleration of the device, values in array are [x,y,z].
  67481. */
  67482. readonly angularAcceleration: Nullable<Float32Array>;
  67483. }
  67484. /**
  67485. * Interface representing a pose controlled object in Babylon.
  67486. * A pose controlled object has both regular pose values as well as pose values
  67487. * from an external device such as a VR head mounted display
  67488. */
  67489. export interface PoseControlled {
  67490. /**
  67491. * The position of the object in babylon space.
  67492. */
  67493. position: Vector3;
  67494. /**
  67495. * The rotation quaternion of the object in babylon space.
  67496. */
  67497. rotationQuaternion: Quaternion;
  67498. /**
  67499. * The position of the device in babylon space.
  67500. */
  67501. devicePosition?: Vector3;
  67502. /**
  67503. * The rotation quaternion of the device in babylon space.
  67504. */
  67505. deviceRotationQuaternion: Quaternion;
  67506. /**
  67507. * The raw pose coming from the device.
  67508. */
  67509. rawPose: Nullable<DevicePose>;
  67510. /**
  67511. * The scale of the device to be used when translating from device space to babylon space.
  67512. */
  67513. deviceScaleFactor: number;
  67514. /**
  67515. * Updates the poseControlled values based on the input device pose.
  67516. * @param poseData the pose data to update the object with
  67517. */
  67518. updateFromDevice(poseData: DevicePose): void;
  67519. }
  67520. /**
  67521. * Set of options to customize the webVRCamera
  67522. */
  67523. export interface WebVROptions {
  67524. /**
  67525. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  67526. */
  67527. trackPosition?: boolean;
  67528. /**
  67529. * Sets the scale of the vrDevice in babylon space. (default: 1)
  67530. */
  67531. positionScale?: number;
  67532. /**
  67533. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  67534. */
  67535. displayName?: string;
  67536. /**
  67537. * Should the native controller meshes be initialized. (default: true)
  67538. */
  67539. controllerMeshes?: boolean;
  67540. /**
  67541. * Creating a default HemiLight only on controllers. (default: true)
  67542. */
  67543. defaultLightingOnControllers?: boolean;
  67544. /**
  67545. * If you don't want to use the default VR button of the helper. (default: false)
  67546. */
  67547. useCustomVRButton?: boolean;
  67548. /**
  67549. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  67550. */
  67551. customVRButton?: HTMLButtonElement;
  67552. /**
  67553. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  67554. */
  67555. rayLength?: number;
  67556. /**
  67557. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  67558. */
  67559. defaultHeight?: number;
  67560. }
  67561. /**
  67562. * This represents a WebVR camera.
  67563. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  67564. * @example http://doc.babylonjs.com/how_to/webvr_camera
  67565. */
  67566. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  67567. private webVROptions;
  67568. /**
  67569. * @hidden
  67570. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  67571. */
  67572. _vrDevice: any;
  67573. /**
  67574. * The rawPose of the vrDevice.
  67575. */
  67576. rawPose: Nullable<DevicePose>;
  67577. private _onVREnabled;
  67578. private _specsVersion;
  67579. private _attached;
  67580. private _frameData;
  67581. protected _descendants: Array<Node>;
  67582. private _deviceRoomPosition;
  67583. /** @hidden */
  67584. _deviceRoomRotationQuaternion: Quaternion;
  67585. private _standingMatrix;
  67586. /**
  67587. * Represents device position in babylon space.
  67588. */
  67589. devicePosition: Vector3;
  67590. /**
  67591. * Represents device rotation in babylon space.
  67592. */
  67593. deviceRotationQuaternion: Quaternion;
  67594. /**
  67595. * The scale of the device to be used when translating from device space to babylon space.
  67596. */
  67597. deviceScaleFactor: number;
  67598. private _deviceToWorld;
  67599. private _worldToDevice;
  67600. /**
  67601. * References to the webVR controllers for the vrDevice.
  67602. */
  67603. controllers: Array<WebVRController>;
  67604. /**
  67605. * Emits an event when a controller is attached.
  67606. */
  67607. onControllersAttachedObservable: Observable<WebVRController[]>;
  67608. /**
  67609. * Emits an event when a controller's mesh has been loaded;
  67610. */
  67611. onControllerMeshLoadedObservable: Observable<WebVRController>;
  67612. /**
  67613. * Emits an event when the HMD's pose has been updated.
  67614. */
  67615. onPoseUpdatedFromDeviceObservable: Observable<any>;
  67616. private _poseSet;
  67617. /**
  67618. * If the rig cameras be used as parent instead of this camera.
  67619. */
  67620. rigParenting: boolean;
  67621. private _lightOnControllers;
  67622. private _defaultHeight?;
  67623. /**
  67624. * Instantiates a WebVRFreeCamera.
  67625. * @param name The name of the WebVRFreeCamera
  67626. * @param position The starting anchor position for the camera
  67627. * @param scene The scene the camera belongs to
  67628. * @param webVROptions a set of customizable options for the webVRCamera
  67629. */
  67630. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  67631. /**
  67632. * Gets the device distance from the ground in meters.
  67633. * @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.
  67634. */
  67635. deviceDistanceToRoomGround(): number;
  67636. /**
  67637. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  67638. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  67639. */
  67640. useStandingMatrix(callback?: (bool: boolean) => void): void;
  67641. /**
  67642. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  67643. * @returns A promise with a boolean set to if the standing matrix is supported.
  67644. */
  67645. useStandingMatrixAsync(): Promise<boolean>;
  67646. /**
  67647. * Disposes the camera
  67648. */
  67649. dispose(): void;
  67650. /**
  67651. * Gets a vrController by name.
  67652. * @param name The name of the controller to retreive
  67653. * @returns the controller matching the name specified or null if not found
  67654. */
  67655. getControllerByName(name: string): Nullable<WebVRController>;
  67656. private _leftController;
  67657. /**
  67658. * The controller corrisponding to the users left hand.
  67659. */
  67660. readonly leftController: Nullable<WebVRController>;
  67661. private _rightController;
  67662. /**
  67663. * The controller corrisponding to the users right hand.
  67664. */
  67665. readonly rightController: Nullable<WebVRController>;
  67666. /**
  67667. * Casts a ray forward from the vrCamera's gaze.
  67668. * @param length Length of the ray (default: 100)
  67669. * @returns the ray corrisponding to the gaze
  67670. */
  67671. getForwardRay(length?: number): Ray;
  67672. /**
  67673. * @hidden
  67674. * Updates the camera based on device's frame data
  67675. */
  67676. _checkInputs(): void;
  67677. /**
  67678. * Updates the poseControlled values based on the input device pose.
  67679. * @param poseData Pose coming from the device
  67680. */
  67681. updateFromDevice(poseData: DevicePose): void;
  67682. private _htmlElementAttached;
  67683. private _detachIfAttached;
  67684. /**
  67685. * WebVR's attach control will start broadcasting frames to the device.
  67686. * Note that in certain browsers (chrome for example) this function must be called
  67687. * within a user-interaction callback. Example:
  67688. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  67689. *
  67690. * @param element html element to attach the vrDevice to
  67691. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  67692. */
  67693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67694. /**
  67695. * Detaches the camera from the html element and disables VR
  67696. *
  67697. * @param element html element to detach from
  67698. */
  67699. detachControl(element: HTMLElement): void;
  67700. /**
  67701. * @returns the name of this class
  67702. */
  67703. getClassName(): string;
  67704. /**
  67705. * Calls resetPose on the vrDisplay
  67706. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  67707. */
  67708. resetToCurrentRotation(): void;
  67709. /**
  67710. * @hidden
  67711. * Updates the rig cameras (left and right eye)
  67712. */
  67713. _updateRigCameras(): void;
  67714. private _workingVector;
  67715. private _oneVector;
  67716. private _workingMatrix;
  67717. private updateCacheCalled;
  67718. private _correctPositionIfNotTrackPosition;
  67719. /**
  67720. * @hidden
  67721. * Updates the cached values of the camera
  67722. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  67723. */
  67724. _updateCache(ignoreParentClass?: boolean): void;
  67725. /**
  67726. * @hidden
  67727. * Get current device position in babylon world
  67728. */
  67729. _computeDevicePosition(): void;
  67730. /**
  67731. * Updates the current device position and rotation in the babylon world
  67732. */
  67733. update(): void;
  67734. /**
  67735. * @hidden
  67736. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  67737. * @returns an identity matrix
  67738. */
  67739. _getViewMatrix(): Matrix;
  67740. private _tmpMatrix;
  67741. /**
  67742. * This function is called by the two RIG cameras.
  67743. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  67744. * @hidden
  67745. */
  67746. _getWebVRViewMatrix(): Matrix;
  67747. /** @hidden */
  67748. _getWebVRProjectionMatrix(): Matrix;
  67749. private _onGamepadConnectedObserver;
  67750. private _onGamepadDisconnectedObserver;
  67751. private _updateCacheWhenTrackingDisabledObserver;
  67752. /**
  67753. * Initializes the controllers and their meshes
  67754. */
  67755. initControllers(): void;
  67756. }
  67757. }
  67758. declare module BABYLON {
  67759. /**
  67760. * Size options for a post process
  67761. */
  67762. export type PostProcessOptions = {
  67763. width: number;
  67764. height: number;
  67765. };
  67766. /**
  67767. * PostProcess can be used to apply a shader to a texture after it has been rendered
  67768. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67769. */
  67770. export class PostProcess {
  67771. /** Name of the PostProcess. */
  67772. name: string;
  67773. /**
  67774. * Width of the texture to apply the post process on
  67775. */
  67776. width: number;
  67777. /**
  67778. * Height of the texture to apply the post process on
  67779. */
  67780. height: number;
  67781. /**
  67782. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  67783. * @hidden
  67784. */
  67785. _outputTexture: Nullable<InternalTexture>;
  67786. /**
  67787. * Sampling mode used by the shader
  67788. * See https://doc.babylonjs.com/classes/3.1/texture
  67789. */
  67790. renderTargetSamplingMode: number;
  67791. /**
  67792. * Clear color to use when screen clearing
  67793. */
  67794. clearColor: Color4;
  67795. /**
  67796. * If the buffer needs to be cleared before applying the post process. (default: true)
  67797. * Should be set to false if shader will overwrite all previous pixels.
  67798. */
  67799. autoClear: boolean;
  67800. /**
  67801. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  67802. */
  67803. alphaMode: number;
  67804. /**
  67805. * Sets the setAlphaBlendConstants of the babylon engine
  67806. */
  67807. alphaConstants: Color4;
  67808. /**
  67809. * Animations to be used for the post processing
  67810. */
  67811. animations: Animation[];
  67812. /**
  67813. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  67814. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  67815. */
  67816. enablePixelPerfectMode: boolean;
  67817. /**
  67818. * Force the postprocess to be applied without taking in account viewport
  67819. */
  67820. forceFullscreenViewport: boolean;
  67821. /**
  67822. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  67823. *
  67824. * | Value | Type | Description |
  67825. * | ----- | ----------------------------------- | ----------- |
  67826. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  67827. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  67828. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  67829. *
  67830. */
  67831. scaleMode: number;
  67832. /**
  67833. * Force textures to be a power of two (default: false)
  67834. */
  67835. alwaysForcePOT: boolean;
  67836. private _samples;
  67837. /**
  67838. * Number of sample textures (default: 1)
  67839. */
  67840. samples: number;
  67841. /**
  67842. * Modify the scale of the post process to be the same as the viewport (default: false)
  67843. */
  67844. adaptScaleToCurrentViewport: boolean;
  67845. private _camera;
  67846. private _scene;
  67847. private _engine;
  67848. private _options;
  67849. private _reusable;
  67850. private _textureType;
  67851. /**
  67852. * Smart array of input and output textures for the post process.
  67853. * @hidden
  67854. */
  67855. _textures: SmartArray<InternalTexture>;
  67856. /**
  67857. * The index in _textures that corresponds to the output texture.
  67858. * @hidden
  67859. */
  67860. _currentRenderTextureInd: number;
  67861. private _effect;
  67862. private _samplers;
  67863. private _fragmentUrl;
  67864. private _vertexUrl;
  67865. private _parameters;
  67866. private _scaleRatio;
  67867. protected _indexParameters: any;
  67868. private _shareOutputWithPostProcess;
  67869. private _texelSize;
  67870. private _forcedOutputTexture;
  67871. /**
  67872. * Returns the fragment url or shader name used in the post process.
  67873. * @returns the fragment url or name in the shader store.
  67874. */
  67875. getEffectName(): string;
  67876. /**
  67877. * An event triggered when the postprocess is activated.
  67878. */
  67879. onActivateObservable: Observable<Camera>;
  67880. private _onActivateObserver;
  67881. /**
  67882. * A function that is added to the onActivateObservable
  67883. */
  67884. onActivate: Nullable<(camera: Camera) => void>;
  67885. /**
  67886. * An event triggered when the postprocess changes its size.
  67887. */
  67888. onSizeChangedObservable: Observable<PostProcess>;
  67889. private _onSizeChangedObserver;
  67890. /**
  67891. * A function that is added to the onSizeChangedObservable
  67892. */
  67893. onSizeChanged: (postProcess: PostProcess) => void;
  67894. /**
  67895. * An event triggered when the postprocess applies its effect.
  67896. */
  67897. onApplyObservable: Observable<Effect>;
  67898. private _onApplyObserver;
  67899. /**
  67900. * A function that is added to the onApplyObservable
  67901. */
  67902. onApply: (effect: Effect) => void;
  67903. /**
  67904. * An event triggered before rendering the postprocess
  67905. */
  67906. onBeforeRenderObservable: Observable<Effect>;
  67907. private _onBeforeRenderObserver;
  67908. /**
  67909. * A function that is added to the onBeforeRenderObservable
  67910. */
  67911. onBeforeRender: (effect: Effect) => void;
  67912. /**
  67913. * An event triggered after rendering the postprocess
  67914. */
  67915. onAfterRenderObservable: Observable<Effect>;
  67916. private _onAfterRenderObserver;
  67917. /**
  67918. * A function that is added to the onAfterRenderObservable
  67919. */
  67920. onAfterRender: (efect: Effect) => void;
  67921. /**
  67922. * 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
  67923. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  67924. */
  67925. inputTexture: InternalTexture;
  67926. /**
  67927. * Gets the camera which post process is applied to.
  67928. * @returns The camera the post process is applied to.
  67929. */
  67930. getCamera(): Camera;
  67931. /**
  67932. * Gets the texel size of the postprocess.
  67933. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  67934. */
  67935. readonly texelSize: Vector2;
  67936. /**
  67937. * Creates a new instance PostProcess
  67938. * @param name The name of the PostProcess.
  67939. * @param fragmentUrl The url of the fragment shader to be used.
  67940. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  67941. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  67942. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67943. * @param camera The camera to apply the render pass to.
  67944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67945. * @param engine The engine which the post process will be applied. (default: current engine)
  67946. * @param reusable If the post process can be reused on the same frame. (default: false)
  67947. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  67948. * @param textureType Type of textures used when performing the post process. (default: 0)
  67949. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  67950. * @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
  67951. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  67952. */
  67953. constructor(
  67954. /** Name of the PostProcess. */
  67955. 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);
  67956. /**
  67957. * Gets the engine which this post process belongs to.
  67958. * @returns The engine the post process was enabled with.
  67959. */
  67960. getEngine(): Engine;
  67961. /**
  67962. * The effect that is created when initializing the post process.
  67963. * @returns The created effect corrisponding the the postprocess.
  67964. */
  67965. getEffect(): Effect;
  67966. /**
  67967. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  67968. * @param postProcess The post process to share the output with.
  67969. * @returns This post process.
  67970. */
  67971. shareOutputWith(postProcess: PostProcess): PostProcess;
  67972. /**
  67973. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  67974. * This should be called if the post process that shares output with this post process is disabled/disposed.
  67975. */
  67976. useOwnOutput(): void;
  67977. /**
  67978. * Updates the effect with the current post process compile time values and recompiles the shader.
  67979. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67980. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67981. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67982. * @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
  67983. * @param onCompiled Called when the shader has been compiled.
  67984. * @param onError Called if there is an error when compiling a shader.
  67985. */
  67986. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67987. /**
  67988. * The post process is reusable if it can be used multiple times within one frame.
  67989. * @returns If the post process is reusable
  67990. */
  67991. isReusable(): boolean;
  67992. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  67993. markTextureDirty(): void;
  67994. /**
  67995. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  67996. * 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.
  67997. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  67998. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  67999. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  68000. * @returns The target texture that was bound to be written to.
  68001. */
  68002. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  68003. /**
  68004. * If the post process is supported.
  68005. */
  68006. readonly isSupported: boolean;
  68007. /**
  68008. * The aspect ratio of the output texture.
  68009. */
  68010. readonly aspectRatio: number;
  68011. /**
  68012. * Get a value indicating if the post-process is ready to be used
  68013. * @returns true if the post-process is ready (shader is compiled)
  68014. */
  68015. isReady(): boolean;
  68016. /**
  68017. * Binds all textures and uniforms to the shader, this will be run on every pass.
  68018. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  68019. */
  68020. apply(): Nullable<Effect>;
  68021. private _disposeTextures;
  68022. /**
  68023. * Disposes the post process.
  68024. * @param camera The camera to dispose the post process on.
  68025. */
  68026. dispose(camera?: Camera): void;
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /** @hidden */
  68031. export var kernelBlurVaryingDeclaration: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module BABYLON {
  68037. /** @hidden */
  68038. export var kernelBlurFragment: {
  68039. name: string;
  68040. shader: string;
  68041. };
  68042. }
  68043. declare module BABYLON {
  68044. /** @hidden */
  68045. export var kernelBlurFragment2: {
  68046. name: string;
  68047. shader: string;
  68048. };
  68049. }
  68050. declare module BABYLON {
  68051. /** @hidden */
  68052. export var kernelBlurPixelShader: {
  68053. name: string;
  68054. shader: string;
  68055. };
  68056. }
  68057. declare module BABYLON {
  68058. /** @hidden */
  68059. export var kernelBlurVertex: {
  68060. name: string;
  68061. shader: string;
  68062. };
  68063. }
  68064. declare module BABYLON {
  68065. /** @hidden */
  68066. export var kernelBlurVertexShader: {
  68067. name: string;
  68068. shader: string;
  68069. };
  68070. }
  68071. declare module BABYLON {
  68072. /**
  68073. * The Blur Post Process which blurs an image based on a kernel and direction.
  68074. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68075. */
  68076. export class BlurPostProcess extends PostProcess {
  68077. /** The direction in which to blur the image. */
  68078. direction: Vector2;
  68079. private blockCompilation;
  68080. protected _kernel: number;
  68081. protected _idealKernel: number;
  68082. protected _packedFloat: boolean;
  68083. private _staticDefines;
  68084. /**
  68085. * Sets the length in pixels of the blur sample region
  68086. */
  68087. /**
  68088. * Gets the length in pixels of the blur sample region
  68089. */
  68090. kernel: number;
  68091. /**
  68092. * Sets wether or not the blur needs to unpack/repack floats
  68093. */
  68094. /**
  68095. * Gets wether or not the blur is unpacking/repacking floats
  68096. */
  68097. packedFloat: boolean;
  68098. /**
  68099. * Creates a new instance BlurPostProcess
  68100. * @param name The name of the effect.
  68101. * @param direction The direction in which to blur the image.
  68102. * @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.
  68103. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68104. * @param camera The camera to apply the render pass to.
  68105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68106. * @param engine The engine which the post process will be applied. (default: current engine)
  68107. * @param reusable If the post process can be reused on the same frame. (default: false)
  68108. * @param textureType Type of textures used when performing the post process. (default: 0)
  68109. * @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)
  68110. */
  68111. constructor(name: string,
  68112. /** The direction in which to blur the image. */
  68113. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68114. /**
  68115. * Updates the effect with the current post process compile time values and recompiles the shader.
  68116. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68117. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68118. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68119. * @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
  68120. * @param onCompiled Called when the shader has been compiled.
  68121. * @param onError Called if there is an error when compiling a shader.
  68122. */
  68123. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68124. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68125. /**
  68126. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68127. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68128. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68129. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68130. * The gaps between physical kernels are compensated for in the weighting of the samples
  68131. * @param idealKernel Ideal blur kernel.
  68132. * @return Nearest best kernel.
  68133. */
  68134. protected _nearestBestKernel(idealKernel: number): number;
  68135. /**
  68136. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68137. * @param x The point on the Gaussian distribution to sample.
  68138. * @return the value of the Gaussian function at x.
  68139. */
  68140. protected _gaussianWeight(x: number): number;
  68141. /**
  68142. * Generates a string that can be used as a floating point number in GLSL.
  68143. * @param x Value to print.
  68144. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68145. * @return GLSL float string.
  68146. */
  68147. protected _glslFloat(x: number, decimalFigures?: number): string;
  68148. }
  68149. }
  68150. declare module BABYLON {
  68151. /**
  68152. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68153. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68154. * You can then easily use it as a reflectionTexture on a flat surface.
  68155. * In case the surface is not a plane, please consider relying on reflection probes.
  68156. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68157. */
  68158. export class MirrorTexture extends RenderTargetTexture {
  68159. private scene;
  68160. /**
  68161. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  68162. * 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.
  68163. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68164. */
  68165. mirrorPlane: Plane;
  68166. /**
  68167. * Define the blur ratio used to blur the reflection if needed.
  68168. */
  68169. blurRatio: number;
  68170. /**
  68171. * Define the adaptive blur kernel used to blur the reflection if needed.
  68172. * This will autocompute the closest best match for the `blurKernel`
  68173. */
  68174. adaptiveBlurKernel: number;
  68175. /**
  68176. * Define the blur kernel used to blur the reflection if needed.
  68177. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68178. */
  68179. blurKernel: number;
  68180. /**
  68181. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  68182. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68183. */
  68184. blurKernelX: number;
  68185. /**
  68186. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  68187. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68188. */
  68189. blurKernelY: number;
  68190. private _autoComputeBlurKernel;
  68191. protected _onRatioRescale(): void;
  68192. private _updateGammaSpace;
  68193. private _imageProcessingConfigChangeObserver;
  68194. private _transformMatrix;
  68195. private _mirrorMatrix;
  68196. private _savedViewMatrix;
  68197. private _blurX;
  68198. private _blurY;
  68199. private _adaptiveBlurKernel;
  68200. private _blurKernelX;
  68201. private _blurKernelY;
  68202. private _blurRatio;
  68203. /**
  68204. * Instantiates a Mirror Texture.
  68205. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68206. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68207. * You can then easily use it as a reflectionTexture on a flat surface.
  68208. * In case the surface is not a plane, please consider relying on reflection probes.
  68209. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68210. * @param name
  68211. * @param size
  68212. * @param scene
  68213. * @param generateMipMaps
  68214. * @param type
  68215. * @param samplingMode
  68216. * @param generateDepthBuffer
  68217. */
  68218. constructor(name: string, size: number | {
  68219. width: number;
  68220. height: number;
  68221. } | {
  68222. ratio: number;
  68223. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  68224. private _preparePostProcesses;
  68225. /**
  68226. * Clone the mirror texture.
  68227. * @returns the cloned texture
  68228. */
  68229. clone(): MirrorTexture;
  68230. /**
  68231. * Serialize the texture to a JSON representation you could use in Parse later on
  68232. * @returns the serialized JSON representation
  68233. */
  68234. serialize(): any;
  68235. /**
  68236. * Dispose the texture and release its associated resources.
  68237. */
  68238. dispose(): void;
  68239. }
  68240. }
  68241. declare module BABYLON {
  68242. /**
  68243. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  68244. * @see http://doc.babylonjs.com/babylon101/materials#texture
  68245. */
  68246. export class Texture extends BaseTexture {
  68247. /** @hidden */
  68248. static _AnimationParser: (jsonAnimation: any) => Animation;
  68249. /** @hidden */
  68250. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  68251. /** @hidden */
  68252. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  68253. /** @hidden */
  68254. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  68255. /** nearest is mag = nearest and min = nearest and mip = linear */
  68256. static readonly NEAREST_SAMPLINGMODE: number;
  68257. /** nearest is mag = nearest and min = nearest and mip = linear */
  68258. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  68259. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68260. static readonly BILINEAR_SAMPLINGMODE: number;
  68261. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68262. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  68263. /** Trilinear is mag = linear and min = linear and mip = linear */
  68264. static readonly TRILINEAR_SAMPLINGMODE: number;
  68265. /** Trilinear is mag = linear and min = linear and mip = linear */
  68266. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  68267. /** mag = nearest and min = nearest and mip = nearest */
  68268. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  68269. /** mag = nearest and min = linear and mip = nearest */
  68270. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  68271. /** mag = nearest and min = linear and mip = linear */
  68272. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  68273. /** mag = nearest and min = linear and mip = none */
  68274. static readonly NEAREST_LINEAR: number;
  68275. /** mag = nearest and min = nearest and mip = none */
  68276. static readonly NEAREST_NEAREST: number;
  68277. /** mag = linear and min = nearest and mip = nearest */
  68278. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  68279. /** mag = linear and min = nearest and mip = linear */
  68280. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  68281. /** mag = linear and min = linear and mip = none */
  68282. static readonly LINEAR_LINEAR: number;
  68283. /** mag = linear and min = nearest and mip = none */
  68284. static readonly LINEAR_NEAREST: number;
  68285. /** Explicit coordinates mode */
  68286. static readonly EXPLICIT_MODE: number;
  68287. /** Spherical coordinates mode */
  68288. static readonly SPHERICAL_MODE: number;
  68289. /** Planar coordinates mode */
  68290. static readonly PLANAR_MODE: number;
  68291. /** Cubic coordinates mode */
  68292. static readonly CUBIC_MODE: number;
  68293. /** Projection coordinates mode */
  68294. static readonly PROJECTION_MODE: number;
  68295. /** Inverse Cubic coordinates mode */
  68296. static readonly SKYBOX_MODE: number;
  68297. /** Inverse Cubic coordinates mode */
  68298. static readonly INVCUBIC_MODE: number;
  68299. /** Equirectangular coordinates mode */
  68300. static readonly EQUIRECTANGULAR_MODE: number;
  68301. /** Equirectangular Fixed coordinates mode */
  68302. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  68303. /** Equirectangular Fixed Mirrored coordinates mode */
  68304. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68305. /** Texture is not repeating outside of 0..1 UVs */
  68306. static readonly CLAMP_ADDRESSMODE: number;
  68307. /** Texture is repeating outside of 0..1 UVs */
  68308. static readonly WRAP_ADDRESSMODE: number;
  68309. /** Texture is repeating and mirrored */
  68310. static readonly MIRROR_ADDRESSMODE: number;
  68311. /**
  68312. * 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
  68313. */
  68314. static UseSerializedUrlIfAny: boolean;
  68315. /**
  68316. * Define the url of the texture.
  68317. */
  68318. url: Nullable<string>;
  68319. /**
  68320. * Define an offset on the texture to offset the u coordinates of the UVs
  68321. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68322. */
  68323. uOffset: number;
  68324. /**
  68325. * Define an offset on the texture to offset the v coordinates of the UVs
  68326. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68327. */
  68328. vOffset: number;
  68329. /**
  68330. * Define an offset on the texture to scale the u coordinates of the UVs
  68331. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68332. */
  68333. uScale: number;
  68334. /**
  68335. * Define an offset on the texture to scale the v coordinates of the UVs
  68336. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68337. */
  68338. vScale: number;
  68339. /**
  68340. * Define an offset on the texture to rotate around the u coordinates of the UVs
  68341. * @see http://doc.babylonjs.com/how_to/more_materials
  68342. */
  68343. uAng: number;
  68344. /**
  68345. * Define an offset on the texture to rotate around the v coordinates of the UVs
  68346. * @see http://doc.babylonjs.com/how_to/more_materials
  68347. */
  68348. vAng: number;
  68349. /**
  68350. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  68351. * @see http://doc.babylonjs.com/how_to/more_materials
  68352. */
  68353. wAng: number;
  68354. /**
  68355. * Defines the center of rotation (U)
  68356. */
  68357. uRotationCenter: number;
  68358. /**
  68359. * Defines the center of rotation (V)
  68360. */
  68361. vRotationCenter: number;
  68362. /**
  68363. * Defines the center of rotation (W)
  68364. */
  68365. wRotationCenter: number;
  68366. /**
  68367. * Are mip maps generated for this texture or not.
  68368. */
  68369. readonly noMipmap: boolean;
  68370. private _noMipmap;
  68371. /** @hidden */
  68372. _invertY: boolean;
  68373. private _rowGenerationMatrix;
  68374. private _cachedTextureMatrix;
  68375. private _projectionModeMatrix;
  68376. private _t0;
  68377. private _t1;
  68378. private _t2;
  68379. private _cachedUOffset;
  68380. private _cachedVOffset;
  68381. private _cachedUScale;
  68382. private _cachedVScale;
  68383. private _cachedUAng;
  68384. private _cachedVAng;
  68385. private _cachedWAng;
  68386. private _cachedProjectionMatrixId;
  68387. private _cachedCoordinatesMode;
  68388. /** @hidden */
  68389. protected _initialSamplingMode: number;
  68390. /** @hidden */
  68391. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68392. private _deleteBuffer;
  68393. protected _format: Nullable<number>;
  68394. private _delayedOnLoad;
  68395. private _delayedOnError;
  68396. /**
  68397. * Observable triggered once the texture has been loaded.
  68398. */
  68399. onLoadObservable: Observable<Texture>;
  68400. protected _isBlocking: boolean;
  68401. /**
  68402. * Is the texture preventing material to render while loading.
  68403. * If false, a default texture will be used instead of the loading one during the preparation step.
  68404. */
  68405. isBlocking: boolean;
  68406. /**
  68407. * Get the current sampling mode associated with the texture.
  68408. */
  68409. readonly samplingMode: number;
  68410. /**
  68411. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  68412. */
  68413. readonly invertY: boolean;
  68414. /**
  68415. * Instantiates a new texture.
  68416. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  68417. * @see http://doc.babylonjs.com/babylon101/materials#texture
  68418. * @param url define the url of the picture to load as a texture
  68419. * @param scene define the scene the texture will belong to
  68420. * @param noMipmap define if the texture will require mip maps or not
  68421. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68422. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68423. * @param onLoad define a callback triggered when the texture has been loaded
  68424. * @param onError define a callback triggered when an error occurred during the loading session
  68425. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68426. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68427. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68428. */
  68429. 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);
  68430. /**
  68431. * Update the url (and optional buffer) of this texture if url was null during construction.
  68432. * @param url the url of the texture
  68433. * @param buffer the buffer of the texture (defaults to null)
  68434. * @param onLoad callback called when the texture is loaded (defaults to null)
  68435. */
  68436. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  68437. /**
  68438. * Finish the loading sequence of a texture flagged as delayed load.
  68439. * @hidden
  68440. */
  68441. delayLoad(): void;
  68442. private _prepareRowForTextureGeneration;
  68443. /**
  68444. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  68445. * @returns the transform matrix of the texture.
  68446. */
  68447. getTextureMatrix(): Matrix;
  68448. /**
  68449. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  68450. * @returns The reflection texture transform
  68451. */
  68452. getReflectionTextureMatrix(): Matrix;
  68453. /**
  68454. * Clones the texture.
  68455. * @returns the cloned texture
  68456. */
  68457. clone(): Texture;
  68458. /**
  68459. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  68460. * @returns The JSON representation of the texture
  68461. */
  68462. serialize(): any;
  68463. /**
  68464. * Get the current class name of the texture useful for serialization or dynamic coding.
  68465. * @returns "Texture"
  68466. */
  68467. getClassName(): string;
  68468. /**
  68469. * Dispose the texture and release its associated resources.
  68470. */
  68471. dispose(): void;
  68472. /**
  68473. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  68474. * @param parsedTexture Define the JSON representation of the texture
  68475. * @param scene Define the scene the parsed texture should be instantiated in
  68476. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68477. * @returns The parsed texture if successful
  68478. */
  68479. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  68480. /**
  68481. * Creates a texture from its base 64 representation.
  68482. * @param data Define the base64 payload without the data: prefix
  68483. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68484. * @param scene Define the scene the texture should belong to
  68485. * @param noMipmap Forces the texture to not create mip map information if true
  68486. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68487. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68488. * @param onLoad define a callback triggered when the texture has been loaded
  68489. * @param onError define a callback triggered when an error occurred during the loading session
  68490. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68491. * @returns the created texture
  68492. */
  68493. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  68494. /**
  68495. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  68496. * @param data Define the base64 payload without the data: prefix
  68497. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68498. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68499. * @param scene Define the scene the texture should belong to
  68500. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68501. * @param noMipmap Forces the texture to not create mip map information if true
  68502. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68503. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68504. * @param onLoad define a callback triggered when the texture has been loaded
  68505. * @param onError define a callback triggered when an error occurred during the loading session
  68506. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68507. * @returns the created texture
  68508. */
  68509. 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;
  68510. }
  68511. }
  68512. declare module BABYLON {
  68513. /**
  68514. * PostProcessManager is used to manage one or more post processes or post process pipelines
  68515. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68516. */
  68517. export class PostProcessManager {
  68518. private _scene;
  68519. private _indexBuffer;
  68520. private _vertexBuffers;
  68521. /**
  68522. * Creates a new instance PostProcess
  68523. * @param scene The scene that the post process is associated with.
  68524. */
  68525. constructor(scene: Scene);
  68526. private _prepareBuffers;
  68527. private _buildIndexBuffer;
  68528. /**
  68529. * Rebuilds the vertex buffers of the manager.
  68530. * @hidden
  68531. */
  68532. _rebuild(): void;
  68533. /**
  68534. * Prepares a frame to be run through a post process.
  68535. * @param sourceTexture The input texture to the post procesess. (default: null)
  68536. * @param postProcesses An array of post processes to be run. (default: null)
  68537. * @returns True if the post processes were able to be run.
  68538. * @hidden
  68539. */
  68540. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  68541. /**
  68542. * Manually render a set of post processes to a texture.
  68543. * @param postProcesses An array of post processes to be run.
  68544. * @param targetTexture The target texture to render to.
  68545. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  68546. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  68547. * @param lodLevel defines which lod of the texture to render to
  68548. */
  68549. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  68550. /**
  68551. * Finalize the result of the output of the postprocesses.
  68552. * @param doNotPresent If true the result will not be displayed to the screen.
  68553. * @param targetTexture The target texture to render to.
  68554. * @param faceIndex The index of the face to bind the target texture to.
  68555. * @param postProcesses The array of post processes to render.
  68556. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  68557. * @hidden
  68558. */
  68559. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  68560. /**
  68561. * Disposes of the post process manager.
  68562. */
  68563. dispose(): void;
  68564. }
  68565. }
  68566. declare module BABYLON {
  68567. /**
  68568. * Groups all the scene component constants in one place to ease maintenance.
  68569. * @hidden
  68570. */
  68571. export class SceneComponentConstants {
  68572. static readonly NAME_EFFECTLAYER: string;
  68573. static readonly NAME_LAYER: string;
  68574. static readonly NAME_LENSFLARESYSTEM: string;
  68575. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68576. static readonly NAME_PARTICLESYSTEM: string;
  68577. static readonly NAME_GAMEPAD: string;
  68578. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68579. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68580. static readonly NAME_DEPTHRENDERER: string;
  68581. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68582. static readonly NAME_SPRITE: string;
  68583. static readonly NAME_OUTLINERENDERER: string;
  68584. static readonly NAME_PROCEDURALTEXTURE: string;
  68585. static readonly NAME_SHADOWGENERATOR: string;
  68586. static readonly NAME_OCTREE: string;
  68587. static readonly NAME_PHYSICSENGINE: string;
  68588. static readonly NAME_AUDIO: string;
  68589. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68590. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68591. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68592. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68593. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68594. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68595. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68596. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68597. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68598. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68599. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68600. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68601. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68602. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68603. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68604. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68605. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68606. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68607. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68608. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68609. static readonly STEP_AFTERRENDER_AUDIO: number;
  68610. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68611. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68612. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68613. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68614. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68615. static readonly STEP_POINTERMOVE_SPRITE: number;
  68616. static readonly STEP_POINTERDOWN_SPRITE: number;
  68617. static readonly STEP_POINTERUP_SPRITE: number;
  68618. }
  68619. /**
  68620. * This represents a scene component.
  68621. *
  68622. * This is used to decouple the dependency the scene is having on the different workloads like
  68623. * layers, post processes...
  68624. */
  68625. export interface ISceneComponent {
  68626. /**
  68627. * The name of the component. Each component must have a unique name.
  68628. */
  68629. name: string;
  68630. /**
  68631. * The scene the component belongs to.
  68632. */
  68633. scene: Scene;
  68634. /**
  68635. * Register the component to one instance of a scene.
  68636. */
  68637. register(): void;
  68638. /**
  68639. * Rebuilds the elements related to this component in case of
  68640. * context lost for instance.
  68641. */
  68642. rebuild(): void;
  68643. /**
  68644. * Disposes the component and the associated ressources.
  68645. */
  68646. dispose(): void;
  68647. }
  68648. /**
  68649. * This represents a SERIALIZABLE scene component.
  68650. *
  68651. * This extends Scene Component to add Serialization methods on top.
  68652. */
  68653. export interface ISceneSerializableComponent extends ISceneComponent {
  68654. /**
  68655. * Adds all the element from the container to the scene
  68656. * @param container the container holding the elements
  68657. */
  68658. addFromContainer(container: AbstractScene): void;
  68659. /**
  68660. * Removes all the elements in the container from the scene
  68661. * @param container contains the elements to remove
  68662. */
  68663. removeFromContainer(container: AbstractScene): void;
  68664. /**
  68665. * Serializes the component data to the specified json object
  68666. * @param serializationObject The object to serialize to
  68667. */
  68668. serialize(serializationObject: any): void;
  68669. }
  68670. /**
  68671. * Strong typing of a Mesh related stage step action
  68672. */
  68673. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68674. /**
  68675. * Strong typing of a Evaluate Sub Mesh related stage step action
  68676. */
  68677. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68678. /**
  68679. * Strong typing of a Active Mesh related stage step action
  68680. */
  68681. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68682. /**
  68683. * Strong typing of a Camera related stage step action
  68684. */
  68685. export type CameraStageAction = (camera: Camera) => void;
  68686. /**
  68687. * Strong typing of a Render Target related stage step action
  68688. */
  68689. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68690. /**
  68691. * Strong typing of a RenderingGroup related stage step action
  68692. */
  68693. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68694. /**
  68695. * Strong typing of a Mesh Render related stage step action
  68696. */
  68697. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68698. /**
  68699. * Strong typing of a simple stage step action
  68700. */
  68701. export type SimpleStageAction = () => void;
  68702. /**
  68703. * Strong typing of a render target action.
  68704. */
  68705. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68706. /**
  68707. * Strong typing of a pointer move action.
  68708. */
  68709. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68710. /**
  68711. * Strong typing of a pointer up/down action.
  68712. */
  68713. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68714. /**
  68715. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68716. * @hidden
  68717. */
  68718. export class Stage<T extends Function> extends Array<{
  68719. index: number;
  68720. component: ISceneComponent;
  68721. action: T;
  68722. }> {
  68723. /**
  68724. * Hide ctor from the rest of the world.
  68725. * @param items The items to add.
  68726. */
  68727. private constructor();
  68728. /**
  68729. * Creates a new Stage.
  68730. * @returns A new instance of a Stage
  68731. */
  68732. static Create<T extends Function>(): Stage<T>;
  68733. /**
  68734. * Registers a step in an ordered way in the targeted stage.
  68735. * @param index Defines the position to register the step in
  68736. * @param component Defines the component attached to the step
  68737. * @param action Defines the action to launch during the step
  68738. */
  68739. registerStep(index: number, component: ISceneComponent, action: T): void;
  68740. /**
  68741. * Clears all the steps from the stage.
  68742. */
  68743. clear(): void;
  68744. }
  68745. }
  68746. declare module BABYLON {
  68747. interface Scene {
  68748. /** @hidden */
  68749. _pointerOverSprite: Nullable<Sprite>;
  68750. /** @hidden */
  68751. _pickedDownSprite: Nullable<Sprite>;
  68752. /** @hidden */
  68753. _tempSpritePickingRay: Nullable<Ray>;
  68754. /**
  68755. * All of the sprite managers added to this scene
  68756. * @see http://doc.babylonjs.com/babylon101/sprites
  68757. */
  68758. spriteManagers: Array<ISpriteManager>;
  68759. /**
  68760. * An event triggered when sprites rendering is about to start
  68761. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68762. */
  68763. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68764. /**
  68765. * An event triggered when sprites rendering is done
  68766. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68767. */
  68768. onAfterSpritesRenderingObservable: Observable<Scene>;
  68769. /** @hidden */
  68770. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68771. /** Launch a ray to try to pick a sprite in the scene
  68772. * @param x position on screen
  68773. * @param y position on screen
  68774. * @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
  68775. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68776. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68777. * @returns a PickingInfo
  68778. */
  68779. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68780. /** Use the given ray to pick a sprite in the scene
  68781. * @param ray The ray (in world space) to use to pick meshes
  68782. * @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
  68783. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68784. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68785. * @returns a PickingInfo
  68786. */
  68787. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68788. /**
  68789. * Force the sprite under the pointer
  68790. * @param sprite defines the sprite to use
  68791. */
  68792. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68793. /**
  68794. * Gets the sprite under the pointer
  68795. * @returns a Sprite or null if no sprite is under the pointer
  68796. */
  68797. getPointerOverSprite(): Nullable<Sprite>;
  68798. }
  68799. /**
  68800. * Defines the sprite scene component responsible to manage sprites
  68801. * in a given scene.
  68802. */
  68803. export class SpriteSceneComponent implements ISceneComponent {
  68804. /**
  68805. * The component name helpfull to identify the component in the list of scene components.
  68806. */
  68807. readonly name: string;
  68808. /**
  68809. * The scene the component belongs to.
  68810. */
  68811. scene: Scene;
  68812. /** @hidden */
  68813. private _spritePredicate;
  68814. /**
  68815. * Creates a new instance of the component for the given scene
  68816. * @param scene Defines the scene to register the component in
  68817. */
  68818. constructor(scene: Scene);
  68819. /**
  68820. * Registers the component in a given scene
  68821. */
  68822. register(): void;
  68823. /**
  68824. * Rebuilds the elements related to this component in case of
  68825. * context lost for instance.
  68826. */
  68827. rebuild(): void;
  68828. /**
  68829. * Disposes the component and the associated ressources.
  68830. */
  68831. dispose(): void;
  68832. private _pickSpriteButKeepRay;
  68833. private _pointerMove;
  68834. private _pointerDown;
  68835. private _pointerUp;
  68836. }
  68837. }
  68838. declare module BABYLON {
  68839. /** @hidden */
  68840. export var fogFragmentDeclaration: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export var fogFragment: {
  68848. name: string;
  68849. shader: string;
  68850. };
  68851. }
  68852. declare module BABYLON {
  68853. /** @hidden */
  68854. export var spritesPixelShader: {
  68855. name: string;
  68856. shader: string;
  68857. };
  68858. }
  68859. declare module BABYLON {
  68860. /** @hidden */
  68861. export var fogVertexDeclaration: {
  68862. name: string;
  68863. shader: string;
  68864. };
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export var spritesVertexShader: {
  68869. name: string;
  68870. shader: string;
  68871. };
  68872. }
  68873. declare module BABYLON {
  68874. /**
  68875. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68876. */
  68877. export interface ISpriteManager extends IDisposable {
  68878. /**
  68879. * Restricts the camera to viewing objects with the same layerMask.
  68880. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68881. */
  68882. layerMask: number;
  68883. /**
  68884. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68885. */
  68886. isPickable: boolean;
  68887. /**
  68888. * Specifies the rendering group id for this mesh (0 by default)
  68889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68890. */
  68891. renderingGroupId: number;
  68892. /**
  68893. * Defines the list of sprites managed by the manager.
  68894. */
  68895. sprites: Array<Sprite>;
  68896. /**
  68897. * Tests the intersection of a sprite with a specific ray.
  68898. * @param ray The ray we are sending to test the collision
  68899. * @param camera The camera space we are sending rays in
  68900. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68901. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68902. * @returns picking info or null.
  68903. */
  68904. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68905. /**
  68906. * Renders the list of sprites on screen.
  68907. */
  68908. render(): void;
  68909. }
  68910. /**
  68911. * Class used to manage multiple sprites on the same spritesheet
  68912. * @see http://doc.babylonjs.com/babylon101/sprites
  68913. */
  68914. export class SpriteManager implements ISpriteManager {
  68915. /** defines the manager's name */
  68916. name: string;
  68917. /** Gets the list of sprites */
  68918. sprites: Sprite[];
  68919. /** Gets or sets the rendering group id (0 by default) */
  68920. renderingGroupId: number;
  68921. /** Gets or sets camera layer mask */
  68922. layerMask: number;
  68923. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68924. fogEnabled: boolean;
  68925. /** Gets or sets a boolean indicating if the sprites are pickable */
  68926. isPickable: boolean;
  68927. /** Defines the default width of a cell in the spritesheet */
  68928. cellWidth: number;
  68929. /** Defines the default height of a cell in the spritesheet */
  68930. cellHeight: number;
  68931. /**
  68932. * An event triggered when the manager is disposed.
  68933. */
  68934. onDisposeObservable: Observable<SpriteManager>;
  68935. private _onDisposeObserver;
  68936. /**
  68937. * Callback called when the manager is disposed
  68938. */
  68939. onDispose: () => void;
  68940. private _capacity;
  68941. private _spriteTexture;
  68942. private _epsilon;
  68943. private _scene;
  68944. private _vertexData;
  68945. private _buffer;
  68946. private _vertexBuffers;
  68947. private _indexBuffer;
  68948. private _effectBase;
  68949. private _effectFog;
  68950. /**
  68951. * Gets or sets the spritesheet texture
  68952. */
  68953. texture: Texture;
  68954. /**
  68955. * Creates a new sprite manager
  68956. * @param name defines the manager's name
  68957. * @param imgUrl defines the sprite sheet url
  68958. * @param capacity defines the maximum allowed number of sprites
  68959. * @param cellSize defines the size of a sprite cell
  68960. * @param scene defines the hosting scene
  68961. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68962. * @param samplingMode defines the smapling mode to use with spritesheet
  68963. */
  68964. constructor(
  68965. /** defines the manager's name */
  68966. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68967. private _appendSpriteVertex;
  68968. /**
  68969. * Intersects the sprites with a ray
  68970. * @param ray defines the ray to intersect with
  68971. * @param camera defines the current active camera
  68972. * @param predicate defines a predicate used to select candidate sprites
  68973. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68974. * @returns null if no hit or a PickingInfo
  68975. */
  68976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68977. /**
  68978. * Render all child sprites
  68979. */
  68980. render(): void;
  68981. /**
  68982. * Release associated resources
  68983. */
  68984. dispose(): void;
  68985. }
  68986. }
  68987. declare module BABYLON {
  68988. interface AbstractScene {
  68989. /**
  68990. * The list of layers (background and foreground) of the scene
  68991. */
  68992. layers: Array<Layer>;
  68993. }
  68994. /**
  68995. * Defines the layer scene component responsible to manage any layers
  68996. * in a given scene.
  68997. */
  68998. export class LayerSceneComponent implements ISceneComponent {
  68999. /**
  69000. * The component name helpfull to identify the component in the list of scene components.
  69001. */
  69002. readonly name: string;
  69003. /**
  69004. * The scene the component belongs to.
  69005. */
  69006. scene: Scene;
  69007. private _engine;
  69008. /**
  69009. * Creates a new instance of the component for the given scene
  69010. * @param scene Defines the scene to register the component in
  69011. */
  69012. constructor(scene: Scene);
  69013. /**
  69014. * Registers the component in a given scene
  69015. */
  69016. register(): void;
  69017. /**
  69018. * Rebuilds the elements related to this component in case of
  69019. * context lost for instance.
  69020. */
  69021. rebuild(): void;
  69022. /**
  69023. * Disposes the component and the associated ressources.
  69024. */
  69025. dispose(): void;
  69026. private _draw;
  69027. private _drawCameraPredicate;
  69028. private _drawCameraBackground;
  69029. private _drawCameraForeground;
  69030. private _drawRenderTargetPredicate;
  69031. private _drawRenderTargetBackground;
  69032. private _drawRenderTargetForeground;
  69033. }
  69034. }
  69035. declare module BABYLON {
  69036. /** @hidden */
  69037. export var layerPixelShader: {
  69038. name: string;
  69039. shader: string;
  69040. };
  69041. }
  69042. declare module BABYLON {
  69043. /** @hidden */
  69044. export var layerVertexShader: {
  69045. name: string;
  69046. shader: string;
  69047. };
  69048. }
  69049. declare module BABYLON {
  69050. /**
  69051. * This represents a full screen 2d layer.
  69052. * This can be useful to display a picture in the background of your scene for instance.
  69053. * @see https://www.babylonjs-playground.com/#08A2BS#1
  69054. */
  69055. export class Layer {
  69056. /**
  69057. * Define the name of the layer.
  69058. */
  69059. name: string;
  69060. /**
  69061. * Define the texture the layer should display.
  69062. */
  69063. texture: Nullable<Texture>;
  69064. /**
  69065. * Is the layer in background or foreground.
  69066. */
  69067. isBackground: boolean;
  69068. /**
  69069. * Define the color of the layer (instead of texture).
  69070. */
  69071. color: Color4;
  69072. /**
  69073. * Define the scale of the layer in order to zoom in out of the texture.
  69074. */
  69075. scale: Vector2;
  69076. /**
  69077. * Define an offset for the layer in order to shift the texture.
  69078. */
  69079. offset: Vector2;
  69080. /**
  69081. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  69082. */
  69083. alphaBlendingMode: number;
  69084. /**
  69085. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  69086. * Alpha test will not mix with the background color in case of transparency.
  69087. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  69088. */
  69089. alphaTest: boolean;
  69090. /**
  69091. * Define a mask to restrict the layer to only some of the scene cameras.
  69092. */
  69093. layerMask: number;
  69094. /**
  69095. * Define the list of render target the layer is visible into.
  69096. */
  69097. renderTargetTextures: RenderTargetTexture[];
  69098. /**
  69099. * Define if the layer is only used in renderTarget or if it also
  69100. * renders in the main frame buffer of the canvas.
  69101. */
  69102. renderOnlyInRenderTargetTextures: boolean;
  69103. private _scene;
  69104. private _vertexBuffers;
  69105. private _indexBuffer;
  69106. private _effect;
  69107. private _alphaTestEffect;
  69108. /**
  69109. * An event triggered when the layer is disposed.
  69110. */
  69111. onDisposeObservable: Observable<Layer>;
  69112. private _onDisposeObserver;
  69113. /**
  69114. * Back compatibility with callback before the onDisposeObservable existed.
  69115. * The set callback will be triggered when the layer has been disposed.
  69116. */
  69117. onDispose: () => void;
  69118. /**
  69119. * An event triggered before rendering the scene
  69120. */
  69121. onBeforeRenderObservable: Observable<Layer>;
  69122. private _onBeforeRenderObserver;
  69123. /**
  69124. * Back compatibility with callback before the onBeforeRenderObservable existed.
  69125. * The set callback will be triggered just before rendering the layer.
  69126. */
  69127. onBeforeRender: () => void;
  69128. /**
  69129. * An event triggered after rendering the scene
  69130. */
  69131. onAfterRenderObservable: Observable<Layer>;
  69132. private _onAfterRenderObserver;
  69133. /**
  69134. * Back compatibility with callback before the onAfterRenderObservable existed.
  69135. * The set callback will be triggered just after rendering the layer.
  69136. */
  69137. onAfterRender: () => void;
  69138. /**
  69139. * Instantiates a new layer.
  69140. * This represents a full screen 2d layer.
  69141. * This can be useful to display a picture in the background of your scene for instance.
  69142. * @see https://www.babylonjs-playground.com/#08A2BS#1
  69143. * @param name Define the name of the layer in the scene
  69144. * @param imgUrl Define the url of the texture to display in the layer
  69145. * @param scene Define the scene the layer belongs to
  69146. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  69147. * @param color Defines a color for the layer
  69148. */
  69149. constructor(
  69150. /**
  69151. * Define the name of the layer.
  69152. */
  69153. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  69154. private _createIndexBuffer;
  69155. /** @hidden */
  69156. _rebuild(): void;
  69157. /**
  69158. * Renders the layer in the scene.
  69159. */
  69160. render(): void;
  69161. /**
  69162. * Disposes and releases the associated ressources.
  69163. */
  69164. dispose(): void;
  69165. }
  69166. }
  69167. declare module BABYLON {
  69168. interface AbstractScene {
  69169. /**
  69170. * The list of procedural textures added to the scene
  69171. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69172. */
  69173. proceduralTextures: Array<ProceduralTexture>;
  69174. }
  69175. /**
  69176. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  69177. * in a given scene.
  69178. */
  69179. export class ProceduralTextureSceneComponent implements ISceneComponent {
  69180. /**
  69181. * The component name helpfull to identify the component in the list of scene components.
  69182. */
  69183. readonly name: string;
  69184. /**
  69185. * The scene the component belongs to.
  69186. */
  69187. scene: Scene;
  69188. /**
  69189. * Creates a new instance of the component for the given scene
  69190. * @param scene Defines the scene to register the component in
  69191. */
  69192. constructor(scene: Scene);
  69193. /**
  69194. * Registers the component in a given scene
  69195. */
  69196. register(): void;
  69197. /**
  69198. * Rebuilds the elements related to this component in case of
  69199. * context lost for instance.
  69200. */
  69201. rebuild(): void;
  69202. /**
  69203. * Disposes the component and the associated ressources.
  69204. */
  69205. dispose(): void;
  69206. private _beforeClear;
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /** @hidden */
  69211. export var proceduralVertexShader: {
  69212. name: string;
  69213. shader: string;
  69214. };
  69215. }
  69216. declare module BABYLON {
  69217. /**
  69218. * 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.
  69219. * This is the base class of any Procedural texture and contains most of the shareable code.
  69220. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69221. */
  69222. export class ProceduralTexture extends Texture {
  69223. isCube: boolean;
  69224. /**
  69225. * Define if the texture is enabled or not (disabled texture will not render)
  69226. */
  69227. isEnabled: boolean;
  69228. /**
  69229. * Define if the texture must be cleared before rendering (default is true)
  69230. */
  69231. autoClear: boolean;
  69232. /**
  69233. * Callback called when the texture is generated
  69234. */
  69235. onGenerated: () => void;
  69236. /**
  69237. * Event raised when the texture is generated
  69238. */
  69239. onGeneratedObservable: Observable<ProceduralTexture>;
  69240. /** @hidden */
  69241. _generateMipMaps: boolean;
  69242. /** @hidden **/
  69243. _effect: Effect;
  69244. /** @hidden */
  69245. _textures: {
  69246. [key: string]: Texture;
  69247. };
  69248. private _size;
  69249. private _currentRefreshId;
  69250. private _refreshRate;
  69251. private _vertexBuffers;
  69252. private _indexBuffer;
  69253. private _uniforms;
  69254. private _samplers;
  69255. private _fragment;
  69256. private _floats;
  69257. private _ints;
  69258. private _floatsArrays;
  69259. private _colors3;
  69260. private _colors4;
  69261. private _vectors2;
  69262. private _vectors3;
  69263. private _matrices;
  69264. private _fallbackTexture;
  69265. private _fallbackTextureUsed;
  69266. private _engine;
  69267. private _cachedDefines;
  69268. private _contentUpdateId;
  69269. private _contentData;
  69270. /**
  69271. * Instantiates a new procedural texture.
  69272. * 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.
  69273. * This is the base class of any Procedural texture and contains most of the shareable code.
  69274. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69275. * @param name Define the name of the texture
  69276. * @param size Define the size of the texture to create
  69277. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  69278. * @param scene Define the scene the texture belongs to
  69279. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69280. * @param generateMipMaps Define if the texture should creates mip maps or not
  69281. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  69282. */
  69283. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  69284. /**
  69285. * The effect that is created when initializing the post process.
  69286. * @returns The created effect corrisponding the the postprocess.
  69287. */
  69288. getEffect(): Effect;
  69289. /**
  69290. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  69291. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  69292. */
  69293. getContent(): Nullable<ArrayBufferView>;
  69294. private _createIndexBuffer;
  69295. /** @hidden */
  69296. _rebuild(): void;
  69297. /**
  69298. * Resets the texture in order to recreate its associated resources.
  69299. * This can be called in case of context loss
  69300. */
  69301. reset(): void;
  69302. protected _getDefines(): string;
  69303. /**
  69304. * Is the texture ready to be used ? (rendered at least once)
  69305. * @returns true if ready, otherwise, false.
  69306. */
  69307. isReady(): boolean;
  69308. /**
  69309. * Resets the refresh counter of the texture and start bak from scratch.
  69310. * Could be useful to regenerate the texture if it is setup to render only once.
  69311. */
  69312. resetRefreshCounter(): void;
  69313. /**
  69314. * Set the fragment shader to use in order to render the texture.
  69315. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  69316. */
  69317. setFragment(fragment: any): void;
  69318. /**
  69319. * Define the refresh rate of the texture or the rendering frequency.
  69320. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  69321. */
  69322. refreshRate: number;
  69323. /** @hidden */
  69324. _shouldRender(): boolean;
  69325. /**
  69326. * Get the size the texture is rendering at.
  69327. * @returns the size (texture is always squared)
  69328. */
  69329. getRenderSize(): number;
  69330. /**
  69331. * Resize the texture to new value.
  69332. * @param size Define the new size the texture should have
  69333. * @param generateMipMaps Define whether the new texture should create mip maps
  69334. */
  69335. resize(size: number, generateMipMaps: boolean): void;
  69336. private _checkUniform;
  69337. /**
  69338. * Set a texture in the shader program used to render.
  69339. * @param name Define the name of the uniform samplers as defined in the shader
  69340. * @param texture Define the texture to bind to this sampler
  69341. * @return the texture itself allowing "fluent" like uniform updates
  69342. */
  69343. setTexture(name: string, texture: Texture): ProceduralTexture;
  69344. /**
  69345. * Set a float in the shader.
  69346. * @param name Define the name of the uniform as defined in the shader
  69347. * @param value Define the value to give to the uniform
  69348. * @return the texture itself allowing "fluent" like uniform updates
  69349. */
  69350. setFloat(name: string, value: number): ProceduralTexture;
  69351. /**
  69352. * Set a int in the shader.
  69353. * @param name Define the name of the uniform as defined in the shader
  69354. * @param value Define the value to give to the uniform
  69355. * @return the texture itself allowing "fluent" like uniform updates
  69356. */
  69357. setInt(name: string, value: number): ProceduralTexture;
  69358. /**
  69359. * Set an array of floats in the shader.
  69360. * @param name Define the name of the uniform as defined in the shader
  69361. * @param value Define the value to give to the uniform
  69362. * @return the texture itself allowing "fluent" like uniform updates
  69363. */
  69364. setFloats(name: string, value: number[]): ProceduralTexture;
  69365. /**
  69366. * Set a vec3 in the shader from a Color3.
  69367. * @param name Define the name of the uniform as defined in the shader
  69368. * @param value Define the value to give to the uniform
  69369. * @return the texture itself allowing "fluent" like uniform updates
  69370. */
  69371. setColor3(name: string, value: Color3): ProceduralTexture;
  69372. /**
  69373. * Set a vec4 in the shader from a Color4.
  69374. * @param name Define the name of the uniform as defined in the shader
  69375. * @param value Define the value to give to the uniform
  69376. * @return the texture itself allowing "fluent" like uniform updates
  69377. */
  69378. setColor4(name: string, value: Color4): ProceduralTexture;
  69379. /**
  69380. * Set a vec2 in the shader from a Vector2.
  69381. * @param name Define the name of the uniform as defined in the shader
  69382. * @param value Define the value to give to the uniform
  69383. * @return the texture itself allowing "fluent" like uniform updates
  69384. */
  69385. setVector2(name: string, value: Vector2): ProceduralTexture;
  69386. /**
  69387. * Set a vec3 in the shader from a Vector3.
  69388. * @param name Define the name of the uniform as defined in the shader
  69389. * @param value Define the value to give to the uniform
  69390. * @return the texture itself allowing "fluent" like uniform updates
  69391. */
  69392. setVector3(name: string, value: Vector3): ProceduralTexture;
  69393. /**
  69394. * Set a mat4 in the shader from a MAtrix.
  69395. * @param name Define the name of the uniform as defined in the shader
  69396. * @param value Define the value to give to the uniform
  69397. * @return the texture itself allowing "fluent" like uniform updates
  69398. */
  69399. setMatrix(name: string, value: Matrix): ProceduralTexture;
  69400. /**
  69401. * Render the texture to its associated render target.
  69402. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69403. */
  69404. render(useCameraPostProcess?: boolean): void;
  69405. /**
  69406. * Clone the texture.
  69407. * @returns the cloned texture
  69408. */
  69409. clone(): ProceduralTexture;
  69410. /**
  69411. * Dispose the texture and release its asoociated resources.
  69412. */
  69413. dispose(): void;
  69414. }
  69415. }
  69416. declare module BABYLON {
  69417. /**
  69418. * This represents the base class for particle system in Babylon.
  69419. * 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.
  69420. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  69421. * @example https://doc.babylonjs.com/babylon101/particles
  69422. */
  69423. export class BaseParticleSystem {
  69424. /**
  69425. * Source color is added to the destination color without alpha affecting the result
  69426. */
  69427. static BLENDMODE_ONEONE: number;
  69428. /**
  69429. * Blend current color and particle color using particle’s alpha
  69430. */
  69431. static BLENDMODE_STANDARD: number;
  69432. /**
  69433. * Add current color and particle color multiplied by particle’s alpha
  69434. */
  69435. static BLENDMODE_ADD: number;
  69436. /**
  69437. * Multiply current color with particle color
  69438. */
  69439. static BLENDMODE_MULTIPLY: number;
  69440. /**
  69441. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  69442. */
  69443. static BLENDMODE_MULTIPLYADD: number;
  69444. /**
  69445. * List of animations used by the particle system.
  69446. */
  69447. animations: Animation[];
  69448. /**
  69449. * The id of the Particle system.
  69450. */
  69451. id: string;
  69452. /**
  69453. * The friendly name of the Particle system.
  69454. */
  69455. name: string;
  69456. /**
  69457. * The rendering group used by the Particle system to chose when to render.
  69458. */
  69459. renderingGroupId: number;
  69460. /**
  69461. * The emitter represents the Mesh or position we are attaching the particle system to.
  69462. */
  69463. emitter: Nullable<AbstractMesh | Vector3>;
  69464. /**
  69465. * The maximum number of particles to emit per frame
  69466. */
  69467. emitRate: number;
  69468. /**
  69469. * If you want to launch only a few particles at once, that can be done, as well.
  69470. */
  69471. manualEmitCount: number;
  69472. /**
  69473. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  69474. */
  69475. updateSpeed: number;
  69476. /**
  69477. * The amount of time the particle system is running (depends of the overall update speed).
  69478. */
  69479. targetStopDuration: number;
  69480. /**
  69481. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  69482. */
  69483. disposeOnStop: boolean;
  69484. /**
  69485. * Minimum power of emitting particles.
  69486. */
  69487. minEmitPower: number;
  69488. /**
  69489. * Maximum power of emitting particles.
  69490. */
  69491. maxEmitPower: number;
  69492. /**
  69493. * Minimum life time of emitting particles.
  69494. */
  69495. minLifeTime: number;
  69496. /**
  69497. * Maximum life time of emitting particles.
  69498. */
  69499. maxLifeTime: number;
  69500. /**
  69501. * Minimum Size of emitting particles.
  69502. */
  69503. minSize: number;
  69504. /**
  69505. * Maximum Size of emitting particles.
  69506. */
  69507. maxSize: number;
  69508. /**
  69509. * Minimum scale of emitting particles on X axis.
  69510. */
  69511. minScaleX: number;
  69512. /**
  69513. * Maximum scale of emitting particles on X axis.
  69514. */
  69515. maxScaleX: number;
  69516. /**
  69517. * Minimum scale of emitting particles on Y axis.
  69518. */
  69519. minScaleY: number;
  69520. /**
  69521. * Maximum scale of emitting particles on Y axis.
  69522. */
  69523. maxScaleY: number;
  69524. /**
  69525. * Gets or sets the minimal initial rotation in radians.
  69526. */
  69527. minInitialRotation: number;
  69528. /**
  69529. * Gets or sets the maximal initial rotation in radians.
  69530. */
  69531. maxInitialRotation: number;
  69532. /**
  69533. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  69534. */
  69535. minAngularSpeed: number;
  69536. /**
  69537. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  69538. */
  69539. maxAngularSpeed: number;
  69540. /**
  69541. * The texture used to render each particle. (this can be a spritesheet)
  69542. */
  69543. particleTexture: Nullable<Texture>;
  69544. /**
  69545. * The layer mask we are rendering the particles through.
  69546. */
  69547. layerMask: number;
  69548. /**
  69549. * This can help using your own shader to render the particle system.
  69550. * The according effect will be created
  69551. */
  69552. customShader: any;
  69553. /**
  69554. * By default particle system starts as soon as they are created. This prevents the
  69555. * automatic start to happen and let you decide when to start emitting particles.
  69556. */
  69557. preventAutoStart: boolean;
  69558. private _noiseTexture;
  69559. /**
  69560. * Gets or sets a texture used to add random noise to particle positions
  69561. */
  69562. noiseTexture: Nullable<ProceduralTexture>;
  69563. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  69564. noiseStrength: Vector3;
  69565. /**
  69566. * Callback triggered when the particle animation is ending.
  69567. */
  69568. onAnimationEnd: Nullable<() => void>;
  69569. /**
  69570. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  69571. */
  69572. blendMode: number;
  69573. /**
  69574. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69575. * to override the particles.
  69576. */
  69577. forceDepthWrite: boolean;
  69578. /** 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 */
  69579. preWarmCycles: number;
  69580. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  69581. preWarmStepOffset: number;
  69582. /**
  69583. * 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)
  69584. */
  69585. spriteCellChangeSpeed: number;
  69586. /**
  69587. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  69588. */
  69589. startSpriteCellID: number;
  69590. /**
  69591. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  69592. */
  69593. endSpriteCellID: number;
  69594. /**
  69595. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  69596. */
  69597. spriteCellWidth: number;
  69598. /**
  69599. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  69600. */
  69601. spriteCellHeight: number;
  69602. /**
  69603. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  69604. */
  69605. spriteRandomStartCell: boolean;
  69606. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  69607. translationPivot: Vector2;
  69608. /** @hidden */
  69609. protected _isAnimationSheetEnabled: boolean;
  69610. /**
  69611. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  69612. */
  69613. beginAnimationOnStart: boolean;
  69614. /**
  69615. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  69616. */
  69617. beginAnimationFrom: number;
  69618. /**
  69619. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  69620. */
  69621. beginAnimationTo: number;
  69622. /**
  69623. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  69624. */
  69625. beginAnimationLoop: boolean;
  69626. /**
  69627. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  69628. */
  69629. isAnimationSheetEnabled: boolean;
  69630. /**
  69631. * Get hosting scene
  69632. * @returns the scene
  69633. */
  69634. getScene(): Scene;
  69635. /**
  69636. * You can use gravity if you want to give an orientation to your particles.
  69637. */
  69638. gravity: Vector3;
  69639. protected _colorGradients: Nullable<Array<ColorGradient>>;
  69640. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  69641. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  69642. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  69643. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  69644. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  69645. protected _dragGradients: Nullable<Array<FactorGradient>>;
  69646. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  69647. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  69648. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  69649. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  69650. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  69651. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  69652. /**
  69653. * Defines the delay in milliseconds before starting the system (0 by default)
  69654. */
  69655. startDelay: number;
  69656. /**
  69657. * Gets the current list of drag gradients.
  69658. * You must use addDragGradient and removeDragGradient to udpate this list
  69659. * @returns the list of drag gradients
  69660. */
  69661. getDragGradients(): Nullable<Array<FactorGradient>>;
  69662. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  69663. limitVelocityDamping: number;
  69664. /**
  69665. * Gets the current list of limit velocity gradients.
  69666. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  69667. * @returns the list of limit velocity gradients
  69668. */
  69669. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  69670. /**
  69671. * Gets the current list of color gradients.
  69672. * You must use addColorGradient and removeColorGradient to udpate this list
  69673. * @returns the list of color gradients
  69674. */
  69675. getColorGradients(): Nullable<Array<ColorGradient>>;
  69676. /**
  69677. * Gets the current list of size gradients.
  69678. * You must use addSizeGradient and removeSizeGradient to udpate this list
  69679. * @returns the list of size gradients
  69680. */
  69681. getSizeGradients(): Nullable<Array<FactorGradient>>;
  69682. /**
  69683. * Gets the current list of color remap gradients.
  69684. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  69685. * @returns the list of color remap gradients
  69686. */
  69687. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  69688. /**
  69689. * Gets the current list of alpha remap gradients.
  69690. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  69691. * @returns the list of alpha remap gradients
  69692. */
  69693. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  69694. /**
  69695. * Gets the current list of life time gradients.
  69696. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  69697. * @returns the list of life time gradients
  69698. */
  69699. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  69700. /**
  69701. * Gets the current list of angular speed gradients.
  69702. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  69703. * @returns the list of angular speed gradients
  69704. */
  69705. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  69706. /**
  69707. * Gets the current list of velocity gradients.
  69708. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  69709. * @returns the list of velocity gradients
  69710. */
  69711. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  69712. /**
  69713. * Gets the current list of start size gradients.
  69714. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  69715. * @returns the list of start size gradients
  69716. */
  69717. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  69718. /**
  69719. * Gets the current list of emit rate gradients.
  69720. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  69721. * @returns the list of emit rate gradients
  69722. */
  69723. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  69724. /**
  69725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  69726. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69727. */
  69728. direction1: Vector3;
  69729. /**
  69730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  69731. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69732. */
  69733. direction2: Vector3;
  69734. /**
  69735. * 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.
  69736. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69737. */
  69738. minEmitBox: Vector3;
  69739. /**
  69740. * 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.
  69741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69742. */
  69743. maxEmitBox: Vector3;
  69744. /**
  69745. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  69746. */
  69747. color1: Color4;
  69748. /**
  69749. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  69750. */
  69751. color2: Color4;
  69752. /**
  69753. * Color the particle will have at the end of its lifetime
  69754. */
  69755. colorDead: Color4;
  69756. /**
  69757. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  69758. */
  69759. textureMask: Color4;
  69760. /**
  69761. * The particle emitter type defines the emitter used by the particle system.
  69762. * It can be for example box, sphere, or cone...
  69763. */
  69764. particleEmitterType: IParticleEmitterType;
  69765. /** @hidden */
  69766. _isSubEmitter: boolean;
  69767. /**
  69768. * Gets or sets the billboard mode to use when isBillboardBased = true.
  69769. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  69770. */
  69771. billboardMode: number;
  69772. protected _isBillboardBased: boolean;
  69773. /**
  69774. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  69775. */
  69776. isBillboardBased: boolean;
  69777. /**
  69778. * The scene the particle system belongs to.
  69779. */
  69780. protected _scene: Scene;
  69781. /**
  69782. * Local cache of defines for image processing.
  69783. */
  69784. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  69785. /**
  69786. * Default configuration related to image processing available in the standard Material.
  69787. */
  69788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  69789. /**
  69790. * Gets the image processing configuration used either in this material.
  69791. */
  69792. /**
  69793. * Sets the Default image processing configuration used either in the this material.
  69794. *
  69795. * If sets to null, the scene one is in use.
  69796. */
  69797. imageProcessingConfiguration: ImageProcessingConfiguration;
  69798. /**
  69799. * Attaches a new image processing configuration to the Standard Material.
  69800. * @param configuration
  69801. */
  69802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  69803. /** @hidden */
  69804. protected _reset(): void;
  69805. /** @hidden */
  69806. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  69807. /**
  69808. * Instantiates a particle system.
  69809. * 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.
  69810. * @param name The name of the particle system
  69811. */
  69812. constructor(name: string);
  69813. /**
  69814. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  69815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  69816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  69817. * @returns the emitter
  69818. */
  69819. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  69820. /**
  69821. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  69822. * @param radius The radius of the hemisphere to emit from
  69823. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  69824. * @returns the emitter
  69825. */
  69826. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  69827. /**
  69828. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  69829. * @param radius The radius of the sphere to emit from
  69830. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  69831. * @returns the emitter
  69832. */
  69833. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  69834. /**
  69835. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  69836. * @param radius The radius of the sphere to emit from
  69837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  69838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  69839. * @returns the emitter
  69840. */
  69841. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  69842. /**
  69843. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  69844. * @param radius The radius of the emission cylinder
  69845. * @param height The height of the emission cylinder
  69846. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  69847. * @param directionRandomizer How much to randomize the particle direction [0-1]
  69848. * @returns the emitter
  69849. */
  69850. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  69851. /**
  69852. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  69853. * @param radius The radius of the cylinder to emit from
  69854. * @param height The height of the emission cylinder
  69855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  69856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  69857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  69858. * @returns the emitter
  69859. */
  69860. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  69861. /**
  69862. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  69863. * @param radius The radius of the cone to emit from
  69864. * @param angle The base angle of the cone
  69865. * @returns the emitter
  69866. */
  69867. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  69868. /**
  69869. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  69870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  69871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  69872. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  69873. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  69874. * @returns the emitter
  69875. */
  69876. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  69877. }
  69878. }
  69879. declare module BABYLON {
  69880. /**
  69881. * Type of sub emitter
  69882. */
  69883. export enum SubEmitterType {
  69884. /**
  69885. * Attached to the particle over it's lifetime
  69886. */
  69887. ATTACHED = 0,
  69888. /**
  69889. * Created when the particle dies
  69890. */
  69891. END = 1
  69892. }
  69893. /**
  69894. * Sub emitter class used to emit particles from an existing particle
  69895. */
  69896. export class SubEmitter {
  69897. /**
  69898. * the particle system to be used by the sub emitter
  69899. */
  69900. particleSystem: ParticleSystem;
  69901. /**
  69902. * Type of the submitter (Default: END)
  69903. */
  69904. type: SubEmitterType;
  69905. /**
  69906. * 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)
  69907. * Note: This only is supported when using an emitter of type Mesh
  69908. */
  69909. inheritDirection: boolean;
  69910. /**
  69911. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  69912. */
  69913. inheritedVelocityAmount: number;
  69914. /**
  69915. * Creates a sub emitter
  69916. * @param particleSystem the particle system to be used by the sub emitter
  69917. */
  69918. constructor(
  69919. /**
  69920. * the particle system to be used by the sub emitter
  69921. */
  69922. particleSystem: ParticleSystem);
  69923. /**
  69924. * Clones the sub emitter
  69925. * @returns the cloned sub emitter
  69926. */
  69927. clone(): SubEmitter;
  69928. /**
  69929. * Serialize current object to a JSON object
  69930. * @returns the serialized object
  69931. */
  69932. serialize(): any;
  69933. /** @hidden */
  69934. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  69935. /**
  69936. * Creates a new SubEmitter from a serialized JSON version
  69937. * @param serializationObject defines the JSON object to read from
  69938. * @param scene defines the hosting scene
  69939. * @param rootUrl defines the rootUrl for data loading
  69940. * @returns a new SubEmitter
  69941. */
  69942. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  69943. /** Release associated resources */
  69944. dispose(): void;
  69945. }
  69946. }
  69947. declare module BABYLON {
  69948. /** @hidden */
  69949. export var clipPlaneFragmentDeclaration: {
  69950. name: string;
  69951. shader: string;
  69952. };
  69953. }
  69954. declare module BABYLON {
  69955. /** @hidden */
  69956. export var imageProcessingDeclaration: {
  69957. name: string;
  69958. shader: string;
  69959. };
  69960. }
  69961. declare module BABYLON {
  69962. /** @hidden */
  69963. export var imageProcessingFunctions: {
  69964. name: string;
  69965. shader: string;
  69966. };
  69967. }
  69968. declare module BABYLON {
  69969. /** @hidden */
  69970. export var clipPlaneFragment: {
  69971. name: string;
  69972. shader: string;
  69973. };
  69974. }
  69975. declare module BABYLON {
  69976. /** @hidden */
  69977. export var particlesPixelShader: {
  69978. name: string;
  69979. shader: string;
  69980. };
  69981. }
  69982. declare module BABYLON {
  69983. /** @hidden */
  69984. export var clipPlaneVertexDeclaration: {
  69985. name: string;
  69986. shader: string;
  69987. };
  69988. }
  69989. declare module BABYLON {
  69990. /** @hidden */
  69991. export var clipPlaneVertex: {
  69992. name: string;
  69993. shader: string;
  69994. };
  69995. }
  69996. declare module BABYLON {
  69997. /** @hidden */
  69998. export var particlesVertexShader: {
  69999. name: string;
  70000. shader: string;
  70001. };
  70002. }
  70003. declare module BABYLON {
  70004. /**
  70005. * This represents a particle system in Babylon.
  70006. * 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.
  70007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70008. * @example https://doc.babylonjs.com/babylon101/particles
  70009. */
  70010. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  70011. /**
  70012. * Billboard mode will only apply to Y axis
  70013. */
  70014. static readonly BILLBOARDMODE_Y: number;
  70015. /**
  70016. * Billboard mode will apply to all axes
  70017. */
  70018. static readonly BILLBOARDMODE_ALL: number;
  70019. /**
  70020. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70021. */
  70022. static readonly BILLBOARDMODE_STRETCHED: number;
  70023. /**
  70024. * This function can be defined to provide custom update for active particles.
  70025. * This function will be called instead of regular update (age, position, color, etc.).
  70026. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  70027. */
  70028. updateFunction: (particles: Particle[]) => void;
  70029. private _emitterWorldMatrix;
  70030. /**
  70031. * This function can be defined to specify initial direction for every new particle.
  70032. * It by default use the emitterType defined function
  70033. */
  70034. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  70035. /**
  70036. * This function can be defined to specify initial position for every new particle.
  70037. * It by default use the emitterType defined function
  70038. */
  70039. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  70040. /**
  70041. * @hidden
  70042. */
  70043. _inheritedVelocityOffset: Vector3;
  70044. /**
  70045. * An event triggered when the system is disposed
  70046. */
  70047. onDisposeObservable: Observable<ParticleSystem>;
  70048. private _onDisposeObserver;
  70049. /**
  70050. * Sets a callback that will be triggered when the system is disposed
  70051. */
  70052. onDispose: () => void;
  70053. private _particles;
  70054. private _epsilon;
  70055. private _capacity;
  70056. private _stockParticles;
  70057. private _newPartsExcess;
  70058. private _vertexData;
  70059. private _vertexBuffer;
  70060. private _vertexBuffers;
  70061. private _spriteBuffer;
  70062. private _indexBuffer;
  70063. private _effect;
  70064. private _customEffect;
  70065. private _cachedDefines;
  70066. private _scaledColorStep;
  70067. private _colorDiff;
  70068. private _scaledDirection;
  70069. private _scaledGravity;
  70070. private _currentRenderId;
  70071. private _alive;
  70072. private _useInstancing;
  70073. private _started;
  70074. private _stopped;
  70075. private _actualFrame;
  70076. private _scaledUpdateSpeed;
  70077. private _vertexBufferSize;
  70078. /** @hidden */
  70079. _currentEmitRateGradient: Nullable<FactorGradient>;
  70080. /** @hidden */
  70081. _currentEmitRate1: number;
  70082. /** @hidden */
  70083. _currentEmitRate2: number;
  70084. /** @hidden */
  70085. _currentStartSizeGradient: Nullable<FactorGradient>;
  70086. /** @hidden */
  70087. _currentStartSize1: number;
  70088. /** @hidden */
  70089. _currentStartSize2: number;
  70090. private readonly _rawTextureWidth;
  70091. private _rampGradientsTexture;
  70092. private _useRampGradients;
  70093. /** Gets or sets a boolean indicating that ramp gradients must be used
  70094. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70095. */
  70096. useRampGradients: boolean;
  70097. /**
  70098. * 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.
  70099. * 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: [])
  70100. */
  70101. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  70102. private _subEmitters;
  70103. /**
  70104. * @hidden
  70105. * If the particle systems emitter should be disposed when the particle system is disposed
  70106. */
  70107. _disposeEmitterOnDispose: boolean;
  70108. /**
  70109. * The current active Sub-systems, this property is used by the root particle system only.
  70110. */
  70111. activeSubSystems: Array<ParticleSystem>;
  70112. private _rootParticleSystem;
  70113. /**
  70114. * Gets the current list of active particles
  70115. */
  70116. readonly particles: Particle[];
  70117. /**
  70118. * Returns the string "ParticleSystem"
  70119. * @returns a string containing the class name
  70120. */
  70121. getClassName(): string;
  70122. /**
  70123. * Instantiates a particle system.
  70124. * 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.
  70125. * @param name The name of the particle system
  70126. * @param capacity The max number of particles alive at the same time
  70127. * @param scene The scene the particle system belongs to
  70128. * @param customEffect a custom effect used to change the way particles are rendered by default
  70129. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70130. * @param epsilon Offset used to render the particles
  70131. */
  70132. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  70133. private _addFactorGradient;
  70134. private _removeFactorGradient;
  70135. /**
  70136. * Adds a new life time gradient
  70137. * @param gradient defines the gradient to use (between 0 and 1)
  70138. * @param factor defines the life time factor to affect to the specified gradient
  70139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70140. * @returns the current particle system
  70141. */
  70142. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70143. /**
  70144. * Remove a specific life time gradient
  70145. * @param gradient defines the gradient to remove
  70146. * @returns the current particle system
  70147. */
  70148. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70149. /**
  70150. * Adds a new size gradient
  70151. * @param gradient defines the gradient to use (between 0 and 1)
  70152. * @param factor defines the size factor to affect to the specified gradient
  70153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70154. * @returns the current particle system
  70155. */
  70156. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70157. /**
  70158. * Remove a specific size gradient
  70159. * @param gradient defines the gradient to remove
  70160. * @returns the current particle system
  70161. */
  70162. removeSizeGradient(gradient: number): IParticleSystem;
  70163. /**
  70164. * Adds a new color remap gradient
  70165. * @param gradient defines the gradient to use (between 0 and 1)
  70166. * @param min defines the color remap minimal range
  70167. * @param max defines the color remap maximal range
  70168. * @returns the current particle system
  70169. */
  70170. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70171. /**
  70172. * Remove a specific color remap gradient
  70173. * @param gradient defines the gradient to remove
  70174. * @returns the current particle system
  70175. */
  70176. removeColorRemapGradient(gradient: number): IParticleSystem;
  70177. /**
  70178. * Adds a new alpha remap gradient
  70179. * @param gradient defines the gradient to use (between 0 and 1)
  70180. * @param min defines the alpha remap minimal range
  70181. * @param max defines the alpha remap maximal range
  70182. * @returns the current particle system
  70183. */
  70184. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70185. /**
  70186. * Remove a specific alpha remap gradient
  70187. * @param gradient defines the gradient to remove
  70188. * @returns the current particle system
  70189. */
  70190. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  70191. /**
  70192. * Adds a new angular speed gradient
  70193. * @param gradient defines the gradient to use (between 0 and 1)
  70194. * @param factor defines the angular speed to affect to the specified gradient
  70195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70196. * @returns the current particle system
  70197. */
  70198. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70199. /**
  70200. * Remove a specific angular speed gradient
  70201. * @param gradient defines the gradient to remove
  70202. * @returns the current particle system
  70203. */
  70204. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  70205. /**
  70206. * Adds a new velocity gradient
  70207. * @param gradient defines the gradient to use (between 0 and 1)
  70208. * @param factor defines the velocity to affect to the specified gradient
  70209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70210. * @returns the current particle system
  70211. */
  70212. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70213. /**
  70214. * Remove a specific velocity gradient
  70215. * @param gradient defines the gradient to remove
  70216. * @returns the current particle system
  70217. */
  70218. removeVelocityGradient(gradient: number): IParticleSystem;
  70219. /**
  70220. * Adds a new limit velocity gradient
  70221. * @param gradient defines the gradient to use (between 0 and 1)
  70222. * @param factor defines the limit velocity value to affect to the specified gradient
  70223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70224. * @returns the current particle system
  70225. */
  70226. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70227. /**
  70228. * Remove a specific limit velocity gradient
  70229. * @param gradient defines the gradient to remove
  70230. * @returns the current particle system
  70231. */
  70232. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  70233. /**
  70234. * Adds a new drag gradient
  70235. * @param gradient defines the gradient to use (between 0 and 1)
  70236. * @param factor defines the drag value to affect to the specified gradient
  70237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70238. * @returns the current particle system
  70239. */
  70240. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70241. /**
  70242. * Remove a specific drag gradient
  70243. * @param gradient defines the gradient to remove
  70244. * @returns the current particle system
  70245. */
  70246. removeDragGradient(gradient: number): IParticleSystem;
  70247. /**
  70248. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  70249. * @param gradient defines the gradient to use (between 0 and 1)
  70250. * @param factor defines the emit rate value to affect to the specified gradient
  70251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70252. * @returns the current particle system
  70253. */
  70254. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70255. /**
  70256. * Remove a specific emit rate gradient
  70257. * @param gradient defines the gradient to remove
  70258. * @returns the current particle system
  70259. */
  70260. removeEmitRateGradient(gradient: number): IParticleSystem;
  70261. /**
  70262. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  70263. * @param gradient defines the gradient to use (between 0 and 1)
  70264. * @param factor defines the start size value to affect to the specified gradient
  70265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70266. * @returns the current particle system
  70267. */
  70268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70269. /**
  70270. * Remove a specific start size gradient
  70271. * @param gradient defines the gradient to remove
  70272. * @returns the current particle system
  70273. */
  70274. removeStartSizeGradient(gradient: number): IParticleSystem;
  70275. private _createRampGradientTexture;
  70276. /**
  70277. * Gets the current list of ramp gradients.
  70278. * You must use addRampGradient and removeRampGradient to udpate this list
  70279. * @returns the list of ramp gradients
  70280. */
  70281. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70282. /**
  70283. * Adds a new ramp gradient used to remap particle colors
  70284. * @param gradient defines the gradient to use (between 0 and 1)
  70285. * @param color defines the color to affect to the specified gradient
  70286. * @returns the current particle system
  70287. */
  70288. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  70289. /**
  70290. * Remove a specific ramp gradient
  70291. * @param gradient defines the gradient to remove
  70292. * @returns the current particle system
  70293. */
  70294. removeRampGradient(gradient: number): ParticleSystem;
  70295. /**
  70296. * Adds a new color gradient
  70297. * @param gradient defines the gradient to use (between 0 and 1)
  70298. * @param color1 defines the color to affect to the specified gradient
  70299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70300. * @returns this particle system
  70301. */
  70302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  70303. /**
  70304. * Remove a specific color gradient
  70305. * @param gradient defines the gradient to remove
  70306. * @returns this particle system
  70307. */
  70308. removeColorGradient(gradient: number): IParticleSystem;
  70309. private _fetchR;
  70310. protected _reset(): void;
  70311. private _resetEffect;
  70312. private _createVertexBuffers;
  70313. private _createIndexBuffer;
  70314. /**
  70315. * Gets the maximum number of particles active at the same time.
  70316. * @returns The max number of active particles.
  70317. */
  70318. getCapacity(): number;
  70319. /**
  70320. * Gets whether there are still active particles in the system.
  70321. * @returns True if it is alive, otherwise false.
  70322. */
  70323. isAlive(): boolean;
  70324. /**
  70325. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70326. * @returns True if it has been started, otherwise false.
  70327. */
  70328. isStarted(): boolean;
  70329. private _prepareSubEmitterInternalArray;
  70330. /**
  70331. * Starts the particle system and begins to emit
  70332. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70333. */
  70334. start(delay?: number): void;
  70335. /**
  70336. * Stops the particle system.
  70337. * @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.
  70338. */
  70339. stop(stopSubEmitters?: boolean): void;
  70340. /**
  70341. * Remove all active particles
  70342. */
  70343. reset(): void;
  70344. /**
  70345. * @hidden (for internal use only)
  70346. */
  70347. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  70348. /**
  70349. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  70350. * Its lifetime will start back at 0.
  70351. */
  70352. recycleParticle: (particle: Particle) => void;
  70353. private _stopSubEmitters;
  70354. private _createParticle;
  70355. private _removeFromRoot;
  70356. private _emitFromParticle;
  70357. private _update;
  70358. /** @hidden */
  70359. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  70360. /** @hidden */
  70361. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  70362. /** @hidden */
  70363. private _getEffect;
  70364. /**
  70365. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70366. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  70367. */
  70368. animate(preWarmOnly?: boolean): void;
  70369. private _appendParticleVertices;
  70370. /**
  70371. * Rebuilds the particle system.
  70372. */
  70373. rebuild(): void;
  70374. /**
  70375. * Is this system ready to be used/rendered
  70376. * @return true if the system is ready
  70377. */
  70378. isReady(): boolean;
  70379. private _render;
  70380. /**
  70381. * Renders the particle system in its current state.
  70382. * @returns the current number of particles
  70383. */
  70384. render(): number;
  70385. /**
  70386. * Disposes the particle system and free the associated resources
  70387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70388. */
  70389. dispose(disposeTexture?: boolean): void;
  70390. /**
  70391. * Clones the particle system.
  70392. * @param name The name of the cloned object
  70393. * @param newEmitter The new emitter to use
  70394. * @returns the cloned particle system
  70395. */
  70396. clone(name: string, newEmitter: any): ParticleSystem;
  70397. /**
  70398. * Serializes the particle system to a JSON object.
  70399. * @returns the JSON object
  70400. */
  70401. serialize(): any;
  70402. /** @hidden */
  70403. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  70404. /** @hidden */
  70405. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  70406. /**
  70407. * Parses a JSON object to create a particle system.
  70408. * @param parsedParticleSystem The JSON object to parse
  70409. * @param scene The scene to create the particle system in
  70410. * @param rootUrl The root url to use to load external dependencies like texture
  70411. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70412. * @returns the Parsed particle system
  70413. */
  70414. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  70415. }
  70416. }
  70417. declare module BABYLON {
  70418. /**
  70419. * A particle represents one of the element emitted by a particle system.
  70420. * This is mainly define by its coordinates, direction, velocity and age.
  70421. */
  70422. export class Particle {
  70423. /**
  70424. * The particle system the particle belongs to.
  70425. */
  70426. particleSystem: ParticleSystem;
  70427. private static _Count;
  70428. /**
  70429. * Unique ID of the particle
  70430. */
  70431. id: number;
  70432. /**
  70433. * The world position of the particle in the scene.
  70434. */
  70435. position: Vector3;
  70436. /**
  70437. * The world direction of the particle in the scene.
  70438. */
  70439. direction: Vector3;
  70440. /**
  70441. * The color of the particle.
  70442. */
  70443. color: Color4;
  70444. /**
  70445. * The color change of the particle per step.
  70446. */
  70447. colorStep: Color4;
  70448. /**
  70449. * Defines how long will the life of the particle be.
  70450. */
  70451. lifeTime: number;
  70452. /**
  70453. * The current age of the particle.
  70454. */
  70455. age: number;
  70456. /**
  70457. * The current size of the particle.
  70458. */
  70459. size: number;
  70460. /**
  70461. * The current scale of the particle.
  70462. */
  70463. scale: Vector2;
  70464. /**
  70465. * The current angle of the particle.
  70466. */
  70467. angle: number;
  70468. /**
  70469. * Defines how fast is the angle changing.
  70470. */
  70471. angularSpeed: number;
  70472. /**
  70473. * Defines the cell index used by the particle to be rendered from a sprite.
  70474. */
  70475. cellIndex: number;
  70476. /**
  70477. * The information required to support color remapping
  70478. */
  70479. remapData: Vector4;
  70480. /** @hidden */
  70481. _randomCellOffset?: number;
  70482. /** @hidden */
  70483. _initialDirection: Nullable<Vector3>;
  70484. /** @hidden */
  70485. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  70486. /** @hidden */
  70487. _initialStartSpriteCellID: number;
  70488. /** @hidden */
  70489. _initialEndSpriteCellID: number;
  70490. /** @hidden */
  70491. _currentColorGradient: Nullable<ColorGradient>;
  70492. /** @hidden */
  70493. _currentColor1: Color4;
  70494. /** @hidden */
  70495. _currentColor2: Color4;
  70496. /** @hidden */
  70497. _currentSizeGradient: Nullable<FactorGradient>;
  70498. /** @hidden */
  70499. _currentSize1: number;
  70500. /** @hidden */
  70501. _currentSize2: number;
  70502. /** @hidden */
  70503. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  70504. /** @hidden */
  70505. _currentAngularSpeed1: number;
  70506. /** @hidden */
  70507. _currentAngularSpeed2: number;
  70508. /** @hidden */
  70509. _currentVelocityGradient: Nullable<FactorGradient>;
  70510. /** @hidden */
  70511. _currentVelocity1: number;
  70512. /** @hidden */
  70513. _currentVelocity2: number;
  70514. /** @hidden */
  70515. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  70516. /** @hidden */
  70517. _currentLimitVelocity1: number;
  70518. /** @hidden */
  70519. _currentLimitVelocity2: number;
  70520. /** @hidden */
  70521. _currentDragGradient: Nullable<FactorGradient>;
  70522. /** @hidden */
  70523. _currentDrag1: number;
  70524. /** @hidden */
  70525. _currentDrag2: number;
  70526. /** @hidden */
  70527. _randomNoiseCoordinates1: Vector3;
  70528. /** @hidden */
  70529. _randomNoiseCoordinates2: Vector3;
  70530. /**
  70531. * Creates a new instance Particle
  70532. * @param particleSystem the particle system the particle belongs to
  70533. */
  70534. constructor(
  70535. /**
  70536. * The particle system the particle belongs to.
  70537. */
  70538. particleSystem: ParticleSystem);
  70539. private updateCellInfoFromSystem;
  70540. /**
  70541. * Defines how the sprite cell index is updated for the particle
  70542. */
  70543. updateCellIndex(): void;
  70544. /** @hidden */
  70545. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  70546. /** @hidden */
  70547. _inheritParticleInfoToSubEmitters(): void;
  70548. /** @hidden */
  70549. _reset(): void;
  70550. /**
  70551. * Copy the properties of particle to another one.
  70552. * @param other the particle to copy the information to.
  70553. */
  70554. copyTo(other: Particle): void;
  70555. }
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * Particle emitter represents a volume emitting particles.
  70560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  70561. */
  70562. export interface IParticleEmitterType {
  70563. /**
  70564. * Called by the particle System when the direction is computed for the created particle.
  70565. * @param worldMatrix is the world matrix of the particle system
  70566. * @param directionToUpdate is the direction vector to update with the result
  70567. * @param particle is the particle we are computed the direction for
  70568. */
  70569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70570. /**
  70571. * Called by the particle System when the position is computed for the created particle.
  70572. * @param worldMatrix is the world matrix of the particle system
  70573. * @param positionToUpdate is the position vector to update with the result
  70574. * @param particle is the particle we are computed the position for
  70575. */
  70576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70577. /**
  70578. * Clones the current emitter and returns a copy of it
  70579. * @returns the new emitter
  70580. */
  70581. clone(): IParticleEmitterType;
  70582. /**
  70583. * Called by the GPUParticleSystem to setup the update shader
  70584. * @param effect defines the update shader
  70585. */
  70586. applyToShader(effect: Effect): void;
  70587. /**
  70588. * Returns a string to use to update the GPU particles update shader
  70589. * @returns the effect defines string
  70590. */
  70591. getEffectDefines(): string;
  70592. /**
  70593. * Returns a string representing the class name
  70594. * @returns a string containing the class name
  70595. */
  70596. getClassName(): string;
  70597. /**
  70598. * Serializes the particle system to a JSON object.
  70599. * @returns the JSON object
  70600. */
  70601. serialize(): any;
  70602. /**
  70603. * Parse properties from a JSON object
  70604. * @param serializationObject defines the JSON object
  70605. */
  70606. parse(serializationObject: any): void;
  70607. }
  70608. }
  70609. declare module BABYLON {
  70610. /**
  70611. * Particle emitter emitting particles from the inside of a box.
  70612. * It emits the particles randomly between 2 given directions.
  70613. */
  70614. export class BoxParticleEmitter implements IParticleEmitterType {
  70615. /**
  70616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70617. */
  70618. direction1: Vector3;
  70619. /**
  70620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70621. */
  70622. direction2: Vector3;
  70623. /**
  70624. * 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.
  70625. */
  70626. minEmitBox: Vector3;
  70627. /**
  70628. * 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.
  70629. */
  70630. maxEmitBox: Vector3;
  70631. /**
  70632. * Creates a new instance BoxParticleEmitter
  70633. */
  70634. constructor();
  70635. /**
  70636. * Called by the particle System when the direction is computed for the created particle.
  70637. * @param worldMatrix is the world matrix of the particle system
  70638. * @param directionToUpdate is the direction vector to update with the result
  70639. * @param particle is the particle we are computed the direction for
  70640. */
  70641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70642. /**
  70643. * Called by the particle System when the position is computed for the created particle.
  70644. * @param worldMatrix is the world matrix of the particle system
  70645. * @param positionToUpdate is the position vector to update with the result
  70646. * @param particle is the particle we are computed the position for
  70647. */
  70648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70649. /**
  70650. * Clones the current emitter and returns a copy of it
  70651. * @returns the new emitter
  70652. */
  70653. clone(): BoxParticleEmitter;
  70654. /**
  70655. * Called by the GPUParticleSystem to setup the update shader
  70656. * @param effect defines the update shader
  70657. */
  70658. applyToShader(effect: Effect): void;
  70659. /**
  70660. * Returns a string to use to update the GPU particles update shader
  70661. * @returns a string containng the defines string
  70662. */
  70663. getEffectDefines(): string;
  70664. /**
  70665. * Returns the string "BoxParticleEmitter"
  70666. * @returns a string containing the class name
  70667. */
  70668. getClassName(): string;
  70669. /**
  70670. * Serializes the particle system to a JSON object.
  70671. * @returns the JSON object
  70672. */
  70673. serialize(): any;
  70674. /**
  70675. * Parse properties from a JSON object
  70676. * @param serializationObject defines the JSON object
  70677. */
  70678. parse(serializationObject: any): void;
  70679. }
  70680. }
  70681. declare module BABYLON {
  70682. /**
  70683. * Particle emitter emitting particles from the inside of a cone.
  70684. * It emits the particles alongside the cone volume from the base to the particle.
  70685. * The emission direction might be randomized.
  70686. */
  70687. export class ConeParticleEmitter implements IParticleEmitterType {
  70688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  70689. directionRandomizer: number;
  70690. private _radius;
  70691. private _angle;
  70692. private _height;
  70693. /**
  70694. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  70695. */
  70696. radiusRange: number;
  70697. /**
  70698. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  70699. */
  70700. heightRange: number;
  70701. /**
  70702. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  70703. */
  70704. emitFromSpawnPointOnly: boolean;
  70705. /**
  70706. * Gets or sets the radius of the emission cone
  70707. */
  70708. radius: number;
  70709. /**
  70710. * Gets or sets the angle of the emission cone
  70711. */
  70712. angle: number;
  70713. private _buildHeight;
  70714. /**
  70715. * Creates a new instance ConeParticleEmitter
  70716. * @param radius the radius of the emission cone (1 by default)
  70717. * @param angles the cone base angle (PI by default)
  70718. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  70719. */
  70720. constructor(radius?: number, angle?: number,
  70721. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  70722. directionRandomizer?: number);
  70723. /**
  70724. * Called by the particle System when the direction is computed for the created particle.
  70725. * @param worldMatrix is the world matrix of the particle system
  70726. * @param directionToUpdate is the direction vector to update with the result
  70727. * @param particle is the particle we are computed the direction for
  70728. */
  70729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70730. /**
  70731. * Called by the particle System when the position is computed for the created particle.
  70732. * @param worldMatrix is the world matrix of the particle system
  70733. * @param positionToUpdate is the position vector to update with the result
  70734. * @param particle is the particle we are computed the position for
  70735. */
  70736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70737. /**
  70738. * Clones the current emitter and returns a copy of it
  70739. * @returns the new emitter
  70740. */
  70741. clone(): ConeParticleEmitter;
  70742. /**
  70743. * Called by the GPUParticleSystem to setup the update shader
  70744. * @param effect defines the update shader
  70745. */
  70746. applyToShader(effect: Effect): void;
  70747. /**
  70748. * Returns a string to use to update the GPU particles update shader
  70749. * @returns a string containng the defines string
  70750. */
  70751. getEffectDefines(): string;
  70752. /**
  70753. * Returns the string "ConeParticleEmitter"
  70754. * @returns a string containing the class name
  70755. */
  70756. getClassName(): string;
  70757. /**
  70758. * Serializes the particle system to a JSON object.
  70759. * @returns the JSON object
  70760. */
  70761. serialize(): any;
  70762. /**
  70763. * Parse properties from a JSON object
  70764. * @param serializationObject defines the JSON object
  70765. */
  70766. parse(serializationObject: any): void;
  70767. }
  70768. }
  70769. declare module BABYLON {
  70770. /**
  70771. * Particle emitter emitting particles from the inside of a cylinder.
  70772. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  70773. */
  70774. export class CylinderParticleEmitter implements IParticleEmitterType {
  70775. /**
  70776. * The radius of the emission cylinder.
  70777. */
  70778. radius: number;
  70779. /**
  70780. * The height of the emission cylinder.
  70781. */
  70782. height: number;
  70783. /**
  70784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70785. */
  70786. radiusRange: number;
  70787. /**
  70788. * How much to randomize the particle direction [0-1].
  70789. */
  70790. directionRandomizer: number;
  70791. /**
  70792. * Creates a new instance CylinderParticleEmitter
  70793. * @param radius the radius of the emission cylinder (1 by default)
  70794. * @param height the height of the emission cylinder (1 by default)
  70795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  70797. */
  70798. constructor(
  70799. /**
  70800. * The radius of the emission cylinder.
  70801. */
  70802. radius?: number,
  70803. /**
  70804. * The height of the emission cylinder.
  70805. */
  70806. height?: number,
  70807. /**
  70808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70809. */
  70810. radiusRange?: number,
  70811. /**
  70812. * How much to randomize the particle direction [0-1].
  70813. */
  70814. directionRandomizer?: number);
  70815. /**
  70816. * Called by the particle System when the direction is computed for the created particle.
  70817. * @param worldMatrix is the world matrix of the particle system
  70818. * @param directionToUpdate is the direction vector to update with the result
  70819. * @param particle is the particle we are computed the direction for
  70820. */
  70821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70822. /**
  70823. * Called by the particle System when the position is computed for the created particle.
  70824. * @param worldMatrix is the world matrix of the particle system
  70825. * @param positionToUpdate is the position vector to update with the result
  70826. * @param particle is the particle we are computed the position for
  70827. */
  70828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70829. /**
  70830. * Clones the current emitter and returns a copy of it
  70831. * @returns the new emitter
  70832. */
  70833. clone(): CylinderParticleEmitter;
  70834. /**
  70835. * Called by the GPUParticleSystem to setup the update shader
  70836. * @param effect defines the update shader
  70837. */
  70838. applyToShader(effect: Effect): void;
  70839. /**
  70840. * Returns a string to use to update the GPU particles update shader
  70841. * @returns a string containng the defines string
  70842. */
  70843. getEffectDefines(): string;
  70844. /**
  70845. * Returns the string "CylinderParticleEmitter"
  70846. * @returns a string containing the class name
  70847. */
  70848. getClassName(): string;
  70849. /**
  70850. * Serializes the particle system to a JSON object.
  70851. * @returns the JSON object
  70852. */
  70853. serialize(): any;
  70854. /**
  70855. * Parse properties from a JSON object
  70856. * @param serializationObject defines the JSON object
  70857. */
  70858. parse(serializationObject: any): void;
  70859. }
  70860. /**
  70861. * Particle emitter emitting particles from the inside of a cylinder.
  70862. * It emits the particles randomly between two vectors.
  70863. */
  70864. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  70865. /**
  70866. * The min limit of the emission direction.
  70867. */
  70868. direction1: Vector3;
  70869. /**
  70870. * The max limit of the emission direction.
  70871. */
  70872. direction2: Vector3;
  70873. /**
  70874. * Creates a new instance CylinderDirectedParticleEmitter
  70875. * @param radius the radius of the emission cylinder (1 by default)
  70876. * @param height the height of the emission cylinder (1 by default)
  70877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70878. * @param direction1 the min limit of the emission direction (up vector by default)
  70879. * @param direction2 the max limit of the emission direction (up vector by default)
  70880. */
  70881. constructor(radius?: number, height?: number, radiusRange?: number,
  70882. /**
  70883. * The min limit of the emission direction.
  70884. */
  70885. direction1?: Vector3,
  70886. /**
  70887. * The max limit of the emission direction.
  70888. */
  70889. direction2?: Vector3);
  70890. /**
  70891. * Called by the particle System when the direction is computed for the created particle.
  70892. * @param worldMatrix is the world matrix of the particle system
  70893. * @param directionToUpdate is the direction vector to update with the result
  70894. * @param particle is the particle we are computed the direction for
  70895. */
  70896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70897. /**
  70898. * Clones the current emitter and returns a copy of it
  70899. * @returns the new emitter
  70900. */
  70901. clone(): CylinderDirectedParticleEmitter;
  70902. /**
  70903. * Called by the GPUParticleSystem to setup the update shader
  70904. * @param effect defines the update shader
  70905. */
  70906. applyToShader(effect: Effect): void;
  70907. /**
  70908. * Returns a string to use to update the GPU particles update shader
  70909. * @returns a string containng the defines string
  70910. */
  70911. getEffectDefines(): string;
  70912. /**
  70913. * Returns the string "CylinderDirectedParticleEmitter"
  70914. * @returns a string containing the class name
  70915. */
  70916. getClassName(): string;
  70917. /**
  70918. * Serializes the particle system to a JSON object.
  70919. * @returns the JSON object
  70920. */
  70921. serialize(): any;
  70922. /**
  70923. * Parse properties from a JSON object
  70924. * @param serializationObject defines the JSON object
  70925. */
  70926. parse(serializationObject: any): void;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * Particle emitter emitting particles from the inside of a hemisphere.
  70932. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  70933. */
  70934. export class HemisphericParticleEmitter implements IParticleEmitterType {
  70935. /**
  70936. * The radius of the emission hemisphere.
  70937. */
  70938. radius: number;
  70939. /**
  70940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70941. */
  70942. radiusRange: number;
  70943. /**
  70944. * How much to randomize the particle direction [0-1].
  70945. */
  70946. directionRandomizer: number;
  70947. /**
  70948. * Creates a new instance HemisphericParticleEmitter
  70949. * @param radius the radius of the emission hemisphere (1 by default)
  70950. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70951. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  70952. */
  70953. constructor(
  70954. /**
  70955. * The radius of the emission hemisphere.
  70956. */
  70957. radius?: number,
  70958. /**
  70959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70960. */
  70961. radiusRange?: number,
  70962. /**
  70963. * How much to randomize the particle direction [0-1].
  70964. */
  70965. directionRandomizer?: number);
  70966. /**
  70967. * Called by the particle System when the direction is computed for the created particle.
  70968. * @param worldMatrix is the world matrix of the particle system
  70969. * @param directionToUpdate is the direction vector to update with the result
  70970. * @param particle is the particle we are computed the direction for
  70971. */
  70972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70973. /**
  70974. * Called by the particle System when the position is computed for the created particle.
  70975. * @param worldMatrix is the world matrix of the particle system
  70976. * @param positionToUpdate is the position vector to update with the result
  70977. * @param particle is the particle we are computed the position for
  70978. */
  70979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70980. /**
  70981. * Clones the current emitter and returns a copy of it
  70982. * @returns the new emitter
  70983. */
  70984. clone(): HemisphericParticleEmitter;
  70985. /**
  70986. * Called by the GPUParticleSystem to setup the update shader
  70987. * @param effect defines the update shader
  70988. */
  70989. applyToShader(effect: Effect): void;
  70990. /**
  70991. * Returns a string to use to update the GPU particles update shader
  70992. * @returns a string containng the defines string
  70993. */
  70994. getEffectDefines(): string;
  70995. /**
  70996. * Returns the string "HemisphericParticleEmitter"
  70997. * @returns a string containing the class name
  70998. */
  70999. getClassName(): string;
  71000. /**
  71001. * Serializes the particle system to a JSON object.
  71002. * @returns the JSON object
  71003. */
  71004. serialize(): any;
  71005. /**
  71006. * Parse properties from a JSON object
  71007. * @param serializationObject defines the JSON object
  71008. */
  71009. parse(serializationObject: any): void;
  71010. }
  71011. }
  71012. declare module BABYLON {
  71013. /**
  71014. * Particle emitter emitting particles from a point.
  71015. * It emits the particles randomly between 2 given directions.
  71016. */
  71017. export class PointParticleEmitter implements IParticleEmitterType {
  71018. /**
  71019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71020. */
  71021. direction1: Vector3;
  71022. /**
  71023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71024. */
  71025. direction2: Vector3;
  71026. /**
  71027. * Creates a new instance PointParticleEmitter
  71028. */
  71029. constructor();
  71030. /**
  71031. * Called by the particle System when the direction is computed for the created particle.
  71032. * @param worldMatrix is the world matrix of the particle system
  71033. * @param directionToUpdate is the direction vector to update with the result
  71034. * @param particle is the particle we are computed the direction for
  71035. */
  71036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71037. /**
  71038. * Called by the particle System when the position is computed for the created particle.
  71039. * @param worldMatrix is the world matrix of the particle system
  71040. * @param positionToUpdate is the position vector to update with the result
  71041. * @param particle is the particle we are computed the position for
  71042. */
  71043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71044. /**
  71045. * Clones the current emitter and returns a copy of it
  71046. * @returns the new emitter
  71047. */
  71048. clone(): PointParticleEmitter;
  71049. /**
  71050. * Called by the GPUParticleSystem to setup the update shader
  71051. * @param effect defines the update shader
  71052. */
  71053. applyToShader(effect: Effect): void;
  71054. /**
  71055. * Returns a string to use to update the GPU particles update shader
  71056. * @returns a string containng the defines string
  71057. */
  71058. getEffectDefines(): string;
  71059. /**
  71060. * Returns the string "PointParticleEmitter"
  71061. * @returns a string containing the class name
  71062. */
  71063. getClassName(): string;
  71064. /**
  71065. * Serializes the particle system to a JSON object.
  71066. * @returns the JSON object
  71067. */
  71068. serialize(): any;
  71069. /**
  71070. * Parse properties from a JSON object
  71071. * @param serializationObject defines the JSON object
  71072. */
  71073. parse(serializationObject: any): void;
  71074. }
  71075. }
  71076. declare module BABYLON {
  71077. /**
  71078. * Particle emitter emitting particles from the inside of a sphere.
  71079. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  71080. */
  71081. export class SphereParticleEmitter implements IParticleEmitterType {
  71082. /**
  71083. * The radius of the emission sphere.
  71084. */
  71085. radius: number;
  71086. /**
  71087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71088. */
  71089. radiusRange: number;
  71090. /**
  71091. * How much to randomize the particle direction [0-1].
  71092. */
  71093. directionRandomizer: number;
  71094. /**
  71095. * Creates a new instance SphereParticleEmitter
  71096. * @param radius the radius of the emission sphere (1 by default)
  71097. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71098. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71099. */
  71100. constructor(
  71101. /**
  71102. * The radius of the emission sphere.
  71103. */
  71104. radius?: number,
  71105. /**
  71106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71107. */
  71108. radiusRange?: number,
  71109. /**
  71110. * How much to randomize the particle direction [0-1].
  71111. */
  71112. directionRandomizer?: number);
  71113. /**
  71114. * Called by the particle System when the direction is computed for the created particle.
  71115. * @param worldMatrix is the world matrix of the particle system
  71116. * @param directionToUpdate is the direction vector to update with the result
  71117. * @param particle is the particle we are computed the direction for
  71118. */
  71119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71120. /**
  71121. * Called by the particle System when the position is computed for the created particle.
  71122. * @param worldMatrix is the world matrix of the particle system
  71123. * @param positionToUpdate is the position vector to update with the result
  71124. * @param particle is the particle we are computed the position for
  71125. */
  71126. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71127. /**
  71128. * Clones the current emitter and returns a copy of it
  71129. * @returns the new emitter
  71130. */
  71131. clone(): SphereParticleEmitter;
  71132. /**
  71133. * Called by the GPUParticleSystem to setup the update shader
  71134. * @param effect defines the update shader
  71135. */
  71136. applyToShader(effect: Effect): void;
  71137. /**
  71138. * Returns a string to use to update the GPU particles update shader
  71139. * @returns a string containng the defines string
  71140. */
  71141. getEffectDefines(): string;
  71142. /**
  71143. * Returns the string "SphereParticleEmitter"
  71144. * @returns a string containing the class name
  71145. */
  71146. getClassName(): string;
  71147. /**
  71148. * Serializes the particle system to a JSON object.
  71149. * @returns the JSON object
  71150. */
  71151. serialize(): any;
  71152. /**
  71153. * Parse properties from a JSON object
  71154. * @param serializationObject defines the JSON object
  71155. */
  71156. parse(serializationObject: any): void;
  71157. }
  71158. /**
  71159. * Particle emitter emitting particles from the inside of a sphere.
  71160. * It emits the particles randomly between two vectors.
  71161. */
  71162. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  71163. /**
  71164. * The min limit of the emission direction.
  71165. */
  71166. direction1: Vector3;
  71167. /**
  71168. * The max limit of the emission direction.
  71169. */
  71170. direction2: Vector3;
  71171. /**
  71172. * Creates a new instance SphereDirectedParticleEmitter
  71173. * @param radius the radius of the emission sphere (1 by default)
  71174. * @param direction1 the min limit of the emission direction (up vector by default)
  71175. * @param direction2 the max limit of the emission direction (up vector by default)
  71176. */
  71177. constructor(radius?: number,
  71178. /**
  71179. * The min limit of the emission direction.
  71180. */
  71181. direction1?: Vector3,
  71182. /**
  71183. * The max limit of the emission direction.
  71184. */
  71185. direction2?: Vector3);
  71186. /**
  71187. * Called by the particle System when the direction is computed for the created particle.
  71188. * @param worldMatrix is the world matrix of the particle system
  71189. * @param directionToUpdate is the direction vector to update with the result
  71190. * @param particle is the particle we are computed the direction for
  71191. */
  71192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71193. /**
  71194. * Clones the current emitter and returns a copy of it
  71195. * @returns the new emitter
  71196. */
  71197. clone(): SphereDirectedParticleEmitter;
  71198. /**
  71199. * Called by the GPUParticleSystem to setup the update shader
  71200. * @param effect defines the update shader
  71201. */
  71202. applyToShader(effect: Effect): void;
  71203. /**
  71204. * Returns a string to use to update the GPU particles update shader
  71205. * @returns a string containng the defines string
  71206. */
  71207. getEffectDefines(): string;
  71208. /**
  71209. * Returns the string "SphereDirectedParticleEmitter"
  71210. * @returns a string containing the class name
  71211. */
  71212. getClassName(): string;
  71213. /**
  71214. * Serializes the particle system to a JSON object.
  71215. * @returns the JSON object
  71216. */
  71217. serialize(): any;
  71218. /**
  71219. * Parse properties from a JSON object
  71220. * @param serializationObject defines the JSON object
  71221. */
  71222. parse(serializationObject: any): void;
  71223. }
  71224. }
  71225. declare module BABYLON {
  71226. /**
  71227. * Interface representing a particle system in Babylon.js.
  71228. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  71229. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  71230. */
  71231. export interface IParticleSystem {
  71232. /**
  71233. * List of animations used by the particle system.
  71234. */
  71235. animations: Animation[];
  71236. /**
  71237. * The id of the Particle system.
  71238. */
  71239. id: string;
  71240. /**
  71241. * The name of the Particle system.
  71242. */
  71243. name: string;
  71244. /**
  71245. * The emitter represents the Mesh or position we are attaching the particle system to.
  71246. */
  71247. emitter: Nullable<AbstractMesh | Vector3>;
  71248. /**
  71249. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71250. */
  71251. isBillboardBased: boolean;
  71252. /**
  71253. * The rendering group used by the Particle system to chose when to render.
  71254. */
  71255. renderingGroupId: number;
  71256. /**
  71257. * The layer mask we are rendering the particles through.
  71258. */
  71259. layerMask: number;
  71260. /**
  71261. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71262. */
  71263. updateSpeed: number;
  71264. /**
  71265. * The amount of time the particle system is running (depends of the overall update speed).
  71266. */
  71267. targetStopDuration: number;
  71268. /**
  71269. * The texture used to render each particle. (this can be a spritesheet)
  71270. */
  71271. particleTexture: Nullable<Texture>;
  71272. /**
  71273. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  71274. */
  71275. blendMode: number;
  71276. /**
  71277. * Minimum life time of emitting particles.
  71278. */
  71279. minLifeTime: number;
  71280. /**
  71281. * Maximum life time of emitting particles.
  71282. */
  71283. maxLifeTime: number;
  71284. /**
  71285. * Minimum Size of emitting particles.
  71286. */
  71287. minSize: number;
  71288. /**
  71289. * Maximum Size of emitting particles.
  71290. */
  71291. maxSize: number;
  71292. /**
  71293. * Minimum scale of emitting particles on X axis.
  71294. */
  71295. minScaleX: number;
  71296. /**
  71297. * Maximum scale of emitting particles on X axis.
  71298. */
  71299. maxScaleX: number;
  71300. /**
  71301. * Minimum scale of emitting particles on Y axis.
  71302. */
  71303. minScaleY: number;
  71304. /**
  71305. * Maximum scale of emitting particles on Y axis.
  71306. */
  71307. maxScaleY: number;
  71308. /**
  71309. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71310. */
  71311. color1: Color4;
  71312. /**
  71313. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71314. */
  71315. color2: Color4;
  71316. /**
  71317. * Color the particle will have at the end of its lifetime.
  71318. */
  71319. colorDead: Color4;
  71320. /**
  71321. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  71322. */
  71323. emitRate: number;
  71324. /**
  71325. * You can use gravity if you want to give an orientation to your particles.
  71326. */
  71327. gravity: Vector3;
  71328. /**
  71329. * Minimum power of emitting particles.
  71330. */
  71331. minEmitPower: number;
  71332. /**
  71333. * Maximum power of emitting particles.
  71334. */
  71335. maxEmitPower: number;
  71336. /**
  71337. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71338. */
  71339. minAngularSpeed: number;
  71340. /**
  71341. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71342. */
  71343. maxAngularSpeed: number;
  71344. /**
  71345. * Gets or sets the minimal initial rotation in radians.
  71346. */
  71347. minInitialRotation: number;
  71348. /**
  71349. * Gets or sets the maximal initial rotation in radians.
  71350. */
  71351. maxInitialRotation: number;
  71352. /**
  71353. * The particle emitter type defines the emitter used by the particle system.
  71354. * It can be for example box, sphere, or cone...
  71355. */
  71356. particleEmitterType: Nullable<IParticleEmitterType>;
  71357. /**
  71358. * Defines the delay in milliseconds before starting the system (0 by default)
  71359. */
  71360. startDelay: number;
  71361. /**
  71362. * 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
  71363. */
  71364. preWarmCycles: number;
  71365. /**
  71366. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  71367. */
  71368. preWarmStepOffset: number;
  71369. /**
  71370. * 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)
  71371. */
  71372. spriteCellChangeSpeed: number;
  71373. /**
  71374. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71375. */
  71376. startSpriteCellID: number;
  71377. /**
  71378. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71379. */
  71380. endSpriteCellID: number;
  71381. /**
  71382. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71383. */
  71384. spriteCellWidth: number;
  71385. /**
  71386. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71387. */
  71388. spriteCellHeight: number;
  71389. /**
  71390. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71391. */
  71392. spriteRandomStartCell: boolean;
  71393. /**
  71394. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  71395. */
  71396. isAnimationSheetEnabled: boolean;
  71397. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71398. translationPivot: Vector2;
  71399. /**
  71400. * Gets or sets a texture used to add random noise to particle positions
  71401. */
  71402. noiseTexture: Nullable<BaseTexture>;
  71403. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71404. noiseStrength: Vector3;
  71405. /**
  71406. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71407. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71408. */
  71409. billboardMode: number;
  71410. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71411. limitVelocityDamping: number;
  71412. /**
  71413. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71414. */
  71415. beginAnimationOnStart: boolean;
  71416. /**
  71417. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71418. */
  71419. beginAnimationFrom: number;
  71420. /**
  71421. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71422. */
  71423. beginAnimationTo: number;
  71424. /**
  71425. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71426. */
  71427. beginAnimationLoop: boolean;
  71428. /**
  71429. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71430. */
  71431. disposeOnStop: boolean;
  71432. /**
  71433. * Gets the maximum number of particles active at the same time.
  71434. * @returns The max number of active particles.
  71435. */
  71436. getCapacity(): number;
  71437. /**
  71438. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71439. * @returns True if it has been started, otherwise false.
  71440. */
  71441. isStarted(): boolean;
  71442. /**
  71443. * Animates the particle system for this frame.
  71444. */
  71445. animate(): void;
  71446. /**
  71447. * Renders the particle system in its current state.
  71448. * @returns the current number of particles
  71449. */
  71450. render(): number;
  71451. /**
  71452. * Dispose the particle system and frees its associated resources.
  71453. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71454. */
  71455. dispose(disposeTexture?: boolean): void;
  71456. /**
  71457. * Clones the particle system.
  71458. * @param name The name of the cloned object
  71459. * @param newEmitter The new emitter to use
  71460. * @returns the cloned particle system
  71461. */
  71462. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  71463. /**
  71464. * Serializes the particle system to a JSON object.
  71465. * @returns the JSON object
  71466. */
  71467. serialize(): any;
  71468. /**
  71469. * Rebuild the particle system
  71470. */
  71471. rebuild(): void;
  71472. /**
  71473. * Starts the particle system and begins to emit
  71474. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  71475. */
  71476. start(delay?: number): void;
  71477. /**
  71478. * Stops the particle system.
  71479. */
  71480. stop(): void;
  71481. /**
  71482. * Remove all active particles
  71483. */
  71484. reset(): void;
  71485. /**
  71486. * Is this system ready to be used/rendered
  71487. * @return true if the system is ready
  71488. */
  71489. isReady(): boolean;
  71490. /**
  71491. * Adds a new color gradient
  71492. * @param gradient defines the gradient to use (between 0 and 1)
  71493. * @param color1 defines the color to affect to the specified gradient
  71494. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71495. * @returns the current particle system
  71496. */
  71497. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71498. /**
  71499. * Remove a specific color gradient
  71500. * @param gradient defines the gradient to remove
  71501. * @returns the current particle system
  71502. */
  71503. removeColorGradient(gradient: number): IParticleSystem;
  71504. /**
  71505. * Adds a new size gradient
  71506. * @param gradient defines the gradient to use (between 0 and 1)
  71507. * @param factor defines the size factor to affect to the specified gradient
  71508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71509. * @returns the current particle system
  71510. */
  71511. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71512. /**
  71513. * Remove a specific size gradient
  71514. * @param gradient defines the gradient to remove
  71515. * @returns the current particle system
  71516. */
  71517. removeSizeGradient(gradient: number): IParticleSystem;
  71518. /**
  71519. * Gets the current list of color gradients.
  71520. * You must use addColorGradient and removeColorGradient to udpate this list
  71521. * @returns the list of color gradients
  71522. */
  71523. getColorGradients(): Nullable<Array<ColorGradient>>;
  71524. /**
  71525. * Gets the current list of size gradients.
  71526. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71527. * @returns the list of size gradients
  71528. */
  71529. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71530. /**
  71531. * Gets the current list of angular speed gradients.
  71532. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71533. * @returns the list of angular speed gradients
  71534. */
  71535. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71536. /**
  71537. * Adds a new angular speed gradient
  71538. * @param gradient defines the gradient to use (between 0 and 1)
  71539. * @param factor defines the angular speed to affect to the specified gradient
  71540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71541. * @returns the current particle system
  71542. */
  71543. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71544. /**
  71545. * Remove a specific angular speed gradient
  71546. * @param gradient defines the gradient to remove
  71547. * @returns the current particle system
  71548. */
  71549. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71550. /**
  71551. * Gets the current list of velocity gradients.
  71552. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71553. * @returns the list of velocity gradients
  71554. */
  71555. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71556. /**
  71557. * Adds a new velocity gradient
  71558. * @param gradient defines the gradient to use (between 0 and 1)
  71559. * @param factor defines the velocity to affect to the specified gradient
  71560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71561. * @returns the current particle system
  71562. */
  71563. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71564. /**
  71565. * Remove a specific velocity gradient
  71566. * @param gradient defines the gradient to remove
  71567. * @returns the current particle system
  71568. */
  71569. removeVelocityGradient(gradient: number): IParticleSystem;
  71570. /**
  71571. * Gets the current list of limit velocity gradients.
  71572. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71573. * @returns the list of limit velocity gradients
  71574. */
  71575. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71576. /**
  71577. * Adds a new limit velocity gradient
  71578. * @param gradient defines the gradient to use (between 0 and 1)
  71579. * @param factor defines the limit velocity to affect to the specified gradient
  71580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71581. * @returns the current particle system
  71582. */
  71583. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71584. /**
  71585. * Remove a specific limit velocity gradient
  71586. * @param gradient defines the gradient to remove
  71587. * @returns the current particle system
  71588. */
  71589. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71590. /**
  71591. * Adds a new drag gradient
  71592. * @param gradient defines the gradient to use (between 0 and 1)
  71593. * @param factor defines the drag to affect to the specified gradient
  71594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71595. * @returns the current particle system
  71596. */
  71597. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71598. /**
  71599. * Remove a specific drag gradient
  71600. * @param gradient defines the gradient to remove
  71601. * @returns the current particle system
  71602. */
  71603. removeDragGradient(gradient: number): IParticleSystem;
  71604. /**
  71605. * Gets the current list of drag gradients.
  71606. * You must use addDragGradient and removeDragGradient to udpate this list
  71607. * @returns the list of drag gradients
  71608. */
  71609. getDragGradients(): Nullable<Array<FactorGradient>>;
  71610. /**
  71611. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71612. * @param gradient defines the gradient to use (between 0 and 1)
  71613. * @param factor defines the emit rate to affect to the specified gradient
  71614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71615. * @returns the current particle system
  71616. */
  71617. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71618. /**
  71619. * Remove a specific emit rate gradient
  71620. * @param gradient defines the gradient to remove
  71621. * @returns the current particle system
  71622. */
  71623. removeEmitRateGradient(gradient: number): IParticleSystem;
  71624. /**
  71625. * Gets the current list of emit rate gradients.
  71626. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71627. * @returns the list of emit rate gradients
  71628. */
  71629. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71630. /**
  71631. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71632. * @param gradient defines the gradient to use (between 0 and 1)
  71633. * @param factor defines the start size to affect to the specified gradient
  71634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71635. * @returns the current particle system
  71636. */
  71637. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71638. /**
  71639. * Remove a specific start size gradient
  71640. * @param gradient defines the gradient to remove
  71641. * @returns the current particle system
  71642. */
  71643. removeStartSizeGradient(gradient: number): IParticleSystem;
  71644. /**
  71645. * Gets the current list of start size gradients.
  71646. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71647. * @returns the list of start size gradients
  71648. */
  71649. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71650. /**
  71651. * Adds a new life time gradient
  71652. * @param gradient defines the gradient to use (between 0 and 1)
  71653. * @param factor defines the life time factor to affect to the specified gradient
  71654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71655. * @returns the current particle system
  71656. */
  71657. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71658. /**
  71659. * Remove a specific life time gradient
  71660. * @param gradient defines the gradient to remove
  71661. * @returns the current particle system
  71662. */
  71663. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71664. /**
  71665. * Gets the current list of life time gradients.
  71666. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71667. * @returns the list of life time gradients
  71668. */
  71669. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71670. /**
  71671. * Gets the current list of color gradients.
  71672. * You must use addColorGradient and removeColorGradient to udpate this list
  71673. * @returns the list of color gradients
  71674. */
  71675. getColorGradients(): Nullable<Array<ColorGradient>>;
  71676. /**
  71677. * Adds a new ramp gradient used to remap particle colors
  71678. * @param gradient defines the gradient to use (between 0 and 1)
  71679. * @param color defines the color to affect to the specified gradient
  71680. * @returns the current particle system
  71681. */
  71682. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71683. /**
  71684. * Gets the current list of ramp gradients.
  71685. * You must use addRampGradient and removeRampGradient to udpate this list
  71686. * @returns the list of ramp gradients
  71687. */
  71688. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71689. /** Gets or sets a boolean indicating that ramp gradients must be used
  71690. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71691. */
  71692. useRampGradients: boolean;
  71693. /**
  71694. * Adds a new color remap gradient
  71695. * @param gradient defines the gradient to use (between 0 and 1)
  71696. * @param min defines the color remap minimal range
  71697. * @param max defines the color remap maximal range
  71698. * @returns the current particle system
  71699. */
  71700. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71701. /**
  71702. * Gets the current list of color remap gradients.
  71703. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71704. * @returns the list of color remap gradients
  71705. */
  71706. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71707. /**
  71708. * Adds a new alpha remap gradient
  71709. * @param gradient defines the gradient to use (between 0 and 1)
  71710. * @param min defines the alpha remap minimal range
  71711. * @param max defines the alpha remap maximal range
  71712. * @returns the current particle system
  71713. */
  71714. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71715. /**
  71716. * Gets the current list of alpha remap gradients.
  71717. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71718. * @returns the list of alpha remap gradients
  71719. */
  71720. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71721. /**
  71722. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71725. * @returns the emitter
  71726. */
  71727. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71728. /**
  71729. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71730. * @param radius The radius of the hemisphere to emit from
  71731. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71732. * @returns the emitter
  71733. */
  71734. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  71735. /**
  71736. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71737. * @param radius The radius of the sphere to emit from
  71738. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71739. * @returns the emitter
  71740. */
  71741. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  71742. /**
  71743. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71744. * @param radius The radius of the sphere to emit from
  71745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71747. * @returns the emitter
  71748. */
  71749. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  71750. /**
  71751. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71752. * @param radius The radius of the emission cylinder
  71753. * @param height The height of the emission cylinder
  71754. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71755. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71756. * @returns the emitter
  71757. */
  71758. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  71759. /**
  71760. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71761. * @param radius The radius of the cylinder to emit from
  71762. * @param height The height of the emission cylinder
  71763. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71766. * @returns the emitter
  71767. */
  71768. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  71769. /**
  71770. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71771. * @param radius The radius of the cone to emit from
  71772. * @param angle The base angle of the cone
  71773. * @returns the emitter
  71774. */
  71775. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  71776. /**
  71777. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71778. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71779. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71780. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71781. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71782. * @returns the emitter
  71783. */
  71784. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71785. /**
  71786. * Get hosting scene
  71787. * @returns the scene
  71788. */
  71789. getScene(): Scene;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /**
  71794. * Creates an instance based on a source mesh.
  71795. */
  71796. export class InstancedMesh extends AbstractMesh {
  71797. private _sourceMesh;
  71798. private _currentLOD;
  71799. /** @hidden */
  71800. _indexInSourceMeshInstanceArray: number;
  71801. constructor(name: string, source: Mesh);
  71802. /**
  71803. * Returns the string "InstancedMesh".
  71804. */
  71805. getClassName(): string;
  71806. /**
  71807. * If the source mesh receives shadows
  71808. */
  71809. readonly receiveShadows: boolean;
  71810. /**
  71811. * The material of the source mesh
  71812. */
  71813. readonly material: Nullable<Material>;
  71814. /**
  71815. * Visibility of the source mesh
  71816. */
  71817. readonly visibility: number;
  71818. /**
  71819. * Skeleton of the source mesh
  71820. */
  71821. readonly skeleton: Nullable<Skeleton>;
  71822. /**
  71823. * Rendering ground id of the source mesh
  71824. */
  71825. renderingGroupId: number;
  71826. /**
  71827. * Returns the total number of vertices (integer).
  71828. */
  71829. getTotalVertices(): number;
  71830. /**
  71831. * Returns a positive integer : the total number of indices in this mesh geometry.
  71832. * @returns the numner of indices or zero if the mesh has no geometry.
  71833. */
  71834. getTotalIndices(): number;
  71835. /**
  71836. * The source mesh of the instance
  71837. */
  71838. readonly sourceMesh: Mesh;
  71839. /**
  71840. * Is this node ready to be used/rendered
  71841. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  71842. * @return {boolean} is it ready
  71843. */
  71844. isReady(completeCheck?: boolean): boolean;
  71845. /**
  71846. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  71847. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  71848. * @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.
  71849. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  71850. */
  71851. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  71852. /**
  71853. * Sets the vertex data of the mesh geometry for the requested `kind`.
  71854. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  71855. * The `data` are either a numeric array either a Float32Array.
  71856. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  71857. * 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).
  71858. * Note that a new underlying VertexBuffer object is created each call.
  71859. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  71860. *
  71861. * Possible `kind` values :
  71862. * - VertexBuffer.PositionKind
  71863. * - VertexBuffer.UVKind
  71864. * - VertexBuffer.UV2Kind
  71865. * - VertexBuffer.UV3Kind
  71866. * - VertexBuffer.UV4Kind
  71867. * - VertexBuffer.UV5Kind
  71868. * - VertexBuffer.UV6Kind
  71869. * - VertexBuffer.ColorKind
  71870. * - VertexBuffer.MatricesIndicesKind
  71871. * - VertexBuffer.MatricesIndicesExtraKind
  71872. * - VertexBuffer.MatricesWeightsKind
  71873. * - VertexBuffer.MatricesWeightsExtraKind
  71874. *
  71875. * Returns the Mesh.
  71876. */
  71877. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  71878. /**
  71879. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  71880. * If the mesh has no geometry, it is simply returned as it is.
  71881. * The `data` are either a numeric array either a Float32Array.
  71882. * No new underlying VertexBuffer object is created.
  71883. * 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.
  71884. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  71885. *
  71886. * Possible `kind` values :
  71887. * - VertexBuffer.PositionKind
  71888. * - VertexBuffer.UVKind
  71889. * - VertexBuffer.UV2Kind
  71890. * - VertexBuffer.UV3Kind
  71891. * - VertexBuffer.UV4Kind
  71892. * - VertexBuffer.UV5Kind
  71893. * - VertexBuffer.UV6Kind
  71894. * - VertexBuffer.ColorKind
  71895. * - VertexBuffer.MatricesIndicesKind
  71896. * - VertexBuffer.MatricesIndicesExtraKind
  71897. * - VertexBuffer.MatricesWeightsKind
  71898. * - VertexBuffer.MatricesWeightsExtraKind
  71899. *
  71900. * Returns the Mesh.
  71901. */
  71902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  71903. /**
  71904. * Sets the mesh indices.
  71905. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  71906. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  71907. * This method creates a new index buffer each call.
  71908. * Returns the Mesh.
  71909. */
  71910. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  71911. /**
  71912. * Boolean : True if the mesh owns the requested kind of data.
  71913. */
  71914. isVerticesDataPresent(kind: string): boolean;
  71915. /**
  71916. * Returns an array of indices (IndicesArray).
  71917. */
  71918. getIndices(): Nullable<IndicesArray>;
  71919. readonly _positions: Nullable<Vector3[]>;
  71920. /**
  71921. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  71922. * This means the mesh underlying bounding box and sphere are recomputed.
  71923. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  71924. * @returns the current mesh
  71925. */
  71926. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  71927. /** @hidden */
  71928. _preActivate(): InstancedMesh;
  71929. /** @hidden */
  71930. _activate(renderId: number): InstancedMesh;
  71931. /**
  71932. * Returns the current associated LOD AbstractMesh.
  71933. */
  71934. getLOD(camera: Camera): AbstractMesh;
  71935. /** @hidden */
  71936. _syncSubMeshes(): InstancedMesh;
  71937. /** @hidden */
  71938. _generatePointsArray(): boolean;
  71939. /**
  71940. * Creates a new InstancedMesh from the current mesh.
  71941. * - name (string) : the cloned mesh name
  71942. * - newParent (optional Node) : the optional Node to parent the clone to.
  71943. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  71944. *
  71945. * Returns the clone.
  71946. */
  71947. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  71948. /**
  71949. * Disposes the InstancedMesh.
  71950. * Returns nothing.
  71951. */
  71952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71953. }
  71954. }
  71955. declare module BABYLON {
  71956. /**
  71957. * Defines the options associated with the creation of a shader material.
  71958. */
  71959. export interface IShaderMaterialOptions {
  71960. /**
  71961. * Does the material work in alpha blend mode
  71962. */
  71963. needAlphaBlending: boolean;
  71964. /**
  71965. * Does the material work in alpha test mode
  71966. */
  71967. needAlphaTesting: boolean;
  71968. /**
  71969. * The list of attribute names used in the shader
  71970. */
  71971. attributes: string[];
  71972. /**
  71973. * The list of unifrom names used in the shader
  71974. */
  71975. uniforms: string[];
  71976. /**
  71977. * The list of UBO names used in the shader
  71978. */
  71979. uniformBuffers: string[];
  71980. /**
  71981. * The list of sampler names used in the shader
  71982. */
  71983. samplers: string[];
  71984. /**
  71985. * The list of defines used in the shader
  71986. */
  71987. defines: string[];
  71988. }
  71989. /**
  71990. * 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.
  71991. *
  71992. * This returned material effects how the mesh will look based on the code in the shaders.
  71993. *
  71994. * @see http://doc.babylonjs.com/how_to/shader_material
  71995. */
  71996. export class ShaderMaterial extends Material {
  71997. private _shaderPath;
  71998. private _options;
  71999. private _textures;
  72000. private _textureArrays;
  72001. private _floats;
  72002. private _ints;
  72003. private _floatsArrays;
  72004. private _colors3;
  72005. private _colors3Arrays;
  72006. private _colors4;
  72007. private _vectors2;
  72008. private _vectors3;
  72009. private _vectors4;
  72010. private _matrices;
  72011. private _matrices3x3;
  72012. private _matrices2x2;
  72013. private _vectors2Arrays;
  72014. private _vectors3Arrays;
  72015. private _cachedWorldViewMatrix;
  72016. private _renderId;
  72017. /**
  72018. * Instantiate a new shader material.
  72019. * 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.
  72020. * This returned material effects how the mesh will look based on the code in the shaders.
  72021. * @see http://doc.babylonjs.com/how_to/shader_material
  72022. * @param name Define the name of the material in the scene
  72023. * @param scene Define the scene the material belongs to
  72024. * @param shaderPath Defines the route to the shader code in one of three ways:
  72025. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  72026. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  72027. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  72028. * @param options Define the options used to create the shader
  72029. */
  72030. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  72031. /**
  72032. * Gets the current class name of the material e.g. "ShaderMaterial"
  72033. * Mainly use in serialization.
  72034. * @returns the class name
  72035. */
  72036. getClassName(): string;
  72037. /**
  72038. * Specifies if the material will require alpha blending
  72039. * @returns a boolean specifying if alpha blending is needed
  72040. */
  72041. needAlphaBlending(): boolean;
  72042. /**
  72043. * Specifies if this material should be rendered in alpha test mode
  72044. * @returns a boolean specifying if an alpha test is needed.
  72045. */
  72046. needAlphaTesting(): boolean;
  72047. private _checkUniform;
  72048. /**
  72049. * Set a texture in the shader.
  72050. * @param name Define the name of the uniform samplers as defined in the shader
  72051. * @param texture Define the texture to bind to this sampler
  72052. * @return the material itself allowing "fluent" like uniform updates
  72053. */
  72054. setTexture(name: string, texture: Texture): ShaderMaterial;
  72055. /**
  72056. * Set a texture array in the shader.
  72057. * @param name Define the name of the uniform sampler array as defined in the shader
  72058. * @param textures Define the list of textures to bind to this sampler
  72059. * @return the material itself allowing "fluent" like uniform updates
  72060. */
  72061. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  72062. /**
  72063. * Set a float in the shader.
  72064. * @param name Define the name of the uniform as defined in the shader
  72065. * @param value Define the value to give to the uniform
  72066. * @return the material itself allowing "fluent" like uniform updates
  72067. */
  72068. setFloat(name: string, value: number): ShaderMaterial;
  72069. /**
  72070. * Set a int in the shader.
  72071. * @param name Define the name of the uniform as defined in the shader
  72072. * @param value Define the value to give to the uniform
  72073. * @return the material itself allowing "fluent" like uniform updates
  72074. */
  72075. setInt(name: string, value: number): ShaderMaterial;
  72076. /**
  72077. * Set an array of floats in the shader.
  72078. * @param name Define the name of the uniform as defined in the shader
  72079. * @param value Define the value to give to the uniform
  72080. * @return the material itself allowing "fluent" like uniform updates
  72081. */
  72082. setFloats(name: string, value: number[]): ShaderMaterial;
  72083. /**
  72084. * Set a vec3 in the shader from a Color3.
  72085. * @param name Define the name of the uniform as defined in the shader
  72086. * @param value Define the value to give to the uniform
  72087. * @return the material itself allowing "fluent" like uniform updates
  72088. */
  72089. setColor3(name: string, value: Color3): ShaderMaterial;
  72090. /**
  72091. * Set a vec3 array in the shader from a Color3 array.
  72092. * @param name Define the name of the uniform as defined in the shader
  72093. * @param value Define the value to give to the uniform
  72094. * @return the material itself allowing "fluent" like uniform updates
  72095. */
  72096. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  72097. /**
  72098. * Set a vec4 in the shader from a Color4.
  72099. * @param name Define the name of the uniform as defined in the shader
  72100. * @param value Define the value to give to the uniform
  72101. * @return the material itself allowing "fluent" like uniform updates
  72102. */
  72103. setColor4(name: string, value: Color4): ShaderMaterial;
  72104. /**
  72105. * Set a vec2 in the shader from a Vector2.
  72106. * @param name Define the name of the uniform as defined in the shader
  72107. * @param value Define the value to give to the uniform
  72108. * @return the material itself allowing "fluent" like uniform updates
  72109. */
  72110. setVector2(name: string, value: Vector2): ShaderMaterial;
  72111. /**
  72112. * Set a vec3 in the shader from a Vector3.
  72113. * @param name Define the name of the uniform as defined in the shader
  72114. * @param value Define the value to give to the uniform
  72115. * @return the material itself allowing "fluent" like uniform updates
  72116. */
  72117. setVector3(name: string, value: Vector3): ShaderMaterial;
  72118. /**
  72119. * Set a vec4 in the shader from a Vector4.
  72120. * @param name Define the name of the uniform as defined in the shader
  72121. * @param value Define the value to give to the uniform
  72122. * @return the material itself allowing "fluent" like uniform updates
  72123. */
  72124. setVector4(name: string, value: Vector4): ShaderMaterial;
  72125. /**
  72126. * Set a mat4 in the shader from a Matrix.
  72127. * @param name Define the name of the uniform as defined in the shader
  72128. * @param value Define the value to give to the uniform
  72129. * @return the material itself allowing "fluent" like uniform updates
  72130. */
  72131. setMatrix(name: string, value: Matrix): ShaderMaterial;
  72132. /**
  72133. * Set a mat3 in the shader from a Float32Array.
  72134. * @param name Define the name of the uniform as defined in the shader
  72135. * @param value Define the value to give to the uniform
  72136. * @return the material itself allowing "fluent" like uniform updates
  72137. */
  72138. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  72139. /**
  72140. * Set a mat2 in the shader from a Float32Array.
  72141. * @param name Define the name of the uniform as defined in the shader
  72142. * @param value Define the value to give to the uniform
  72143. * @return the material itself allowing "fluent" like uniform updates
  72144. */
  72145. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  72146. /**
  72147. * Set a vec2 array in the shader from a number array.
  72148. * @param name Define the name of the uniform as defined in the shader
  72149. * @param value Define the value to give to the uniform
  72150. * @return the material itself allowing "fluent" like uniform updates
  72151. */
  72152. setArray2(name: string, value: number[]): ShaderMaterial;
  72153. /**
  72154. * Set a vec3 array in the shader from a number array.
  72155. * @param name Define the name of the uniform as defined in the shader
  72156. * @param value Define the value to give to the uniform
  72157. * @return the material itself allowing "fluent" like uniform updates
  72158. */
  72159. setArray3(name: string, value: number[]): ShaderMaterial;
  72160. private _checkCache;
  72161. /**
  72162. * Checks if the material is ready to render the requested mesh
  72163. * @param mesh Define the mesh to render
  72164. * @param useInstances Define whether or not the material is used with instances
  72165. * @returns true if ready, otherwise false
  72166. */
  72167. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  72168. /**
  72169. * Binds the world matrix to the material
  72170. * @param world defines the world transformation matrix
  72171. */
  72172. bindOnlyWorldMatrix(world: Matrix): void;
  72173. /**
  72174. * Binds the material to the mesh
  72175. * @param world defines the world transformation matrix
  72176. * @param mesh defines the mesh to bind the material to
  72177. */
  72178. bind(world: Matrix, mesh?: Mesh): void;
  72179. /**
  72180. * Gets the active textures from the material
  72181. * @returns an array of textures
  72182. */
  72183. getActiveTextures(): BaseTexture[];
  72184. /**
  72185. * Specifies if the material uses a texture
  72186. * @param texture defines the texture to check against the material
  72187. * @returns a boolean specifying if the material uses the texture
  72188. */
  72189. hasTexture(texture: BaseTexture): boolean;
  72190. /**
  72191. * Makes a duplicate of the material, and gives it a new name
  72192. * @param name defines the new name for the duplicated material
  72193. * @returns the cloned material
  72194. */
  72195. clone(name: string): ShaderMaterial;
  72196. /**
  72197. * Disposes the material
  72198. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72199. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  72200. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  72201. */
  72202. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  72203. /**
  72204. * Serializes this material in a JSON representation
  72205. * @returns the serialized material object
  72206. */
  72207. serialize(): any;
  72208. /**
  72209. * Creates a shader material from parsed shader material data
  72210. * @param source defines the JSON represnetation of the material
  72211. * @param scene defines the hosting scene
  72212. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72213. * @returns a new material
  72214. */
  72215. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /** @hidden */
  72220. export var colorPixelShader: {
  72221. name: string;
  72222. shader: string;
  72223. };
  72224. }
  72225. declare module BABYLON {
  72226. /** @hidden */
  72227. export var colorVertexShader: {
  72228. name: string;
  72229. shader: string;
  72230. };
  72231. }
  72232. declare module BABYLON {
  72233. /**
  72234. * Line mesh
  72235. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  72236. */
  72237. export class LinesMesh extends Mesh {
  72238. /**
  72239. * If vertex color should be applied to the mesh
  72240. */
  72241. useVertexColor?: boolean | undefined;
  72242. /**
  72243. * If vertex alpha should be applied to the mesh
  72244. */
  72245. useVertexAlpha?: boolean | undefined;
  72246. /**
  72247. * Color of the line (Default: White)
  72248. */
  72249. color: Color3;
  72250. /**
  72251. * Alpha of the line (Default: 1)
  72252. */
  72253. alpha: number;
  72254. /**
  72255. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72256. * This margin is expressed in world space coordinates, so its value may vary.
  72257. * Default value is 0.1
  72258. */
  72259. intersectionThreshold: number;
  72260. private _colorShader;
  72261. /**
  72262. * Creates a new LinesMesh
  72263. * @param name defines the name
  72264. * @param scene defines the hosting scene
  72265. * @param parent defines the parent mesh if any
  72266. * @param source defines the optional source LinesMesh used to clone data from
  72267. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  72268. * When false, achieved by calling a clone(), also passing False.
  72269. * This will make creation of children, recursive.
  72270. * @param useVertexColor defines if this LinesMesh supports vertex color
  72271. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  72272. */
  72273. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  72274. /**
  72275. * If vertex color should be applied to the mesh
  72276. */
  72277. useVertexColor?: boolean | undefined,
  72278. /**
  72279. * If vertex alpha should be applied to the mesh
  72280. */
  72281. useVertexAlpha?: boolean | undefined);
  72282. /**
  72283. * Returns the string "LineMesh"
  72284. */
  72285. getClassName(): string;
  72286. /**
  72287. * @hidden
  72288. */
  72289. /**
  72290. * @hidden
  72291. */
  72292. material: Material;
  72293. /**
  72294. * @hidden
  72295. */
  72296. readonly checkCollisions: boolean;
  72297. /** @hidden */
  72298. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  72299. /** @hidden */
  72300. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  72301. /**
  72302. * Disposes of the line mesh
  72303. * @param doNotRecurse If children should be disposed
  72304. */
  72305. dispose(doNotRecurse?: boolean): void;
  72306. /**
  72307. * Returns a new LineMesh object cloned from the current one.
  72308. */
  72309. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  72310. /**
  72311. * Creates a new InstancedLinesMesh object from the mesh model.
  72312. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  72313. * @param name defines the name of the new instance
  72314. * @returns a new InstancedLinesMesh
  72315. */
  72316. createInstance(name: string): InstancedLinesMesh;
  72317. }
  72318. /**
  72319. * Creates an instance based on a source LinesMesh
  72320. */
  72321. export class InstancedLinesMesh extends InstancedMesh {
  72322. /**
  72323. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72324. * This margin is expressed in world space coordinates, so its value may vary.
  72325. * Initilized with the intersectionThreshold value of the source LinesMesh
  72326. */
  72327. intersectionThreshold: number;
  72328. constructor(name: string, source: LinesMesh);
  72329. /**
  72330. * Returns the string "InstancedLinesMesh".
  72331. */
  72332. getClassName(): string;
  72333. }
  72334. }
  72335. declare module BABYLON {
  72336. /** @hidden */
  72337. export var linePixelShader: {
  72338. name: string;
  72339. shader: string;
  72340. };
  72341. }
  72342. declare module BABYLON {
  72343. /** @hidden */
  72344. export var lineVertexShader: {
  72345. name: string;
  72346. shader: string;
  72347. };
  72348. }
  72349. declare module BABYLON {
  72350. interface AbstractMesh {
  72351. /**
  72352. * Disables the mesh edge rendering mode
  72353. * @returns the currentAbstractMesh
  72354. */
  72355. disableEdgesRendering(): AbstractMesh;
  72356. /**
  72357. * Enables the edge rendering mode on the mesh.
  72358. * This mode makes the mesh edges visible
  72359. * @param epsilon defines the maximal distance between two angles to detect a face
  72360. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72361. * @returns the currentAbstractMesh
  72362. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72363. */
  72364. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72365. /**
  72366. * Gets the edgesRenderer associated with the mesh
  72367. */
  72368. edgesRenderer: Nullable<EdgesRenderer>;
  72369. }
  72370. interface LinesMesh {
  72371. /**
  72372. * Enables the edge rendering mode on the mesh.
  72373. * This mode makes the mesh edges visible
  72374. * @param epsilon defines the maximal distance between two angles to detect a face
  72375. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72376. * @returns the currentAbstractMesh
  72377. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72378. */
  72379. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72380. }
  72381. interface InstancedLinesMesh {
  72382. /**
  72383. * Enables the edge rendering mode on the mesh.
  72384. * This mode makes the mesh edges visible
  72385. * @param epsilon defines the maximal distance between two angles to detect a face
  72386. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72387. * @returns the current InstancedLinesMesh
  72388. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72389. */
  72390. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  72391. }
  72392. /**
  72393. * Defines the minimum contract an Edges renderer should follow.
  72394. */
  72395. export interface IEdgesRenderer extends IDisposable {
  72396. /**
  72397. * Gets or sets a boolean indicating if the edgesRenderer is active
  72398. */
  72399. isEnabled: boolean;
  72400. /**
  72401. * Renders the edges of the attached mesh,
  72402. */
  72403. render(): void;
  72404. /**
  72405. * Checks wether or not the edges renderer is ready to render.
  72406. * @return true if ready, otherwise false.
  72407. */
  72408. isReady(): boolean;
  72409. }
  72410. /**
  72411. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  72412. */
  72413. export class EdgesRenderer implements IEdgesRenderer {
  72414. /**
  72415. * Define the size of the edges with an orthographic camera
  72416. */
  72417. edgesWidthScalerForOrthographic: number;
  72418. /**
  72419. * Define the size of the edges with a perspective camera
  72420. */
  72421. edgesWidthScalerForPerspective: number;
  72422. protected _source: AbstractMesh;
  72423. protected _linesPositions: number[];
  72424. protected _linesNormals: number[];
  72425. protected _linesIndices: number[];
  72426. protected _epsilon: number;
  72427. protected _indicesCount: number;
  72428. protected _lineShader: ShaderMaterial;
  72429. protected _ib: WebGLBuffer;
  72430. protected _buffers: {
  72431. [key: string]: Nullable<VertexBuffer>;
  72432. };
  72433. protected _checkVerticesInsteadOfIndices: boolean;
  72434. private _meshRebuildObserver;
  72435. private _meshDisposeObserver;
  72436. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  72437. isEnabled: boolean;
  72438. /**
  72439. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  72440. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  72441. * @param source Mesh used to create edges
  72442. * @param epsilon sum of angles in adjacency to check for edge
  72443. * @param checkVerticesInsteadOfIndices
  72444. * @param generateEdgesLines - should generate Lines or only prepare resources.
  72445. */
  72446. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  72447. protected _prepareRessources(): void;
  72448. /** @hidden */
  72449. _rebuild(): void;
  72450. /**
  72451. * Releases the required resources for the edges renderer
  72452. */
  72453. dispose(): void;
  72454. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  72455. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  72456. /**
  72457. * Checks if the pair of p0 and p1 is en edge
  72458. * @param faceIndex
  72459. * @param edge
  72460. * @param faceNormals
  72461. * @param p0
  72462. * @param p1
  72463. * @private
  72464. */
  72465. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  72466. /**
  72467. * push line into the position, normal and index buffer
  72468. * @protected
  72469. */
  72470. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  72471. /**
  72472. * Generates lines edges from adjacencjes
  72473. * @private
  72474. */
  72475. _generateEdgesLines(): void;
  72476. /**
  72477. * Checks wether or not the edges renderer is ready to render.
  72478. * @return true if ready, otherwise false.
  72479. */
  72480. isReady(): boolean;
  72481. /**
  72482. * Renders the edges of the attached mesh,
  72483. */
  72484. render(): void;
  72485. }
  72486. /**
  72487. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  72488. */
  72489. export class LineEdgesRenderer extends EdgesRenderer {
  72490. /**
  72491. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  72492. * @param source LineMesh used to generate edges
  72493. * @param epsilon not important (specified angle for edge detection)
  72494. * @param checkVerticesInsteadOfIndices not important for LineMesh
  72495. */
  72496. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  72497. /**
  72498. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  72499. */
  72500. _generateEdgesLines(): void;
  72501. }
  72502. }
  72503. declare module BABYLON {
  72504. /**
  72505. * This represents the object necessary to create a rendering group.
  72506. * This is exclusively used and created by the rendering manager.
  72507. * To modify the behavior, you use the available helpers in your scene or meshes.
  72508. * @hidden
  72509. */
  72510. export class RenderingGroup {
  72511. index: number;
  72512. private _scene;
  72513. private _opaqueSubMeshes;
  72514. private _transparentSubMeshes;
  72515. private _alphaTestSubMeshes;
  72516. private _depthOnlySubMeshes;
  72517. private _particleSystems;
  72518. private _spriteManagers;
  72519. private _opaqueSortCompareFn;
  72520. private _alphaTestSortCompareFn;
  72521. private _transparentSortCompareFn;
  72522. private _renderOpaque;
  72523. private _renderAlphaTest;
  72524. private _renderTransparent;
  72525. private _edgesRenderers;
  72526. onBeforeTransparentRendering: () => void;
  72527. /**
  72528. * Set the opaque sort comparison function.
  72529. * If null the sub meshes will be render in the order they were created
  72530. */
  72531. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72532. /**
  72533. * Set the alpha test sort comparison function.
  72534. * If null the sub meshes will be render in the order they were created
  72535. */
  72536. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72537. /**
  72538. * Set the transparent sort comparison function.
  72539. * If null the sub meshes will be render in the order they were created
  72540. */
  72541. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72542. /**
  72543. * Creates a new rendering group.
  72544. * @param index The rendering group index
  72545. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  72546. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  72547. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  72548. */
  72549. 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>);
  72550. /**
  72551. * Render all the sub meshes contained in the group.
  72552. * @param customRenderFunction Used to override the default render behaviour of the group.
  72553. * @returns true if rendered some submeshes.
  72554. */
  72555. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  72556. /**
  72557. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  72558. * @param subMeshes The submeshes to render
  72559. */
  72560. private renderOpaqueSorted;
  72561. /**
  72562. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  72563. * @param subMeshes The submeshes to render
  72564. */
  72565. private renderAlphaTestSorted;
  72566. /**
  72567. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  72568. * @param subMeshes The submeshes to render
  72569. */
  72570. private renderTransparentSorted;
  72571. /**
  72572. * Renders the submeshes in a specified order.
  72573. * @param subMeshes The submeshes to sort before render
  72574. * @param sortCompareFn The comparison function use to sort
  72575. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  72576. * @param transparent Specifies to activate blending if true
  72577. */
  72578. private static renderSorted;
  72579. /**
  72580. * Renders the submeshes in the order they were dispatched (no sort applied).
  72581. * @param subMeshes The submeshes to render
  72582. */
  72583. private static renderUnsorted;
  72584. /**
  72585. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72586. * are rendered back to front if in the same alpha index.
  72587. *
  72588. * @param a The first submesh
  72589. * @param b The second submesh
  72590. * @returns The result of the comparison
  72591. */
  72592. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  72593. /**
  72594. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72595. * are rendered back to front.
  72596. *
  72597. * @param a The first submesh
  72598. * @param b The second submesh
  72599. * @returns The result of the comparison
  72600. */
  72601. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  72602. /**
  72603. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72604. * are rendered front to back (prevent overdraw).
  72605. *
  72606. * @param a The first submesh
  72607. * @param b The second submesh
  72608. * @returns The result of the comparison
  72609. */
  72610. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  72611. /**
  72612. * Resets the different lists of submeshes to prepare a new frame.
  72613. */
  72614. prepare(): void;
  72615. dispose(): void;
  72616. /**
  72617. * Inserts the submesh in its correct queue depending on its material.
  72618. * @param subMesh The submesh to dispatch
  72619. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  72620. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  72621. */
  72622. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  72623. dispatchSprites(spriteManager: ISpriteManager): void;
  72624. dispatchParticles(particleSystem: IParticleSystem): void;
  72625. private _renderParticles;
  72626. private _renderSprites;
  72627. }
  72628. }
  72629. declare module BABYLON {
  72630. /**
  72631. * Interface describing the different options available in the rendering manager
  72632. * regarding Auto Clear between groups.
  72633. */
  72634. export interface IRenderingManagerAutoClearSetup {
  72635. /**
  72636. * Defines whether or not autoclear is enable.
  72637. */
  72638. autoClear: boolean;
  72639. /**
  72640. * Defines whether or not to autoclear the depth buffer.
  72641. */
  72642. depth: boolean;
  72643. /**
  72644. * Defines whether or not to autoclear the stencil buffer.
  72645. */
  72646. stencil: boolean;
  72647. }
  72648. /**
  72649. * This class is used by the onRenderingGroupObservable
  72650. */
  72651. export class RenderingGroupInfo {
  72652. /**
  72653. * The Scene that being rendered
  72654. */
  72655. scene: Scene;
  72656. /**
  72657. * The camera currently used for the rendering pass
  72658. */
  72659. camera: Nullable<Camera>;
  72660. /**
  72661. * The ID of the renderingGroup being processed
  72662. */
  72663. renderingGroupId: number;
  72664. }
  72665. /**
  72666. * This is the manager responsible of all the rendering for meshes sprites and particles.
  72667. * It is enable to manage the different groups as well as the different necessary sort functions.
  72668. * This should not be used directly aside of the few static configurations
  72669. */
  72670. export class RenderingManager {
  72671. /**
  72672. * The max id used for rendering groups (not included)
  72673. */
  72674. static MAX_RENDERINGGROUPS: number;
  72675. /**
  72676. * The min id used for rendering groups (included)
  72677. */
  72678. static MIN_RENDERINGGROUPS: number;
  72679. /**
  72680. * Used to globally prevent autoclearing scenes.
  72681. */
  72682. static AUTOCLEAR: boolean;
  72683. /**
  72684. * @hidden
  72685. */
  72686. _useSceneAutoClearSetup: boolean;
  72687. private _scene;
  72688. private _renderingGroups;
  72689. private _depthStencilBufferAlreadyCleaned;
  72690. private _autoClearDepthStencil;
  72691. private _customOpaqueSortCompareFn;
  72692. private _customAlphaTestSortCompareFn;
  72693. private _customTransparentSortCompareFn;
  72694. private _renderingGroupInfo;
  72695. /**
  72696. * Instantiates a new rendering group for a particular scene
  72697. * @param scene Defines the scene the groups belongs to
  72698. */
  72699. constructor(scene: Scene);
  72700. private _clearDepthStencilBuffer;
  72701. /**
  72702. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  72703. * @hidden
  72704. */
  72705. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  72706. /**
  72707. * Resets the different information of the group to prepare a new frame
  72708. * @hidden
  72709. */
  72710. reset(): void;
  72711. /**
  72712. * Dispose and release the group and its associated resources.
  72713. * @hidden
  72714. */
  72715. dispose(): void;
  72716. /**
  72717. * Clear the info related to rendering groups preventing retention points during dispose.
  72718. */
  72719. freeRenderingGroups(): void;
  72720. private _prepareRenderingGroup;
  72721. /**
  72722. * Add a sprite manager to the rendering manager in order to render it this frame.
  72723. * @param spriteManager Define the sprite manager to render
  72724. */
  72725. dispatchSprites(spriteManager: ISpriteManager): void;
  72726. /**
  72727. * Add a particle system to the rendering manager in order to render it this frame.
  72728. * @param particleSystem Define the particle system to render
  72729. */
  72730. dispatchParticles(particleSystem: IParticleSystem): void;
  72731. /**
  72732. * Add a submesh to the manager in order to render it this frame
  72733. * @param subMesh The submesh to dispatch
  72734. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  72735. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  72736. */
  72737. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  72738. /**
  72739. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  72740. * This allowed control for front to back rendering or reversly depending of the special needs.
  72741. *
  72742. * @param renderingGroupId The rendering group id corresponding to its index
  72743. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  72744. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  72745. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  72746. */
  72747. 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;
  72748. /**
  72749. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  72750. *
  72751. * @param renderingGroupId The rendering group id corresponding to its index
  72752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  72753. * @param depth Automatically clears depth between groups if true and autoClear is true.
  72754. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  72755. */
  72756. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  72757. /**
  72758. * Gets the current auto clear configuration for one rendering group of the rendering
  72759. * manager.
  72760. * @param index the rendering group index to get the information for
  72761. * @returns The auto clear setup for the requested rendering group
  72762. */
  72763. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  72764. }
  72765. }
  72766. declare module BABYLON {
  72767. /**
  72768. * This Helps creating a texture that will be created from a camera in your scene.
  72769. * It is basically a dynamic texture that could be used to create special effects for instance.
  72770. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  72771. */
  72772. export class RenderTargetTexture extends Texture {
  72773. isCube: boolean;
  72774. /**
  72775. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  72776. */
  72777. static readonly REFRESHRATE_RENDER_ONCE: number;
  72778. /**
  72779. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  72780. */
  72781. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  72782. /**
  72783. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  72784. * the central point of your effect and can save a lot of performances.
  72785. */
  72786. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  72787. /**
  72788. * Use this predicate to dynamically define the list of mesh you want to render.
  72789. * If set, the renderList property will be overwritten.
  72790. */
  72791. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  72792. private _renderList;
  72793. /**
  72794. * Use this list to define the list of mesh you want to render.
  72795. */
  72796. renderList: Nullable<Array<AbstractMesh>>;
  72797. private _hookArray;
  72798. /**
  72799. * Define if particles should be rendered in your texture.
  72800. */
  72801. renderParticles: boolean;
  72802. /**
  72803. * Define if sprites should be rendered in your texture.
  72804. */
  72805. renderSprites: boolean;
  72806. /**
  72807. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  72808. */
  72809. coordinatesMode: number;
  72810. /**
  72811. * Define the camera used to render the texture.
  72812. */
  72813. activeCamera: Nullable<Camera>;
  72814. /**
  72815. * Override the render function of the texture with your own one.
  72816. */
  72817. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  72818. /**
  72819. * Define if camera post processes should be use while rendering the texture.
  72820. */
  72821. useCameraPostProcesses: boolean;
  72822. /**
  72823. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  72824. */
  72825. ignoreCameraViewport: boolean;
  72826. private _postProcessManager;
  72827. private _postProcesses;
  72828. private _resizeObserver;
  72829. /**
  72830. * An event triggered when the texture is unbind.
  72831. */
  72832. onBeforeBindObservable: Observable<RenderTargetTexture>;
  72833. /**
  72834. * An event triggered when the texture is unbind.
  72835. */
  72836. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  72837. private _onAfterUnbindObserver;
  72838. /**
  72839. * Set a after unbind callback in the texture.
  72840. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  72841. */
  72842. onAfterUnbind: () => void;
  72843. /**
  72844. * An event triggered before rendering the texture
  72845. */
  72846. onBeforeRenderObservable: Observable<number>;
  72847. private _onBeforeRenderObserver;
  72848. /**
  72849. * Set a before render callback in the texture.
  72850. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  72851. */
  72852. onBeforeRender: (faceIndex: number) => void;
  72853. /**
  72854. * An event triggered after rendering the texture
  72855. */
  72856. onAfterRenderObservable: Observable<number>;
  72857. private _onAfterRenderObserver;
  72858. /**
  72859. * Set a after render callback in the texture.
  72860. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  72861. */
  72862. onAfterRender: (faceIndex: number) => void;
  72863. /**
  72864. * An event triggered after the texture clear
  72865. */
  72866. onClearObservable: Observable<Engine>;
  72867. private _onClearObserver;
  72868. /**
  72869. * Set a clear callback in the texture.
  72870. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  72871. */
  72872. onClear: (Engine: Engine) => void;
  72873. /**
  72874. * Define the clear color of the Render Target if it should be different from the scene.
  72875. */
  72876. clearColor: Color4;
  72877. protected _size: number | {
  72878. width: number;
  72879. height: number;
  72880. };
  72881. protected _initialSizeParameter: number | {
  72882. width: number;
  72883. height: number;
  72884. } | {
  72885. ratio: number;
  72886. };
  72887. protected _sizeRatio: Nullable<number>;
  72888. /** @hidden */
  72889. _generateMipMaps: boolean;
  72890. protected _renderingManager: RenderingManager;
  72891. /** @hidden */
  72892. _waitingRenderList: string[];
  72893. protected _doNotChangeAspectRatio: boolean;
  72894. protected _currentRefreshId: number;
  72895. protected _refreshRate: number;
  72896. protected _textureMatrix: Matrix;
  72897. protected _samples: number;
  72898. protected _renderTargetOptions: RenderTargetCreationOptions;
  72899. /**
  72900. * Gets render target creation options that were used.
  72901. */
  72902. readonly renderTargetOptions: RenderTargetCreationOptions;
  72903. protected _engine: Engine;
  72904. protected _onRatioRescale(): void;
  72905. /**
  72906. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  72907. * It must define where the camera used to render the texture is set
  72908. */
  72909. boundingBoxPosition: Vector3;
  72910. private _boundingBoxSize;
  72911. /**
  72912. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  72913. * When defined, the cubemap will switch to local mode
  72914. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72915. * @example https://www.babylonjs-playground.com/#RNASML
  72916. */
  72917. boundingBoxSize: Vector3;
  72918. /**
  72919. * In case the RTT has been created with a depth texture, get the associated
  72920. * depth texture.
  72921. * Otherwise, return null.
  72922. */
  72923. depthStencilTexture: Nullable<InternalTexture>;
  72924. /**
  72925. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  72926. * or used a shadow, depth texture...
  72927. * @param name The friendly name of the texture
  72928. * @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)
  72929. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  72930. * @param generateMipMaps True if mip maps need to be generated after render.
  72931. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  72932. * @param type The type of the buffer in the RTT (int, half float, float...)
  72933. * @param isCube True if a cube texture needs to be created
  72934. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  72935. * @param generateDepthBuffer True to generate a depth buffer
  72936. * @param generateStencilBuffer True to generate a stencil buffer
  72937. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  72938. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  72939. * @param delayAllocation if the texture allocation should be delayed (default: false)
  72940. */
  72941. constructor(name: string, size: number | {
  72942. width: number;
  72943. height: number;
  72944. } | {
  72945. ratio: number;
  72946. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  72947. /**
  72948. * Creates a depth stencil texture.
  72949. * This is only available in WebGL 2 or with the depth texture extension available.
  72950. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  72951. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  72952. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  72953. */
  72954. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  72955. private _processSizeParameter;
  72956. /**
  72957. * Define the number of samples to use in case of MSAA.
  72958. * It defaults to one meaning no MSAA has been enabled.
  72959. */
  72960. samples: number;
  72961. /**
  72962. * Resets the refresh counter of the texture and start bak from scratch.
  72963. * Could be useful to regenerate the texture if it is setup to render only once.
  72964. */
  72965. resetRefreshCounter(): void;
  72966. /**
  72967. * Define the refresh rate of the texture or the rendering frequency.
  72968. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72969. */
  72970. refreshRate: number;
  72971. /**
  72972. * Adds a post process to the render target rendering passes.
  72973. * @param postProcess define the post process to add
  72974. */
  72975. addPostProcess(postProcess: PostProcess): void;
  72976. /**
  72977. * Clear all the post processes attached to the render target
  72978. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  72979. */
  72980. clearPostProcesses(dispose?: boolean): void;
  72981. /**
  72982. * Remove one of the post process from the list of attached post processes to the texture
  72983. * @param postProcess define the post process to remove from the list
  72984. */
  72985. removePostProcess(postProcess: PostProcess): void;
  72986. /** @hidden */
  72987. _shouldRender(): boolean;
  72988. /**
  72989. * Gets the actual render size of the texture.
  72990. * @returns the width of the render size
  72991. */
  72992. getRenderSize(): number;
  72993. /**
  72994. * Gets the actual render width of the texture.
  72995. * @returns the width of the render size
  72996. */
  72997. getRenderWidth(): number;
  72998. /**
  72999. * Gets the actual render height of the texture.
  73000. * @returns the height of the render size
  73001. */
  73002. getRenderHeight(): number;
  73003. /**
  73004. * Get if the texture can be rescaled or not.
  73005. */
  73006. readonly canRescale: boolean;
  73007. /**
  73008. * Resize the texture using a ratio.
  73009. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73010. */
  73011. scale(ratio: number): void;
  73012. /**
  73013. * Get the texture reflection matrix used to rotate/transform the reflection.
  73014. * @returns the reflection matrix
  73015. */
  73016. getReflectionTextureMatrix(): Matrix;
  73017. /**
  73018. * Resize the texture to a new desired size.
  73019. * Be carrefull as it will recreate all the data in the new texture.
  73020. * @param size Define the new size. It can be:
  73021. * - a number for squared texture,
  73022. * - an object containing { width: number, height: number }
  73023. * - or an object containing a ratio { ratio: number }
  73024. */
  73025. resize(size: number | {
  73026. width: number;
  73027. height: number;
  73028. } | {
  73029. ratio: number;
  73030. }): void;
  73031. /**
  73032. * Renders all the objects from the render list into the texture.
  73033. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73034. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73035. */
  73036. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73037. private _bestReflectionRenderTargetDimension;
  73038. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73039. private renderToTarget;
  73040. /**
  73041. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73042. * This allowed control for front to back rendering or reversly depending of the special needs.
  73043. *
  73044. * @param renderingGroupId The rendering group id corresponding to its index
  73045. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73046. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73047. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73048. */
  73049. 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;
  73050. /**
  73051. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73052. *
  73053. * @param renderingGroupId The rendering group id corresponding to its index
  73054. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73055. */
  73056. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73057. /**
  73058. * Clones the texture.
  73059. * @returns the cloned texture
  73060. */
  73061. clone(): RenderTargetTexture;
  73062. /**
  73063. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73064. * @returns The JSON representation of the texture
  73065. */
  73066. serialize(): any;
  73067. /**
  73068. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73069. */
  73070. disposeFramebufferObjects(): void;
  73071. /**
  73072. * Dispose the texture and release its associated resources.
  73073. */
  73074. dispose(): void;
  73075. /** @hidden */
  73076. _rebuild(): void;
  73077. /**
  73078. * Clear the info related to rendering groups preventing retention point in material dispose.
  73079. */
  73080. freeRenderingGroups(): void;
  73081. }
  73082. }
  73083. declare module BABYLON {
  73084. /**
  73085. * Base class for the main features of a material in Babylon.js
  73086. */
  73087. export class Material implements IAnimatable {
  73088. /**
  73089. * Returns the triangle fill mode
  73090. */
  73091. static readonly TriangleFillMode: number;
  73092. /**
  73093. * Returns the wireframe mode
  73094. */
  73095. static readonly WireFrameFillMode: number;
  73096. /**
  73097. * Returns the point fill mode
  73098. */
  73099. static readonly PointFillMode: number;
  73100. /**
  73101. * Returns the point list draw mode
  73102. */
  73103. static readonly PointListDrawMode: number;
  73104. /**
  73105. * Returns the line list draw mode
  73106. */
  73107. static readonly LineListDrawMode: number;
  73108. /**
  73109. * Returns the line loop draw mode
  73110. */
  73111. static readonly LineLoopDrawMode: number;
  73112. /**
  73113. * Returns the line strip draw mode
  73114. */
  73115. static readonly LineStripDrawMode: number;
  73116. /**
  73117. * Returns the triangle strip draw mode
  73118. */
  73119. static readonly TriangleStripDrawMode: number;
  73120. /**
  73121. * Returns the triangle fan draw mode
  73122. */
  73123. static readonly TriangleFanDrawMode: number;
  73124. /**
  73125. * Stores the clock-wise side orientation
  73126. */
  73127. static readonly ClockWiseSideOrientation: number;
  73128. /**
  73129. * Stores the counter clock-wise side orientation
  73130. */
  73131. static readonly CounterClockWiseSideOrientation: number;
  73132. /**
  73133. * The dirty texture flag value
  73134. */
  73135. static readonly TextureDirtyFlag: number;
  73136. /**
  73137. * The dirty light flag value
  73138. */
  73139. static readonly LightDirtyFlag: number;
  73140. /**
  73141. * The dirty fresnel flag value
  73142. */
  73143. static readonly FresnelDirtyFlag: number;
  73144. /**
  73145. * The dirty attribute flag value
  73146. */
  73147. static readonly AttributesDirtyFlag: number;
  73148. /**
  73149. * The dirty misc flag value
  73150. */
  73151. static readonly MiscDirtyFlag: number;
  73152. /**
  73153. * The all dirty flag value
  73154. */
  73155. static readonly AllDirtyFlag: number;
  73156. /**
  73157. * The ID of the material
  73158. */
  73159. id: string;
  73160. /**
  73161. * Gets or sets the unique id of the material
  73162. */
  73163. uniqueId: number;
  73164. /**
  73165. * The name of the material
  73166. */
  73167. name: string;
  73168. /**
  73169. * Gets or sets user defined metadata
  73170. */
  73171. metadata: any;
  73172. /**
  73173. * For internal use only. Please do not use.
  73174. */
  73175. reservedDataStore: any;
  73176. /**
  73177. * Specifies if the ready state should be checked on each call
  73178. */
  73179. checkReadyOnEveryCall: boolean;
  73180. /**
  73181. * Specifies if the ready state should be checked once
  73182. */
  73183. checkReadyOnlyOnce: boolean;
  73184. /**
  73185. * The state of the material
  73186. */
  73187. state: string;
  73188. /**
  73189. * The alpha value of the material
  73190. */
  73191. protected _alpha: number;
  73192. /**
  73193. * Sets the alpha value of the material
  73194. */
  73195. /**
  73196. * Gets the alpha value of the material
  73197. */
  73198. alpha: number;
  73199. /**
  73200. * Specifies if back face culling is enabled
  73201. */
  73202. protected _backFaceCulling: boolean;
  73203. /**
  73204. * Sets the back-face culling state
  73205. */
  73206. /**
  73207. * Gets the back-face culling state
  73208. */
  73209. backFaceCulling: boolean;
  73210. /**
  73211. * Stores the value for side orientation
  73212. */
  73213. sideOrientation: number;
  73214. /**
  73215. * Callback triggered when the material is compiled
  73216. */
  73217. onCompiled: (effect: Effect) => void;
  73218. /**
  73219. * Callback triggered when an error occurs
  73220. */
  73221. onError: (effect: Effect, errors: string) => void;
  73222. /**
  73223. * Callback triggered to get the render target textures
  73224. */
  73225. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  73226. /**
  73227. * Gets a boolean indicating that current material needs to register RTT
  73228. */
  73229. readonly hasRenderTargetTextures: boolean;
  73230. /**
  73231. * Specifies if the material should be serialized
  73232. */
  73233. doNotSerialize: boolean;
  73234. /**
  73235. * @hidden
  73236. */
  73237. _storeEffectOnSubMeshes: boolean;
  73238. /**
  73239. * Stores the animations for the material
  73240. */
  73241. animations: Array<Animation>;
  73242. /**
  73243. * An event triggered when the material is disposed
  73244. */
  73245. onDisposeObservable: Observable<Material>;
  73246. /**
  73247. * An observer which watches for dispose events
  73248. */
  73249. private _onDisposeObserver;
  73250. private _onUnBindObservable;
  73251. /**
  73252. * Called during a dispose event
  73253. */
  73254. onDispose: () => void;
  73255. private _onBindObservable;
  73256. /**
  73257. * An event triggered when the material is bound
  73258. */
  73259. readonly onBindObservable: Observable<AbstractMesh>;
  73260. /**
  73261. * An observer which watches for bind events
  73262. */
  73263. private _onBindObserver;
  73264. /**
  73265. * Called during a bind event
  73266. */
  73267. onBind: (Mesh: AbstractMesh) => void;
  73268. /**
  73269. * An event triggered when the material is unbound
  73270. */
  73271. readonly onUnBindObservable: Observable<Material>;
  73272. /**
  73273. * Stores the value of the alpha mode
  73274. */
  73275. private _alphaMode;
  73276. /**
  73277. * Sets the value of the alpha mode.
  73278. *
  73279. * | Value | Type | Description |
  73280. * | --- | --- | --- |
  73281. * | 0 | ALPHA_DISABLE | |
  73282. * | 1 | ALPHA_ADD | |
  73283. * | 2 | ALPHA_COMBINE | |
  73284. * | 3 | ALPHA_SUBTRACT | |
  73285. * | 4 | ALPHA_MULTIPLY | |
  73286. * | 5 | ALPHA_MAXIMIZED | |
  73287. * | 6 | ALPHA_ONEONE | |
  73288. * | 7 | ALPHA_PREMULTIPLIED | |
  73289. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  73290. * | 9 | ALPHA_INTERPOLATE | |
  73291. * | 10 | ALPHA_SCREENMODE | |
  73292. *
  73293. */
  73294. /**
  73295. * Gets the value of the alpha mode
  73296. */
  73297. alphaMode: number;
  73298. /**
  73299. * Stores the state of the need depth pre-pass value
  73300. */
  73301. private _needDepthPrePass;
  73302. /**
  73303. * Sets the need depth pre-pass value
  73304. */
  73305. /**
  73306. * Gets the depth pre-pass value
  73307. */
  73308. needDepthPrePass: boolean;
  73309. /**
  73310. * Specifies if depth writing should be disabled
  73311. */
  73312. disableDepthWrite: boolean;
  73313. /**
  73314. * Specifies if depth writing should be forced
  73315. */
  73316. forceDepthWrite: boolean;
  73317. /**
  73318. * Specifies if there should be a separate pass for culling
  73319. */
  73320. separateCullingPass: boolean;
  73321. /**
  73322. * Stores the state specifing if fog should be enabled
  73323. */
  73324. private _fogEnabled;
  73325. /**
  73326. * Sets the state for enabling fog
  73327. */
  73328. /**
  73329. * Gets the value of the fog enabled state
  73330. */
  73331. fogEnabled: boolean;
  73332. /**
  73333. * Stores the size of points
  73334. */
  73335. pointSize: number;
  73336. /**
  73337. * Stores the z offset value
  73338. */
  73339. zOffset: number;
  73340. /**
  73341. * Gets a value specifying if wireframe mode is enabled
  73342. */
  73343. /**
  73344. * Sets the state of wireframe mode
  73345. */
  73346. wireframe: boolean;
  73347. /**
  73348. * Gets the value specifying if point clouds are enabled
  73349. */
  73350. /**
  73351. * Sets the state of point cloud mode
  73352. */
  73353. pointsCloud: boolean;
  73354. /**
  73355. * Gets the material fill mode
  73356. */
  73357. /**
  73358. * Sets the material fill mode
  73359. */
  73360. fillMode: number;
  73361. /**
  73362. * @hidden
  73363. * Stores the effects for the material
  73364. */
  73365. _effect: Nullable<Effect>;
  73366. /**
  73367. * @hidden
  73368. * Specifies if the material was previously ready
  73369. */
  73370. _wasPreviouslyReady: boolean;
  73371. /**
  73372. * Specifies if uniform buffers should be used
  73373. */
  73374. private _useUBO;
  73375. /**
  73376. * Stores a reference to the scene
  73377. */
  73378. private _scene;
  73379. /**
  73380. * Stores the fill mode state
  73381. */
  73382. private _fillMode;
  73383. /**
  73384. * Specifies if the depth write state should be cached
  73385. */
  73386. private _cachedDepthWriteState;
  73387. /**
  73388. * Stores the uniform buffer
  73389. */
  73390. protected _uniformBuffer: UniformBuffer;
  73391. /** @hidden */
  73392. _indexInSceneMaterialArray: number;
  73393. /** @hidden */
  73394. meshMap: Nullable<{
  73395. [id: string]: AbstractMesh | undefined;
  73396. }>;
  73397. /**
  73398. * Creates a material instance
  73399. * @param name defines the name of the material
  73400. * @param scene defines the scene to reference
  73401. * @param doNotAdd specifies if the material should be added to the scene
  73402. */
  73403. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  73404. /**
  73405. * Returns a string representation of the current material
  73406. * @param fullDetails defines a boolean indicating which levels of logging is desired
  73407. * @returns a string with material information
  73408. */
  73409. toString(fullDetails?: boolean): string;
  73410. /**
  73411. * Gets the class name of the material
  73412. * @returns a string with the class name of the material
  73413. */
  73414. getClassName(): string;
  73415. /**
  73416. * Specifies if updates for the material been locked
  73417. */
  73418. readonly isFrozen: boolean;
  73419. /**
  73420. * Locks updates for the material
  73421. */
  73422. freeze(): void;
  73423. /**
  73424. * Unlocks updates for the material
  73425. */
  73426. unfreeze(): void;
  73427. /**
  73428. * Specifies if the material is ready to be used
  73429. * @param mesh defines the mesh to check
  73430. * @param useInstances specifies if instances should be used
  73431. * @returns a boolean indicating if the material is ready to be used
  73432. */
  73433. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73434. /**
  73435. * Specifies that the submesh is ready to be used
  73436. * @param mesh defines the mesh to check
  73437. * @param subMesh defines which submesh to check
  73438. * @param useInstances specifies that instances should be used
  73439. * @returns a boolean indicating that the submesh is ready or not
  73440. */
  73441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  73442. /**
  73443. * Returns the material effect
  73444. * @returns the effect associated with the material
  73445. */
  73446. getEffect(): Nullable<Effect>;
  73447. /**
  73448. * Returns the current scene
  73449. * @returns a Scene
  73450. */
  73451. getScene(): Scene;
  73452. /**
  73453. * Specifies if the material will require alpha blending
  73454. * @returns a boolean specifying if alpha blending is needed
  73455. */
  73456. needAlphaBlending(): boolean;
  73457. /**
  73458. * Specifies if the mesh will require alpha blending
  73459. * @param mesh defines the mesh to check
  73460. * @returns a boolean specifying if alpha blending is needed for the mesh
  73461. */
  73462. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  73463. /**
  73464. * Specifies if this material should be rendered in alpha test mode
  73465. * @returns a boolean specifying if an alpha test is needed.
  73466. */
  73467. needAlphaTesting(): boolean;
  73468. /**
  73469. * Gets the texture used for the alpha test
  73470. * @returns the texture to use for alpha testing
  73471. */
  73472. getAlphaTestTexture(): Nullable<BaseTexture>;
  73473. /**
  73474. * Marks the material to indicate that it needs to be re-calculated
  73475. */
  73476. markDirty(): void;
  73477. /** @hidden */
  73478. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  73479. /**
  73480. * Binds the material to the mesh
  73481. * @param world defines the world transformation matrix
  73482. * @param mesh defines the mesh to bind the material to
  73483. */
  73484. bind(world: Matrix, mesh?: Mesh): void;
  73485. /**
  73486. * Binds the submesh to the material
  73487. * @param world defines the world transformation matrix
  73488. * @param mesh defines the mesh containing the submesh
  73489. * @param subMesh defines the submesh to bind the material to
  73490. */
  73491. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  73492. /**
  73493. * Binds the world matrix to the material
  73494. * @param world defines the world transformation matrix
  73495. */
  73496. bindOnlyWorldMatrix(world: Matrix): void;
  73497. /**
  73498. * Binds the scene's uniform buffer to the effect.
  73499. * @param effect defines the effect to bind to the scene uniform buffer
  73500. * @param sceneUbo defines the uniform buffer storing scene data
  73501. */
  73502. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  73503. /**
  73504. * Binds the view matrix to the effect
  73505. * @param effect defines the effect to bind the view matrix to
  73506. */
  73507. bindView(effect: Effect): void;
  73508. /**
  73509. * Binds the view projection matrix to the effect
  73510. * @param effect defines the effect to bind the view projection matrix to
  73511. */
  73512. bindViewProjection(effect: Effect): void;
  73513. /**
  73514. * Specifies if material alpha testing should be turned on for the mesh
  73515. * @param mesh defines the mesh to check
  73516. */
  73517. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  73518. /**
  73519. * Processes to execute after binding the material to a mesh
  73520. * @param mesh defines the rendered mesh
  73521. */
  73522. protected _afterBind(mesh?: Mesh): void;
  73523. /**
  73524. * Unbinds the material from the mesh
  73525. */
  73526. unbind(): void;
  73527. /**
  73528. * Gets the active textures from the material
  73529. * @returns an array of textures
  73530. */
  73531. getActiveTextures(): BaseTexture[];
  73532. /**
  73533. * Specifies if the material uses a texture
  73534. * @param texture defines the texture to check against the material
  73535. * @returns a boolean specifying if the material uses the texture
  73536. */
  73537. hasTexture(texture: BaseTexture): boolean;
  73538. /**
  73539. * Makes a duplicate of the material, and gives it a new name
  73540. * @param name defines the new name for the duplicated material
  73541. * @returns the cloned material
  73542. */
  73543. clone(name: string): Nullable<Material>;
  73544. /**
  73545. * Gets the meshes bound to the material
  73546. * @returns an array of meshes bound to the material
  73547. */
  73548. getBindedMeshes(): AbstractMesh[];
  73549. /**
  73550. * Force shader compilation
  73551. * @param mesh defines the mesh associated with this material
  73552. * @param onCompiled defines a function to execute once the material is compiled
  73553. * @param options defines the options to configure the compilation
  73554. */
  73555. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  73556. clipPlane: boolean;
  73557. }>): void;
  73558. /**
  73559. * Force shader compilation
  73560. * @param mesh defines the mesh that will use this material
  73561. * @param options defines additional options for compiling the shaders
  73562. * @returns a promise that resolves when the compilation completes
  73563. */
  73564. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  73565. clipPlane: boolean;
  73566. }>): Promise<void>;
  73567. private static readonly _ImageProcessingDirtyCallBack;
  73568. private static readonly _TextureDirtyCallBack;
  73569. private static readonly _FresnelDirtyCallBack;
  73570. private static readonly _MiscDirtyCallBack;
  73571. private static readonly _LightsDirtyCallBack;
  73572. private static readonly _AttributeDirtyCallBack;
  73573. private static _FresnelAndMiscDirtyCallBack;
  73574. private static _TextureAndMiscDirtyCallBack;
  73575. private static readonly _DirtyCallbackArray;
  73576. private static readonly _RunDirtyCallBacks;
  73577. /**
  73578. * Marks a define in the material to indicate that it needs to be re-computed
  73579. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  73580. */
  73581. markAsDirty(flag: number): void;
  73582. /**
  73583. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  73584. * @param func defines a function which checks material defines against the submeshes
  73585. */
  73586. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  73587. /**
  73588. * Indicates that image processing needs to be re-calculated for all submeshes
  73589. */
  73590. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  73591. /**
  73592. * Indicates that textures need to be re-calculated for all submeshes
  73593. */
  73594. protected _markAllSubMeshesAsTexturesDirty(): void;
  73595. /**
  73596. * Indicates that fresnel needs to be re-calculated for all submeshes
  73597. */
  73598. protected _markAllSubMeshesAsFresnelDirty(): void;
  73599. /**
  73600. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  73601. */
  73602. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  73603. /**
  73604. * Indicates that lights need to be re-calculated for all submeshes
  73605. */
  73606. protected _markAllSubMeshesAsLightsDirty(): void;
  73607. /**
  73608. * Indicates that attributes need to be re-calculated for all submeshes
  73609. */
  73610. protected _markAllSubMeshesAsAttributesDirty(): void;
  73611. /**
  73612. * Indicates that misc needs to be re-calculated for all submeshes
  73613. */
  73614. protected _markAllSubMeshesAsMiscDirty(): void;
  73615. /**
  73616. * Indicates that textures and misc need to be re-calculated for all submeshes
  73617. */
  73618. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  73619. /**
  73620. * Disposes the material
  73621. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73622. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73623. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73624. */
  73625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73626. /** @hidden */
  73627. private releaseVertexArrayObject;
  73628. /**
  73629. * Serializes this material
  73630. * @returns the serialized material object
  73631. */
  73632. serialize(): any;
  73633. /**
  73634. * Creates a material from parsed material data
  73635. * @param parsedMaterial defines parsed material data
  73636. * @param scene defines the hosting scene
  73637. * @param rootUrl defines the root URL to use to load textures
  73638. * @returns a new material
  73639. */
  73640. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  73641. }
  73642. }
  73643. declare module BABYLON {
  73644. /**
  73645. * Class used to represent data loading progression
  73646. */
  73647. export class SceneLoaderFlags {
  73648. private static _ForceFullSceneLoadingForIncremental;
  73649. private static _ShowLoadingScreen;
  73650. private static _CleanBoneMatrixWeights;
  73651. private static _loggingLevel;
  73652. /**
  73653. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  73654. */
  73655. static ForceFullSceneLoadingForIncremental: boolean;
  73656. /**
  73657. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  73658. */
  73659. static ShowLoadingScreen: boolean;
  73660. /**
  73661. * Defines the current logging level (while loading the scene)
  73662. * @ignorenaming
  73663. */
  73664. static loggingLevel: number;
  73665. /**
  73666. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  73667. */
  73668. static CleanBoneMatrixWeights: boolean;
  73669. }
  73670. }
  73671. declare module BABYLON {
  73672. /**
  73673. * Defines a target to use with MorphTargetManager
  73674. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73675. */
  73676. export class MorphTarget implements IAnimatable {
  73677. /** defines the name of the target */
  73678. name: string;
  73679. /**
  73680. * Gets or sets the list of animations
  73681. */
  73682. animations: Animation[];
  73683. private _scene;
  73684. private _positions;
  73685. private _normals;
  73686. private _tangents;
  73687. private _influence;
  73688. /**
  73689. * Observable raised when the influence changes
  73690. */
  73691. onInfluenceChanged: Observable<boolean>;
  73692. /** @hidden */
  73693. _onDataLayoutChanged: Observable<void>;
  73694. /**
  73695. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73696. */
  73697. influence: number;
  73698. /**
  73699. * Gets or sets the id of the morph Target
  73700. */
  73701. id: string;
  73702. private _animationPropertiesOverride;
  73703. /**
  73704. * Gets or sets the animation properties override
  73705. */
  73706. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73707. /**
  73708. * Creates a new MorphTarget
  73709. * @param name defines the name of the target
  73710. * @param influence defines the influence to use
  73711. */
  73712. constructor(
  73713. /** defines the name of the target */
  73714. name: string, influence?: number, scene?: Nullable<Scene>);
  73715. /**
  73716. * Gets a boolean defining if the target contains position data
  73717. */
  73718. readonly hasPositions: boolean;
  73719. /**
  73720. * Gets a boolean defining if the target contains normal data
  73721. */
  73722. readonly hasNormals: boolean;
  73723. /**
  73724. * Gets a boolean defining if the target contains tangent data
  73725. */
  73726. readonly hasTangents: boolean;
  73727. /**
  73728. * Affects position data to this target
  73729. * @param data defines the position data to use
  73730. */
  73731. setPositions(data: Nullable<FloatArray>): void;
  73732. /**
  73733. * Gets the position data stored in this target
  73734. * @returns a FloatArray containing the position data (or null if not present)
  73735. */
  73736. getPositions(): Nullable<FloatArray>;
  73737. /**
  73738. * Affects normal data to this target
  73739. * @param data defines the normal data to use
  73740. */
  73741. setNormals(data: Nullable<FloatArray>): void;
  73742. /**
  73743. * Gets the normal data stored in this target
  73744. * @returns a FloatArray containing the normal data (or null if not present)
  73745. */
  73746. getNormals(): Nullable<FloatArray>;
  73747. /**
  73748. * Affects tangent data to this target
  73749. * @param data defines the tangent data to use
  73750. */
  73751. setTangents(data: Nullable<FloatArray>): void;
  73752. /**
  73753. * Gets the tangent data stored in this target
  73754. * @returns a FloatArray containing the tangent data (or null if not present)
  73755. */
  73756. getTangents(): Nullable<FloatArray>;
  73757. /**
  73758. * Serializes the current target into a Serialization object
  73759. * @returns the serialized object
  73760. */
  73761. serialize(): any;
  73762. /**
  73763. * Returns the string "MorphTarget"
  73764. * @returns "MorphTarget"
  73765. */
  73766. getClassName(): string;
  73767. /**
  73768. * Creates a new target from serialized data
  73769. * @param serializationObject defines the serialized data to use
  73770. * @returns a new MorphTarget
  73771. */
  73772. static Parse(serializationObject: any): MorphTarget;
  73773. /**
  73774. * Creates a MorphTarget from mesh data
  73775. * @param mesh defines the source mesh
  73776. * @param name defines the name to use for the new target
  73777. * @param influence defines the influence to attach to the target
  73778. * @returns a new MorphTarget
  73779. */
  73780. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73781. }
  73782. }
  73783. declare module BABYLON {
  73784. /**
  73785. * This class is used to deform meshes using morphing between different targets
  73786. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73787. */
  73788. export class MorphTargetManager {
  73789. private _targets;
  73790. private _targetInfluenceChangedObservers;
  73791. private _targetDataLayoutChangedObservers;
  73792. private _activeTargets;
  73793. private _scene;
  73794. private _influences;
  73795. private _supportsNormals;
  73796. private _supportsTangents;
  73797. private _vertexCount;
  73798. private _uniqueId;
  73799. private _tempInfluences;
  73800. /**
  73801. * Creates a new MorphTargetManager
  73802. * @param scene defines the current scene
  73803. */
  73804. constructor(scene?: Nullable<Scene>);
  73805. /**
  73806. * Gets the unique ID of this manager
  73807. */
  73808. readonly uniqueId: number;
  73809. /**
  73810. * Gets the number of vertices handled by this manager
  73811. */
  73812. readonly vertexCount: number;
  73813. /**
  73814. * Gets a boolean indicating if this manager supports morphing of normals
  73815. */
  73816. readonly supportsNormals: boolean;
  73817. /**
  73818. * Gets a boolean indicating if this manager supports morphing of tangents
  73819. */
  73820. readonly supportsTangents: boolean;
  73821. /**
  73822. * Gets the number of targets stored in this manager
  73823. */
  73824. readonly numTargets: number;
  73825. /**
  73826. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73827. */
  73828. readonly numInfluencers: number;
  73829. /**
  73830. * Gets the list of influences (one per target)
  73831. */
  73832. readonly influences: Float32Array;
  73833. /**
  73834. * Gets the active target at specified index. An active target is a target with an influence > 0
  73835. * @param index defines the index to check
  73836. * @returns the requested target
  73837. */
  73838. getActiveTarget(index: number): MorphTarget;
  73839. /**
  73840. * Gets the target at specified index
  73841. * @param index defines the index to check
  73842. * @returns the requested target
  73843. */
  73844. getTarget(index: number): MorphTarget;
  73845. /**
  73846. * Add a new target to this manager
  73847. * @param target defines the target to add
  73848. */
  73849. addTarget(target: MorphTarget): void;
  73850. /**
  73851. * Removes a target from the manager
  73852. * @param target defines the target to remove
  73853. */
  73854. removeTarget(target: MorphTarget): void;
  73855. /**
  73856. * Serializes the current manager into a Serialization object
  73857. * @returns the serialized object
  73858. */
  73859. serialize(): any;
  73860. private _syncActiveTargets;
  73861. /**
  73862. * Syncrhonize the targets with all the meshes using this morph target manager
  73863. */
  73864. synchronize(): void;
  73865. /**
  73866. * Creates a new MorphTargetManager from serialized data
  73867. * @param serializationObject defines the serialized data
  73868. * @param scene defines the hosting scene
  73869. * @returns the new MorphTargetManager
  73870. */
  73871. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /**
  73876. * Interface for Physics-Joint data
  73877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73878. */
  73879. export interface PhysicsJointData {
  73880. /**
  73881. * The main pivot of the joint
  73882. */
  73883. mainPivot?: Vector3;
  73884. /**
  73885. * The connected pivot of the joint
  73886. */
  73887. connectedPivot?: Vector3;
  73888. /**
  73889. * The main axis of the joint
  73890. */
  73891. mainAxis?: Vector3;
  73892. /**
  73893. * The connected axis of the joint
  73894. */
  73895. connectedAxis?: Vector3;
  73896. /**
  73897. * The collision of the joint
  73898. */
  73899. collision?: boolean;
  73900. /**
  73901. * Native Oimo/Cannon/Energy data
  73902. */
  73903. nativeParams?: any;
  73904. }
  73905. /**
  73906. * This is a holder class for the physics joint created by the physics plugin
  73907. * It holds a set of functions to control the underlying joint
  73908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73909. */
  73910. export class PhysicsJoint {
  73911. /**
  73912. * The type of the physics joint
  73913. */
  73914. type: number;
  73915. /**
  73916. * The data for the physics joint
  73917. */
  73918. jointData: PhysicsJointData;
  73919. private _physicsJoint;
  73920. protected _physicsPlugin: IPhysicsEnginePlugin;
  73921. /**
  73922. * Initializes the physics joint
  73923. * @param type The type of the physics joint
  73924. * @param jointData The data for the physics joint
  73925. */
  73926. constructor(
  73927. /**
  73928. * The type of the physics joint
  73929. */
  73930. type: number,
  73931. /**
  73932. * The data for the physics joint
  73933. */
  73934. jointData: PhysicsJointData);
  73935. /**
  73936. * Gets the physics joint
  73937. */
  73938. /**
  73939. * Sets the physics joint
  73940. */
  73941. physicsJoint: any;
  73942. /**
  73943. * Sets the physics plugin
  73944. */
  73945. physicsPlugin: IPhysicsEnginePlugin;
  73946. /**
  73947. * Execute a function that is physics-plugin specific.
  73948. * @param {Function} func the function that will be executed.
  73949. * It accepts two parameters: the physics world and the physics joint
  73950. */
  73951. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  73952. /**
  73953. * Distance-Joint type
  73954. */
  73955. static DistanceJoint: number;
  73956. /**
  73957. * Hinge-Joint type
  73958. */
  73959. static HingeJoint: number;
  73960. /**
  73961. * Ball-and-Socket joint type
  73962. */
  73963. static BallAndSocketJoint: number;
  73964. /**
  73965. * Wheel-Joint type
  73966. */
  73967. static WheelJoint: number;
  73968. /**
  73969. * Slider-Joint type
  73970. */
  73971. static SliderJoint: number;
  73972. /**
  73973. * Prismatic-Joint type
  73974. */
  73975. static PrismaticJoint: number;
  73976. /**
  73977. * Universal-Joint type
  73978. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  73979. */
  73980. static UniversalJoint: number;
  73981. /**
  73982. * Hinge-Joint 2 type
  73983. */
  73984. static Hinge2Joint: number;
  73985. /**
  73986. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  73987. */
  73988. static PointToPointJoint: number;
  73989. /**
  73990. * Spring-Joint type
  73991. */
  73992. static SpringJoint: number;
  73993. /**
  73994. * Lock-Joint type
  73995. */
  73996. static LockJoint: number;
  73997. }
  73998. /**
  73999. * A class representing a physics distance joint
  74000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74001. */
  74002. export class DistanceJoint extends PhysicsJoint {
  74003. /**
  74004. *
  74005. * @param jointData The data for the Distance-Joint
  74006. */
  74007. constructor(jointData: DistanceJointData);
  74008. /**
  74009. * Update the predefined distance.
  74010. * @param maxDistance The maximum preferred distance
  74011. * @param minDistance The minimum preferred distance
  74012. */
  74013. updateDistance(maxDistance: number, minDistance?: number): void;
  74014. }
  74015. /**
  74016. * Represents a Motor-Enabled Joint
  74017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74018. */
  74019. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74020. /**
  74021. * Initializes the Motor-Enabled Joint
  74022. * @param type The type of the joint
  74023. * @param jointData The physica joint data for the joint
  74024. */
  74025. constructor(type: number, jointData: PhysicsJointData);
  74026. /**
  74027. * Set the motor values.
  74028. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74029. * @param force the force to apply
  74030. * @param maxForce max force for this motor.
  74031. */
  74032. setMotor(force?: number, maxForce?: number): void;
  74033. /**
  74034. * Set the motor's limits.
  74035. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74036. * @param upperLimit The upper limit of the motor
  74037. * @param lowerLimit The lower limit of the motor
  74038. */
  74039. setLimit(upperLimit: number, lowerLimit?: number): void;
  74040. }
  74041. /**
  74042. * This class represents a single physics Hinge-Joint
  74043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74044. */
  74045. export class HingeJoint extends MotorEnabledJoint {
  74046. /**
  74047. * Initializes the Hinge-Joint
  74048. * @param jointData The joint data for the Hinge-Joint
  74049. */
  74050. constructor(jointData: PhysicsJointData);
  74051. /**
  74052. * Set the motor values.
  74053. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74054. * @param {number} force the force to apply
  74055. * @param {number} maxForce max force for this motor.
  74056. */
  74057. setMotor(force?: number, maxForce?: number): void;
  74058. /**
  74059. * Set the motor's limits.
  74060. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74061. * @param upperLimit The upper limit of the motor
  74062. * @param lowerLimit The lower limit of the motor
  74063. */
  74064. setLimit(upperLimit: number, lowerLimit?: number): void;
  74065. }
  74066. /**
  74067. * This class represents a dual hinge physics joint (same as wheel joint)
  74068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74069. */
  74070. export class Hinge2Joint extends MotorEnabledJoint {
  74071. /**
  74072. * Initializes the Hinge2-Joint
  74073. * @param jointData The joint data for the Hinge2-Joint
  74074. */
  74075. constructor(jointData: PhysicsJointData);
  74076. /**
  74077. * Set the motor values.
  74078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74079. * @param {number} force the force to apply
  74080. * @param {number} maxForce max force for this motor.
  74081. * @param {motorIndex} the motor's index, 0 or 1.
  74082. */
  74083. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74084. /**
  74085. * Set the motor limits.
  74086. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74087. * @param {number} upperLimit the upper limit
  74088. * @param {number} lowerLimit lower limit
  74089. * @param {motorIndex} the motor's index, 0 or 1.
  74090. */
  74091. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74092. }
  74093. /**
  74094. * Interface for a motor enabled joint
  74095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74096. */
  74097. export interface IMotorEnabledJoint {
  74098. /**
  74099. * Physics joint
  74100. */
  74101. physicsJoint: any;
  74102. /**
  74103. * Sets the motor of the motor-enabled joint
  74104. * @param force The force of the motor
  74105. * @param maxForce The maximum force of the motor
  74106. * @param motorIndex The index of the motor
  74107. */
  74108. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74109. /**
  74110. * Sets the limit of the motor
  74111. * @param upperLimit The upper limit of the motor
  74112. * @param lowerLimit The lower limit of the motor
  74113. * @param motorIndex The index of the motor
  74114. */
  74115. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74116. }
  74117. /**
  74118. * Joint data for a Distance-Joint
  74119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74120. */
  74121. export interface DistanceJointData extends PhysicsJointData {
  74122. /**
  74123. * Max distance the 2 joint objects can be apart
  74124. */
  74125. maxDistance: number;
  74126. }
  74127. /**
  74128. * Joint data from a spring joint
  74129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74130. */
  74131. export interface SpringJointData extends PhysicsJointData {
  74132. /**
  74133. * Length of the spring
  74134. */
  74135. length: number;
  74136. /**
  74137. * Stiffness of the spring
  74138. */
  74139. stiffness: number;
  74140. /**
  74141. * Damping of the spring
  74142. */
  74143. damping: number;
  74144. /** this callback will be called when applying the force to the impostors. */
  74145. forceApplicationCallback: () => void;
  74146. }
  74147. }
  74148. declare module BABYLON {
  74149. /**
  74150. * Interface used to describe a physics joint
  74151. */
  74152. export interface PhysicsImpostorJoint {
  74153. /** Defines the main impostor to which the joint is linked */
  74154. mainImpostor: PhysicsImpostor;
  74155. /** Defines the impostor that is connected to the main impostor using this joint */
  74156. connectedImpostor: PhysicsImpostor;
  74157. /** Defines the joint itself */
  74158. joint: PhysicsJoint;
  74159. }
  74160. /** @hidden */
  74161. export interface IPhysicsEnginePlugin {
  74162. world: any;
  74163. name: string;
  74164. setGravity(gravity: Vector3): void;
  74165. setTimeStep(timeStep: number): void;
  74166. getTimeStep(): number;
  74167. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74168. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74171. removePhysicsBody(impostor: PhysicsImpostor): void;
  74172. generateJoint(joint: PhysicsImpostorJoint): void;
  74173. removeJoint(joint: PhysicsImpostorJoint): void;
  74174. isSupported(): boolean;
  74175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74176. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74177. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74178. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74179. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74180. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74182. getBodyMass(impostor: PhysicsImpostor): number;
  74183. getBodyFriction(impostor: PhysicsImpostor): number;
  74184. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74185. getBodyRestitution(impostor: PhysicsImpostor): number;
  74186. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74187. sleepBody(impostor: PhysicsImpostor): void;
  74188. wakeUpBody(impostor: PhysicsImpostor): void;
  74189. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74190. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74191. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74192. getRadius(impostor: PhysicsImpostor): number;
  74193. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74195. dispose(): void;
  74196. }
  74197. /**
  74198. * Interface used to define a physics engine
  74199. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74200. */
  74201. export interface IPhysicsEngine {
  74202. /**
  74203. * Gets the gravity vector used by the simulation
  74204. */
  74205. gravity: Vector3;
  74206. /**
  74207. * Sets the gravity vector used by the simulation
  74208. * @param gravity defines the gravity vector to use
  74209. */
  74210. setGravity(gravity: Vector3): void;
  74211. /**
  74212. * Set the time step of the physics engine.
  74213. * Default is 1/60.
  74214. * To slow it down, enter 1/600 for example.
  74215. * To speed it up, 1/30
  74216. * @param newTimeStep the new timestep to apply to this world.
  74217. */
  74218. setTimeStep(newTimeStep: number): void;
  74219. /**
  74220. * Get the time step of the physics engine.
  74221. * @returns the current time step
  74222. */
  74223. getTimeStep(): number;
  74224. /**
  74225. * Release all resources
  74226. */
  74227. dispose(): void;
  74228. /**
  74229. * Gets the name of the current physics plugin
  74230. * @returns the name of the plugin
  74231. */
  74232. getPhysicsPluginName(): string;
  74233. /**
  74234. * Adding a new impostor for the impostor tracking.
  74235. * This will be done by the impostor itself.
  74236. * @param impostor the impostor to add
  74237. */
  74238. addImpostor(impostor: PhysicsImpostor): void;
  74239. /**
  74240. * Remove an impostor from the engine.
  74241. * This impostor and its mesh will not longer be updated by the physics engine.
  74242. * @param impostor the impostor to remove
  74243. */
  74244. removeImpostor(impostor: PhysicsImpostor): void;
  74245. /**
  74246. * Add a joint to the physics engine
  74247. * @param mainImpostor defines the main impostor to which the joint is added.
  74248. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  74249. * @param joint defines the joint that will connect both impostors.
  74250. */
  74251. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74252. /**
  74253. * Removes a joint from the simulation
  74254. * @param mainImpostor defines the impostor used with the joint
  74255. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  74256. * @param joint defines the joint to remove
  74257. */
  74258. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74259. /**
  74260. * Gets the current plugin used to run the simulation
  74261. * @returns current plugin
  74262. */
  74263. getPhysicsPlugin(): IPhysicsEnginePlugin;
  74264. /**
  74265. * Gets the list of physic impostors
  74266. * @returns an array of PhysicsImpostor
  74267. */
  74268. getImpostors(): Array<PhysicsImpostor>;
  74269. /**
  74270. * Gets the impostor for a physics enabled object
  74271. * @param object defines the object impersonated by the impostor
  74272. * @returns the PhysicsImpostor or null if not found
  74273. */
  74274. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74275. /**
  74276. * Gets the impostor for a physics body object
  74277. * @param body defines physics body used by the impostor
  74278. * @returns the PhysicsImpostor or null if not found
  74279. */
  74280. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  74281. /**
  74282. * Called by the scene. No need to call it.
  74283. * @param delta defines the timespam between frames
  74284. */
  74285. _step(delta: number): void;
  74286. }
  74287. }
  74288. declare module BABYLON {
  74289. /**
  74290. * The interface for the physics imposter parameters
  74291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74292. */
  74293. export interface PhysicsImpostorParameters {
  74294. /**
  74295. * The mass of the physics imposter
  74296. */
  74297. mass: number;
  74298. /**
  74299. * The friction of the physics imposter
  74300. */
  74301. friction?: number;
  74302. /**
  74303. * The coefficient of restitution of the physics imposter
  74304. */
  74305. restitution?: number;
  74306. /**
  74307. * The native options of the physics imposter
  74308. */
  74309. nativeOptions?: any;
  74310. /**
  74311. * Specifies if the parent should be ignored
  74312. */
  74313. ignoreParent?: boolean;
  74314. /**
  74315. * Specifies if bi-directional transformations should be disabled
  74316. */
  74317. disableBidirectionalTransformation?: boolean;
  74318. }
  74319. /**
  74320. * Interface for a physics-enabled object
  74321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74322. */
  74323. export interface IPhysicsEnabledObject {
  74324. /**
  74325. * The position of the physics-enabled object
  74326. */
  74327. position: Vector3;
  74328. /**
  74329. * The rotation of the physics-enabled object
  74330. */
  74331. rotationQuaternion: Nullable<Quaternion>;
  74332. /**
  74333. * The scale of the physics-enabled object
  74334. */
  74335. scaling: Vector3;
  74336. /**
  74337. * The rotation of the physics-enabled object
  74338. */
  74339. rotation?: Vector3;
  74340. /**
  74341. * The parent of the physics-enabled object
  74342. */
  74343. parent?: any;
  74344. /**
  74345. * The bounding info of the physics-enabled object
  74346. * @returns The bounding info of the physics-enabled object
  74347. */
  74348. getBoundingInfo(): BoundingInfo;
  74349. /**
  74350. * Computes the world matrix
  74351. * @param force Specifies if the world matrix should be computed by force
  74352. * @returns A world matrix
  74353. */
  74354. computeWorldMatrix(force: boolean): Matrix;
  74355. /**
  74356. * Gets the world matrix
  74357. * @returns A world matrix
  74358. */
  74359. getWorldMatrix?(): Matrix;
  74360. /**
  74361. * Gets the child meshes
  74362. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  74363. * @returns An array of abstract meshes
  74364. */
  74365. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  74366. /**
  74367. * Gets the vertex data
  74368. * @param kind The type of vertex data
  74369. * @returns A nullable array of numbers, or a float32 array
  74370. */
  74371. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  74372. /**
  74373. * Gets the indices from the mesh
  74374. * @returns A nullable array of index arrays
  74375. */
  74376. getIndices?(): Nullable<IndicesArray>;
  74377. /**
  74378. * Gets the scene from the mesh
  74379. * @returns the indices array or null
  74380. */
  74381. getScene?(): Scene;
  74382. /**
  74383. * Gets the absolute position from the mesh
  74384. * @returns the absolute position
  74385. */
  74386. getAbsolutePosition(): Vector3;
  74387. /**
  74388. * Gets the absolute pivot point from the mesh
  74389. * @returns the absolute pivot point
  74390. */
  74391. getAbsolutePivotPoint(): Vector3;
  74392. /**
  74393. * Rotates the mesh
  74394. * @param axis The axis of rotation
  74395. * @param amount The amount of rotation
  74396. * @param space The space of the rotation
  74397. * @returns The rotation transform node
  74398. */
  74399. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  74400. /**
  74401. * Translates the mesh
  74402. * @param axis The axis of translation
  74403. * @param distance The distance of translation
  74404. * @param space The space of the translation
  74405. * @returns The transform node
  74406. */
  74407. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  74408. /**
  74409. * Sets the absolute position of the mesh
  74410. * @param absolutePosition The absolute position of the mesh
  74411. * @returns The transform node
  74412. */
  74413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  74414. /**
  74415. * Gets the class name of the mesh
  74416. * @returns The class name
  74417. */
  74418. getClassName(): string;
  74419. }
  74420. /**
  74421. * Represents a physics imposter
  74422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74423. */
  74424. export class PhysicsImpostor {
  74425. /**
  74426. * The physics-enabled object used as the physics imposter
  74427. */
  74428. object: IPhysicsEnabledObject;
  74429. /**
  74430. * The type of the physics imposter
  74431. */
  74432. type: number;
  74433. private _options;
  74434. private _scene?;
  74435. /**
  74436. * The default object size of the imposter
  74437. */
  74438. static DEFAULT_OBJECT_SIZE: Vector3;
  74439. /**
  74440. * The identity quaternion of the imposter
  74441. */
  74442. static IDENTITY_QUATERNION: Quaternion;
  74443. /** @hidden */
  74444. _pluginData: any;
  74445. private _physicsEngine;
  74446. private _physicsBody;
  74447. private _bodyUpdateRequired;
  74448. private _onBeforePhysicsStepCallbacks;
  74449. private _onAfterPhysicsStepCallbacks;
  74450. /** @hidden */
  74451. _onPhysicsCollideCallbacks: Array<{
  74452. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  74453. otherImpostors: Array<PhysicsImpostor>;
  74454. }>;
  74455. private _deltaPosition;
  74456. private _deltaRotation;
  74457. private _deltaRotationConjugated;
  74458. private _parent;
  74459. private _isDisposed;
  74460. private static _tmpVecs;
  74461. private static _tmpQuat;
  74462. /**
  74463. * Specifies if the physics imposter is disposed
  74464. */
  74465. readonly isDisposed: boolean;
  74466. /**
  74467. * Gets the mass of the physics imposter
  74468. */
  74469. mass: number;
  74470. /**
  74471. * Gets the coefficient of friction
  74472. */
  74473. /**
  74474. * Sets the coefficient of friction
  74475. */
  74476. friction: number;
  74477. /**
  74478. * Gets the coefficient of restitution
  74479. */
  74480. /**
  74481. * Sets the coefficient of restitution
  74482. */
  74483. restitution: number;
  74484. /**
  74485. * The unique id of the physics imposter
  74486. * set by the physics engine when adding this impostor to the array
  74487. */
  74488. uniqueId: number;
  74489. private _joints;
  74490. /**
  74491. * Initializes the physics imposter
  74492. * @param object The physics-enabled object used as the physics imposter
  74493. * @param type The type of the physics imposter
  74494. * @param _options The options for the physics imposter
  74495. * @param _scene The Babylon scene
  74496. */
  74497. constructor(
  74498. /**
  74499. * The physics-enabled object used as the physics imposter
  74500. */
  74501. object: IPhysicsEnabledObject,
  74502. /**
  74503. * The type of the physics imposter
  74504. */
  74505. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  74506. /**
  74507. * This function will completly initialize this impostor.
  74508. * It will create a new body - but only if this mesh has no parent.
  74509. * If it has, this impostor will not be used other than to define the impostor
  74510. * of the child mesh.
  74511. * @hidden
  74512. */
  74513. _init(): void;
  74514. private _getPhysicsParent;
  74515. /**
  74516. * Should a new body be generated.
  74517. * @returns boolean specifying if body initialization is required
  74518. */
  74519. isBodyInitRequired(): boolean;
  74520. /**
  74521. * Sets the updated scaling
  74522. * @param updated Specifies if the scaling is updated
  74523. */
  74524. setScalingUpdated(): void;
  74525. /**
  74526. * Force a regeneration of this or the parent's impostor's body.
  74527. * Use under cautious - This will remove all joints already implemented.
  74528. */
  74529. forceUpdate(): void;
  74530. /**
  74531. * Gets the body that holds this impostor. Either its own, or its parent.
  74532. */
  74533. /**
  74534. * Set the physics body. Used mainly by the physics engine/plugin
  74535. */
  74536. physicsBody: any;
  74537. /**
  74538. * Get the parent of the physics imposter
  74539. * @returns Physics imposter or null
  74540. */
  74541. /**
  74542. * Sets the parent of the physics imposter
  74543. */
  74544. parent: Nullable<PhysicsImpostor>;
  74545. /**
  74546. * Resets the update flags
  74547. */
  74548. resetUpdateFlags(): void;
  74549. /**
  74550. * Gets the object extend size
  74551. * @returns the object extend size
  74552. */
  74553. getObjectExtendSize(): Vector3;
  74554. /**
  74555. * Gets the object center
  74556. * @returns The object center
  74557. */
  74558. getObjectCenter(): Vector3;
  74559. /**
  74560. * Get a specific parametes from the options parameter
  74561. * @param paramName The object parameter name
  74562. * @returns The object parameter
  74563. */
  74564. getParam(paramName: string): any;
  74565. /**
  74566. * Sets a specific parameter in the options given to the physics plugin
  74567. * @param paramName The parameter name
  74568. * @param value The value of the parameter
  74569. */
  74570. setParam(paramName: string, value: number): void;
  74571. /**
  74572. * Specifically change the body's mass option. Won't recreate the physics body object
  74573. * @param mass The mass of the physics imposter
  74574. */
  74575. setMass(mass: number): void;
  74576. /**
  74577. * Gets the linear velocity
  74578. * @returns linear velocity or null
  74579. */
  74580. getLinearVelocity(): Nullable<Vector3>;
  74581. /**
  74582. * Sets the linear velocity
  74583. * @param velocity linear velocity or null
  74584. */
  74585. setLinearVelocity(velocity: Nullable<Vector3>): void;
  74586. /**
  74587. * Gets the angular velocity
  74588. * @returns angular velocity or null
  74589. */
  74590. getAngularVelocity(): Nullable<Vector3>;
  74591. /**
  74592. * Sets the angular velocity
  74593. * @param velocity The velocity or null
  74594. */
  74595. setAngularVelocity(velocity: Nullable<Vector3>): void;
  74596. /**
  74597. * Execute a function with the physics plugin native code
  74598. * Provide a function the will have two variables - the world object and the physics body object
  74599. * @param func The function to execute with the physics plugin native code
  74600. */
  74601. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  74602. /**
  74603. * Register a function that will be executed before the physics world is stepping forward
  74604. * @param func The function to execute before the physics world is stepped forward
  74605. */
  74606. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74607. /**
  74608. * Unregister a function that will be executed before the physics world is stepping forward
  74609. * @param func The function to execute before the physics world is stepped forward
  74610. */
  74611. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74612. /**
  74613. * Register a function that will be executed after the physics step
  74614. * @param func The function to execute after physics step
  74615. */
  74616. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74617. /**
  74618. * Unregisters a function that will be executed after the physics step
  74619. * @param func The function to execute after physics step
  74620. */
  74621. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74622. /**
  74623. * register a function that will be executed when this impostor collides against a different body
  74624. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  74625. * @param func Callback that is executed on collision
  74626. */
  74627. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  74628. /**
  74629. * Unregisters the physics imposter on contact
  74630. * @param collideAgainst The physics object to collide against
  74631. * @param func Callback to execute on collision
  74632. */
  74633. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  74634. private _tmpQuat;
  74635. private _tmpQuat2;
  74636. /**
  74637. * Get the parent rotation
  74638. * @returns The parent rotation
  74639. */
  74640. getParentsRotation(): Quaternion;
  74641. /**
  74642. * this function is executed by the physics engine.
  74643. */
  74644. beforeStep: () => void;
  74645. /**
  74646. * this function is executed by the physics engine
  74647. */
  74648. afterStep: () => void;
  74649. /**
  74650. * Legacy collision detection event support
  74651. */
  74652. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  74653. /**
  74654. * event and body object due to cannon's event-based architecture.
  74655. */
  74656. onCollide: (e: {
  74657. body: any;
  74658. }) => void;
  74659. /**
  74660. * Apply a force
  74661. * @param force The force to apply
  74662. * @param contactPoint The contact point for the force
  74663. * @returns The physics imposter
  74664. */
  74665. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  74666. /**
  74667. * Apply an impulse
  74668. * @param force The impulse force
  74669. * @param contactPoint The contact point for the impulse force
  74670. * @returns The physics imposter
  74671. */
  74672. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  74673. /**
  74674. * A help function to create a joint
  74675. * @param otherImpostor A physics imposter used to create a joint
  74676. * @param jointType The type of joint
  74677. * @param jointData The data for the joint
  74678. * @returns The physics imposter
  74679. */
  74680. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  74681. /**
  74682. * Add a joint to this impostor with a different impostor
  74683. * @param otherImpostor A physics imposter used to add a joint
  74684. * @param joint The joint to add
  74685. * @returns The physics imposter
  74686. */
  74687. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  74688. /**
  74689. * Will keep this body still, in a sleep mode.
  74690. * @returns the physics imposter
  74691. */
  74692. sleep(): PhysicsImpostor;
  74693. /**
  74694. * Wake the body up.
  74695. * @returns The physics imposter
  74696. */
  74697. wakeUp(): PhysicsImpostor;
  74698. /**
  74699. * Clones the physics imposter
  74700. * @param newObject The physics imposter clones to this physics-enabled object
  74701. * @returns A nullable physics imposter
  74702. */
  74703. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74704. /**
  74705. * Disposes the physics imposter
  74706. */
  74707. dispose(): void;
  74708. /**
  74709. * Sets the delta position
  74710. * @param position The delta position amount
  74711. */
  74712. setDeltaPosition(position: Vector3): void;
  74713. /**
  74714. * Sets the delta rotation
  74715. * @param rotation The delta rotation amount
  74716. */
  74717. setDeltaRotation(rotation: Quaternion): void;
  74718. /**
  74719. * Gets the box size of the physics imposter and stores the result in the input parameter
  74720. * @param result Stores the box size
  74721. * @returns The physics imposter
  74722. */
  74723. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  74724. /**
  74725. * Gets the radius of the physics imposter
  74726. * @returns Radius of the physics imposter
  74727. */
  74728. getRadius(): number;
  74729. /**
  74730. * Sync a bone with this impostor
  74731. * @param bone The bone to sync to the impostor.
  74732. * @param boneMesh The mesh that the bone is influencing.
  74733. * @param jointPivot The pivot of the joint / bone in local space.
  74734. * @param distToJoint Optional distance from the impostor to the joint.
  74735. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  74736. */
  74737. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  74738. /**
  74739. * Sync impostor to a bone
  74740. * @param bone The bone that the impostor will be synced to.
  74741. * @param boneMesh The mesh that the bone is influencing.
  74742. * @param jointPivot The pivot of the joint / bone in local space.
  74743. * @param distToJoint Optional distance from the impostor to the joint.
  74744. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  74745. * @param boneAxis Optional vector3 axis the bone is aligned with
  74746. */
  74747. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  74748. /**
  74749. * No-Imposter type
  74750. */
  74751. static NoImpostor: number;
  74752. /**
  74753. * Sphere-Imposter type
  74754. */
  74755. static SphereImpostor: number;
  74756. /**
  74757. * Box-Imposter type
  74758. */
  74759. static BoxImpostor: number;
  74760. /**
  74761. * Plane-Imposter type
  74762. */
  74763. static PlaneImpostor: number;
  74764. /**
  74765. * Mesh-imposter type
  74766. */
  74767. static MeshImpostor: number;
  74768. /**
  74769. * Cylinder-Imposter type
  74770. */
  74771. static CylinderImpostor: number;
  74772. /**
  74773. * Particle-Imposter type
  74774. */
  74775. static ParticleImpostor: number;
  74776. /**
  74777. * Heightmap-Imposter type
  74778. */
  74779. static HeightmapImpostor: number;
  74780. }
  74781. }
  74782. declare module BABYLON {
  74783. /**
  74784. * Mesh representing the gorund
  74785. */
  74786. export class GroundMesh extends Mesh {
  74787. /** If octree should be generated */
  74788. generateOctree: boolean;
  74789. private _heightQuads;
  74790. /** @hidden */
  74791. _subdivisionsX: number;
  74792. /** @hidden */
  74793. _subdivisionsY: number;
  74794. /** @hidden */
  74795. _width: number;
  74796. /** @hidden */
  74797. _height: number;
  74798. /** @hidden */
  74799. _minX: number;
  74800. /** @hidden */
  74801. _maxX: number;
  74802. /** @hidden */
  74803. _minZ: number;
  74804. /** @hidden */
  74805. _maxZ: number;
  74806. constructor(name: string, scene: Scene);
  74807. /**
  74808. * "GroundMesh"
  74809. * @returns "GroundMesh"
  74810. */
  74811. getClassName(): string;
  74812. /**
  74813. * The minimum of x and y subdivisions
  74814. */
  74815. readonly subdivisions: number;
  74816. /**
  74817. * X subdivisions
  74818. */
  74819. readonly subdivisionsX: number;
  74820. /**
  74821. * Y subdivisions
  74822. */
  74823. readonly subdivisionsY: number;
  74824. /**
  74825. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74826. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74827. * @param chunksCount the number of subdivisions for x and y
  74828. * @param octreeBlocksSize (Default: 32)
  74829. */
  74830. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74831. /**
  74832. * Returns a height (y) value in the Worl system :
  74833. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74834. * @param x x coordinate
  74835. * @param z z coordinate
  74836. * @returns the ground y position if (x, z) are outside the ground surface.
  74837. */
  74838. getHeightAtCoordinates(x: number, z: number): number;
  74839. /**
  74840. * Returns a normalized vector (Vector3) orthogonal to the ground
  74841. * at the ground coordinates (x, z) expressed in the World system.
  74842. * @param x x coordinate
  74843. * @param z z coordinate
  74844. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74845. */
  74846. getNormalAtCoordinates(x: number, z: number): Vector3;
  74847. /**
  74848. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74849. * at the ground coordinates (x, z) expressed in the World system.
  74850. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74851. * @param x x coordinate
  74852. * @param z z coordinate
  74853. * @param ref vector to store the result
  74854. * @returns the GroundMesh.
  74855. */
  74856. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74857. /**
  74858. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74859. * if the ground has been updated.
  74860. * This can be used in the render loop.
  74861. * @returns the GroundMesh.
  74862. */
  74863. updateCoordinateHeights(): GroundMesh;
  74864. private _getFacetAt;
  74865. private _initHeightQuads;
  74866. private _computeHeightQuads;
  74867. /**
  74868. * Serializes this ground mesh
  74869. * @param serializationObject object to write serialization to
  74870. */
  74871. serialize(serializationObject: any): void;
  74872. /**
  74873. * Parses a serialized ground mesh
  74874. * @param parsedMesh the serialized mesh
  74875. * @param scene the scene to create the ground mesh in
  74876. * @returns the created ground mesh
  74877. */
  74878. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74879. }
  74880. }
  74881. declare module BABYLON {
  74882. /**
  74883. * Class used to represent a specific level of detail of a mesh
  74884. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  74885. */
  74886. export class MeshLODLevel {
  74887. /** Defines the distance where this level should star being displayed */
  74888. distance: number;
  74889. /** Defines the mesh to use to render this level */
  74890. mesh: Nullable<Mesh>;
  74891. /**
  74892. * Creates a new LOD level
  74893. * @param distance defines the distance where this level should star being displayed
  74894. * @param mesh defines the mesh to use to render this level
  74895. */
  74896. constructor(
  74897. /** Defines the distance where this level should star being displayed */
  74898. distance: number,
  74899. /** Defines the mesh to use to render this level */
  74900. mesh: Nullable<Mesh>);
  74901. }
  74902. /**
  74903. * @hidden
  74904. **/
  74905. export class _CreationDataStorage {
  74906. closePath?: boolean;
  74907. closeArray?: boolean;
  74908. idx: number[];
  74909. dashSize: number;
  74910. gapSize: number;
  74911. path3D: Path3D;
  74912. pathArray: Vector3[][];
  74913. arc: number;
  74914. radius: number;
  74915. cap: number;
  74916. tessellation: number;
  74917. }
  74918. /**
  74919. * @hidden
  74920. **/
  74921. class _InstanceDataStorage {
  74922. visibleInstances: any;
  74923. renderIdForInstances: number[];
  74924. batchCache: _InstancesBatch;
  74925. instancesBufferSize: number;
  74926. instancesBuffer: Nullable<Buffer>;
  74927. instancesData: Float32Array;
  74928. overridenInstanceCount: number;
  74929. }
  74930. /**
  74931. * @hidden
  74932. **/
  74933. export class _InstancesBatch {
  74934. mustReturn: boolean;
  74935. visibleInstances: Nullable<InstancedMesh[]>[];
  74936. renderSelf: boolean[];
  74937. }
  74938. /**
  74939. * Class used to represent renderable models
  74940. */
  74941. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  74942. /**
  74943. * Mesh side orientation : usually the external or front surface
  74944. */
  74945. static readonly FRONTSIDE: number;
  74946. /**
  74947. * Mesh side orientation : usually the internal or back surface
  74948. */
  74949. static readonly BACKSIDE: number;
  74950. /**
  74951. * Mesh side orientation : both internal and external or front and back surfaces
  74952. */
  74953. static readonly DOUBLESIDE: number;
  74954. /**
  74955. * Mesh side orientation : by default, `FRONTSIDE`
  74956. */
  74957. static readonly DEFAULTSIDE: number;
  74958. /**
  74959. * Mesh cap setting : no cap
  74960. */
  74961. static readonly NO_CAP: number;
  74962. /**
  74963. * Mesh cap setting : one cap at the beginning of the mesh
  74964. */
  74965. static readonly CAP_START: number;
  74966. /**
  74967. * Mesh cap setting : one cap at the end of the mesh
  74968. */
  74969. static readonly CAP_END: number;
  74970. /**
  74971. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  74972. */
  74973. static readonly CAP_ALL: number;
  74974. private _onBeforeRenderObservable;
  74975. private _onBeforeBindObservable;
  74976. private _onAfterRenderObservable;
  74977. private _onBeforeDrawObservable;
  74978. /**
  74979. * An event triggered before rendering the mesh
  74980. */
  74981. readonly onBeforeRenderObservable: Observable<Mesh>;
  74982. /**
  74983. * An event triggered before binding the mesh
  74984. */
  74985. readonly onBeforeBindObservable: Observable<Mesh>;
  74986. /**
  74987. * An event triggered after rendering the mesh
  74988. */
  74989. readonly onAfterRenderObservable: Observable<Mesh>;
  74990. /**
  74991. * An event triggered before drawing the mesh
  74992. */
  74993. readonly onBeforeDrawObservable: Observable<Mesh>;
  74994. private _onBeforeDrawObserver;
  74995. /**
  74996. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  74997. */
  74998. onBeforeDraw: () => void;
  74999. /**
  75000. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75001. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75002. */
  75003. delayLoadState: number;
  75004. /**
  75005. * Gets the list of instances created from this mesh
  75006. * it is not supposed to be modified manually.
  75007. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75008. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75009. */
  75010. instances: InstancedMesh[];
  75011. /**
  75012. * Gets the file containing delay loading data for this mesh
  75013. */
  75014. delayLoadingFile: string;
  75015. /** @hidden */
  75016. _binaryInfo: any;
  75017. private _LODLevels;
  75018. /**
  75019. * User defined function used to change how LOD level selection is done
  75020. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75021. */
  75022. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75023. private _morphTargetManager;
  75024. /**
  75025. * Gets or sets the morph target manager
  75026. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75027. */
  75028. morphTargetManager: Nullable<MorphTargetManager>;
  75029. /** @hidden */
  75030. _creationDataStorage: Nullable<_CreationDataStorage>;
  75031. /** @hidden */
  75032. _geometry: Nullable<Geometry>;
  75033. /** @hidden */
  75034. _delayInfo: Array<string>;
  75035. /** @hidden */
  75036. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75037. /** @hidden */
  75038. _instanceDataStorage: _InstanceDataStorage;
  75039. private _effectiveMaterial;
  75040. /** @hidden */
  75041. _shouldGenerateFlatShading: boolean;
  75042. private _preActivateId;
  75043. /** @hidden */
  75044. _originalBuilderSideOrientation: number;
  75045. /**
  75046. * Use this property to change the original side orientation defined at construction time
  75047. */
  75048. overrideMaterialSideOrientation: Nullable<number>;
  75049. private _areNormalsFrozen;
  75050. private _sourcePositions;
  75051. private _sourceNormals;
  75052. private _source;
  75053. private meshMap;
  75054. /**
  75055. * Gets the source mesh (the one used to clone this one from)
  75056. */
  75057. readonly source: Nullable<Mesh>;
  75058. /**
  75059. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75060. */
  75061. isUnIndexed: boolean;
  75062. /**
  75063. * @constructor
  75064. * @param name The value used by scene.getMeshByName() to do a lookup.
  75065. * @param scene The scene to add this mesh to.
  75066. * @param parent The parent of this mesh, if it has one
  75067. * @param source An optional Mesh from which geometry is shared, cloned.
  75068. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75069. * When false, achieved by calling a clone(), also passing False.
  75070. * This will make creation of children, recursive.
  75071. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75072. */
  75073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75074. /**
  75075. * Gets the class name
  75076. * @returns the string "Mesh".
  75077. */
  75078. getClassName(): string;
  75079. /** @hidden */
  75080. readonly _isMesh: boolean;
  75081. /**
  75082. * Returns a description of this mesh
  75083. * @param fullDetails define if full details about this mesh must be used
  75084. * @returns a descriptive string representing this mesh
  75085. */
  75086. toString(fullDetails?: boolean): string;
  75087. /** @hidden */
  75088. _unBindEffect(): void;
  75089. /**
  75090. * Gets a boolean indicating if this mesh has LOD
  75091. */
  75092. readonly hasLODLevels: boolean;
  75093. /**
  75094. * Gets the list of MeshLODLevel associated with the current mesh
  75095. * @returns an array of MeshLODLevel
  75096. */
  75097. getLODLevels(): MeshLODLevel[];
  75098. private _sortLODLevels;
  75099. /**
  75100. * Add a mesh as LOD level triggered at the given distance.
  75101. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75102. * @param distance The distance from the center of the object to show this level
  75103. * @param mesh The mesh to be added as LOD level (can be null)
  75104. * @return This mesh (for chaining)
  75105. */
  75106. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75107. /**
  75108. * Returns the LOD level mesh at the passed distance or null if not found.
  75109. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75110. * @param distance The distance from the center of the object to show this level
  75111. * @returns a Mesh or `null`
  75112. */
  75113. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75114. /**
  75115. * Remove a mesh from the LOD array
  75116. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75117. * @param mesh defines the mesh to be removed
  75118. * @return This mesh (for chaining)
  75119. */
  75120. removeLODLevel(mesh: Mesh): Mesh;
  75121. /**
  75122. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75124. * @param camera defines the camera to use to compute distance
  75125. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75126. * @return This mesh (for chaining)
  75127. */
  75128. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75129. /**
  75130. * Gets the mesh internal Geometry object
  75131. */
  75132. readonly geometry: Nullable<Geometry>;
  75133. /**
  75134. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75135. * @returns the total number of vertices
  75136. */
  75137. getTotalVertices(): number;
  75138. /**
  75139. * Returns the content of an associated vertex buffer
  75140. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75141. * - VertexBuffer.PositionKind
  75142. * - VertexBuffer.UVKind
  75143. * - VertexBuffer.UV2Kind
  75144. * - VertexBuffer.UV3Kind
  75145. * - VertexBuffer.UV4Kind
  75146. * - VertexBuffer.UV5Kind
  75147. * - VertexBuffer.UV6Kind
  75148. * - VertexBuffer.ColorKind
  75149. * - VertexBuffer.MatricesIndicesKind
  75150. * - VertexBuffer.MatricesIndicesExtraKind
  75151. * - VertexBuffer.MatricesWeightsKind
  75152. * - VertexBuffer.MatricesWeightsExtraKind
  75153. * @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
  75154. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75155. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75156. */
  75157. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75158. /**
  75159. * Returns the mesh VertexBuffer object from the requested `kind`
  75160. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75161. * - VertexBuffer.PositionKind
  75162. * - VertexBuffer.UVKind
  75163. * - VertexBuffer.UV2Kind
  75164. * - VertexBuffer.UV3Kind
  75165. * - VertexBuffer.UV4Kind
  75166. * - VertexBuffer.UV5Kind
  75167. * - VertexBuffer.UV6Kind
  75168. * - VertexBuffer.ColorKind
  75169. * - VertexBuffer.MatricesIndicesKind
  75170. * - VertexBuffer.MatricesIndicesExtraKind
  75171. * - VertexBuffer.MatricesWeightsKind
  75172. * - VertexBuffer.MatricesWeightsExtraKind
  75173. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75174. */
  75175. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75176. /**
  75177. * Tests if a specific vertex buffer is associated with this mesh
  75178. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75179. * - VertexBuffer.PositionKind
  75180. * - VertexBuffer.UVKind
  75181. * - VertexBuffer.UV2Kind
  75182. * - VertexBuffer.UV3Kind
  75183. * - VertexBuffer.UV4Kind
  75184. * - VertexBuffer.UV5Kind
  75185. * - VertexBuffer.UV6Kind
  75186. * - VertexBuffer.ColorKind
  75187. * - VertexBuffer.MatricesIndicesKind
  75188. * - VertexBuffer.MatricesIndicesExtraKind
  75189. * - VertexBuffer.MatricesWeightsKind
  75190. * - VertexBuffer.MatricesWeightsExtraKind
  75191. * @returns a boolean
  75192. */
  75193. isVerticesDataPresent(kind: string): boolean;
  75194. /**
  75195. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75196. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75197. * - VertexBuffer.PositionKind
  75198. * - VertexBuffer.UVKind
  75199. * - VertexBuffer.UV2Kind
  75200. * - VertexBuffer.UV3Kind
  75201. * - VertexBuffer.UV4Kind
  75202. * - VertexBuffer.UV5Kind
  75203. * - VertexBuffer.UV6Kind
  75204. * - VertexBuffer.ColorKind
  75205. * - VertexBuffer.MatricesIndicesKind
  75206. * - VertexBuffer.MatricesIndicesExtraKind
  75207. * - VertexBuffer.MatricesWeightsKind
  75208. * - VertexBuffer.MatricesWeightsExtraKind
  75209. * @returns a boolean
  75210. */
  75211. isVertexBufferUpdatable(kind: string): boolean;
  75212. /**
  75213. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75214. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75215. * - VertexBuffer.PositionKind
  75216. * - VertexBuffer.UVKind
  75217. * - VertexBuffer.UV2Kind
  75218. * - VertexBuffer.UV3Kind
  75219. * - VertexBuffer.UV4Kind
  75220. * - VertexBuffer.UV5Kind
  75221. * - VertexBuffer.UV6Kind
  75222. * - VertexBuffer.ColorKind
  75223. * - VertexBuffer.MatricesIndicesKind
  75224. * - VertexBuffer.MatricesIndicesExtraKind
  75225. * - VertexBuffer.MatricesWeightsKind
  75226. * - VertexBuffer.MatricesWeightsExtraKind
  75227. * @returns an array of strings
  75228. */
  75229. getVerticesDataKinds(): string[];
  75230. /**
  75231. * Returns a positive integer : the total number of indices in this mesh geometry.
  75232. * @returns the numner of indices or zero if the mesh has no geometry.
  75233. */
  75234. getTotalIndices(): number;
  75235. /**
  75236. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75237. * @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.
  75238. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75239. * @returns the indices array or an empty array if the mesh has no geometry
  75240. */
  75241. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75242. readonly isBlocked: boolean;
  75243. /**
  75244. * Determine if the current mesh is ready to be rendered
  75245. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75246. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75247. * @returns true if all associated assets are ready (material, textures, shaders)
  75248. */
  75249. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75250. /**
  75251. * 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.
  75252. */
  75253. readonly areNormalsFrozen: boolean;
  75254. /**
  75255. * 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.
  75256. * @returns the current mesh
  75257. */
  75258. freezeNormals(): Mesh;
  75259. /**
  75260. * 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
  75261. * @returns the current mesh
  75262. */
  75263. unfreezeNormals(): Mesh;
  75264. /**
  75265. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75266. */
  75267. overridenInstanceCount: number;
  75268. /** @hidden */
  75269. _preActivate(): Mesh;
  75270. /** @hidden */
  75271. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75272. /** @hidden */
  75273. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75274. /**
  75275. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75276. * This means the mesh underlying bounding box and sphere are recomputed.
  75277. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75278. * @returns the current mesh
  75279. */
  75280. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75281. /** @hidden */
  75282. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75283. /**
  75284. * This function will subdivide the mesh into multiple submeshes
  75285. * @param count defines the expected number of submeshes
  75286. */
  75287. subdivide(count: number): void;
  75288. /**
  75289. * Copy a FloatArray into a specific associated vertex buffer
  75290. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75291. * - VertexBuffer.PositionKind
  75292. * - VertexBuffer.UVKind
  75293. * - VertexBuffer.UV2Kind
  75294. * - VertexBuffer.UV3Kind
  75295. * - VertexBuffer.UV4Kind
  75296. * - VertexBuffer.UV5Kind
  75297. * - VertexBuffer.UV6Kind
  75298. * - VertexBuffer.ColorKind
  75299. * - VertexBuffer.MatricesIndicesKind
  75300. * - VertexBuffer.MatricesIndicesExtraKind
  75301. * - VertexBuffer.MatricesWeightsKind
  75302. * - VertexBuffer.MatricesWeightsExtraKind
  75303. * @param data defines the data source
  75304. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75305. * @param stride defines the data stride size (can be null)
  75306. * @returns the current mesh
  75307. */
  75308. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75309. /**
  75310. * Flags an associated vertex buffer as updatable
  75311. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75312. * - VertexBuffer.PositionKind
  75313. * - VertexBuffer.UVKind
  75314. * - VertexBuffer.UV2Kind
  75315. * - VertexBuffer.UV3Kind
  75316. * - VertexBuffer.UV4Kind
  75317. * - VertexBuffer.UV5Kind
  75318. * - VertexBuffer.UV6Kind
  75319. * - VertexBuffer.ColorKind
  75320. * - VertexBuffer.MatricesIndicesKind
  75321. * - VertexBuffer.MatricesIndicesExtraKind
  75322. * - VertexBuffer.MatricesWeightsKind
  75323. * - VertexBuffer.MatricesWeightsExtraKind
  75324. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75325. */
  75326. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  75327. /**
  75328. * Sets the mesh global Vertex Buffer
  75329. * @param buffer defines the buffer to use
  75330. * @returns the current mesh
  75331. */
  75332. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  75333. /**
  75334. * Update a specific associated vertex buffer
  75335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75336. * - VertexBuffer.PositionKind
  75337. * - VertexBuffer.UVKind
  75338. * - VertexBuffer.UV2Kind
  75339. * - VertexBuffer.UV3Kind
  75340. * - VertexBuffer.UV4Kind
  75341. * - VertexBuffer.UV5Kind
  75342. * - VertexBuffer.UV6Kind
  75343. * - VertexBuffer.ColorKind
  75344. * - VertexBuffer.MatricesIndicesKind
  75345. * - VertexBuffer.MatricesIndicesExtraKind
  75346. * - VertexBuffer.MatricesWeightsKind
  75347. * - VertexBuffer.MatricesWeightsExtraKind
  75348. * @param data defines the data source
  75349. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  75350. * @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)
  75351. * @returns the current mesh
  75352. */
  75353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75354. /**
  75355. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  75356. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  75357. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  75358. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  75359. * @returns the current mesh
  75360. */
  75361. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  75362. /**
  75363. * Creates a un-shared specific occurence of the geometry for the mesh.
  75364. * @returns the current mesh
  75365. */
  75366. makeGeometryUnique(): Mesh;
  75367. /**
  75368. * Set the index buffer of this mesh
  75369. * @param indices defines the source data
  75370. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  75371. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  75372. * @returns the current mesh
  75373. */
  75374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  75375. /**
  75376. * Update the current index buffer
  75377. * @param indices defines the source data
  75378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  75379. * @returns the current mesh
  75380. */
  75381. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  75382. /**
  75383. * Invert the geometry to move from a right handed system to a left handed one.
  75384. * @returns the current mesh
  75385. */
  75386. toLeftHanded(): Mesh;
  75387. /** @hidden */
  75388. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  75389. /** @hidden */
  75390. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  75391. /**
  75392. * Registers for this mesh a javascript function called just before the rendering process
  75393. * @param func defines the function to call before rendering this mesh
  75394. * @returns the current mesh
  75395. */
  75396. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75397. /**
  75398. * Disposes a previously registered javascript function called before the rendering
  75399. * @param func defines the function to remove
  75400. * @returns the current mesh
  75401. */
  75402. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75403. /**
  75404. * Registers for this mesh a javascript function called just after the rendering is complete
  75405. * @param func defines the function to call after rendering this mesh
  75406. * @returns the current mesh
  75407. */
  75408. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75409. /**
  75410. * Disposes a previously registered javascript function called after the rendering.
  75411. * @param func defines the function to remove
  75412. * @returns the current mesh
  75413. */
  75414. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75415. /** @hidden */
  75416. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  75417. /** @hidden */
  75418. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  75419. /** @hidden */
  75420. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  75421. /**
  75422. * 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
  75423. * @param subMesh defines the subMesh to render
  75424. * @param enableAlphaMode defines if alpha mode can be changed
  75425. * @returns the current mesh
  75426. */
  75427. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  75428. private _onBeforeDraw;
  75429. /**
  75430. * Renormalize the mesh and patch it up if there are no weights
  75431. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  75432. * However in the case of zero weights then we set just a single influence to 1.
  75433. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  75434. */
  75435. cleanMatrixWeights(): void;
  75436. private normalizeSkinFourWeights;
  75437. private normalizeSkinWeightsAndExtra;
  75438. /**
  75439. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  75440. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  75441. * the user know there was an issue with importing the mesh
  75442. * @returns a validation object with skinned, valid and report string
  75443. */
  75444. validateSkinning(): {
  75445. skinned: boolean;
  75446. valid: boolean;
  75447. report: string;
  75448. };
  75449. /** @hidden */
  75450. _checkDelayState(): Mesh;
  75451. private _queueLoad;
  75452. /**
  75453. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75454. * A mesh is in the frustum if its bounding box intersects the frustum
  75455. * @param frustumPlanes defines the frustum to test
  75456. * @returns true if the mesh is in the frustum planes
  75457. */
  75458. isInFrustum(frustumPlanes: Plane[]): boolean;
  75459. /**
  75460. * Sets the mesh material by the material or multiMaterial `id` property
  75461. * @param id is a string identifying the material or the multiMaterial
  75462. * @returns the current mesh
  75463. */
  75464. setMaterialByID(id: string): Mesh;
  75465. /**
  75466. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  75467. * @returns an array of IAnimatable
  75468. */
  75469. getAnimatables(): IAnimatable[];
  75470. /**
  75471. * Modifies the mesh geometry according to the passed transformation matrix.
  75472. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  75473. * The mesh normals are modified using the same transformation.
  75474. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75475. * @param transform defines the transform matrix to use
  75476. * @see http://doc.babylonjs.com/resources/baking_transformations
  75477. * @returns the current mesh
  75478. */
  75479. bakeTransformIntoVertices(transform: Matrix): Mesh;
  75480. /**
  75481. * Modifies the mesh geometry according to its own current World Matrix.
  75482. * The mesh World Matrix is then reset.
  75483. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  75484. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75485. * @see http://doc.babylonjs.com/resources/baking_transformations
  75486. * @returns the current mesh
  75487. */
  75488. bakeCurrentTransformIntoVertices(): Mesh;
  75489. /** @hidden */
  75490. readonly _positions: Nullable<Vector3[]>;
  75491. /** @hidden */
  75492. _resetPointsArrayCache(): Mesh;
  75493. /** @hidden */
  75494. _generatePointsArray(): boolean;
  75495. /**
  75496. * Returns a new Mesh object generated from the current mesh properties.
  75497. * This method must not get confused with createInstance()
  75498. * @param name is a string, the name given to the new mesh
  75499. * @param newParent can be any Node object (default `null`)
  75500. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  75501. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  75502. * @returns a new mesh
  75503. */
  75504. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  75505. /**
  75506. * Releases resources associated with this mesh.
  75507. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75508. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75509. */
  75510. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75511. /**
  75512. * Modifies the mesh geometry according to a displacement map.
  75513. * 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.
  75514. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  75515. * @param url is a string, the URL from the image file is to be downloaded.
  75516. * @param minHeight is the lower limit of the displacement.
  75517. * @param maxHeight is the upper limit of the displacement.
  75518. * @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.
  75519. * @param uvOffset is an optional vector2 used to offset UV.
  75520. * @param uvScale is an optional vector2 used to scale UV.
  75521. * @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.
  75522. * @returns the Mesh.
  75523. */
  75524. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  75525. /**
  75526. * Modifies the mesh geometry according to a displacementMap buffer.
  75527. * 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.
  75528. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  75529. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  75530. * @param heightMapWidth is the width of the buffer image.
  75531. * @param heightMapHeight is the height of the buffer image.
  75532. * @param minHeight is the lower limit of the displacement.
  75533. * @param maxHeight is the upper limit of the displacement.
  75534. * @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.
  75535. * @param uvOffset is an optional vector2 used to offset UV.
  75536. * @param uvScale is an optional vector2 used to scale UV.
  75537. * @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.
  75538. * @returns the Mesh.
  75539. */
  75540. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  75541. /**
  75542. * Modify the mesh to get a flat shading rendering.
  75543. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  75544. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  75545. * @returns current mesh
  75546. */
  75547. convertToFlatShadedMesh(): Mesh;
  75548. /**
  75549. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  75550. * In other words, more vertices, no more indices and a single bigger VBO.
  75551. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  75552. * @returns current mesh
  75553. */
  75554. convertToUnIndexedMesh(): Mesh;
  75555. /**
  75556. * Inverses facet orientations.
  75557. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  75558. * @param flipNormals will also inverts the normals
  75559. * @returns current mesh
  75560. */
  75561. flipFaces(flipNormals?: boolean): Mesh;
  75562. /** @hidden */
  75563. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  75564. /**
  75565. * Creates a new InstancedMesh object from the mesh model.
  75566. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75567. * @param name defines the name of the new instance
  75568. * @returns a new InstancedMesh
  75569. */
  75570. createInstance(name: string): InstancedMesh;
  75571. /**
  75572. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  75573. * After this call, all the mesh instances have the same submeshes than the current mesh.
  75574. * @returns the current mesh
  75575. */
  75576. synchronizeInstances(): Mesh;
  75577. /**
  75578. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  75579. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  75580. * This should be used together with the simplification to avoid disappearing triangles.
  75581. * @param successCallback an optional success callback to be called after the optimization finished.
  75582. * @returns the current mesh
  75583. */
  75584. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  75585. /**
  75586. * Serialize current mesh
  75587. * @param serializationObject defines the object which will receive the serialization data
  75588. */
  75589. serialize(serializationObject: any): void;
  75590. /** @hidden */
  75591. _syncGeometryWithMorphTargetManager(): void;
  75592. /** @hidden */
  75593. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  75594. /**
  75595. * Returns a new Mesh object parsed from the source provided.
  75596. * @param parsedMesh is the source
  75597. * @param scene defines the hosting scene
  75598. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  75599. * @returns a new Mesh
  75600. */
  75601. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  75602. /**
  75603. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  75604. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75605. * @param name defines the name of the mesh to create
  75606. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  75607. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  75608. * @param closePath creates a seam between the first and the last points of each path of the path array
  75609. * @param offset is taken in account only if the `pathArray` is containing a single path
  75610. * @param scene defines the hosting scene
  75611. * @param updatable defines if the mesh must be flagged as updatable
  75612. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75613. * @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)
  75614. * @returns a new Mesh
  75615. */
  75616. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75617. /**
  75618. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  75619. * @param name defines the name of the mesh to create
  75620. * @param radius sets the radius size (float) of the polygon (default 0.5)
  75621. * @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
  75622. * @param scene defines the hosting scene
  75623. * @param updatable defines if the mesh must be flagged as updatable
  75624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75625. * @returns a new Mesh
  75626. */
  75627. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  75628. /**
  75629. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  75630. * @param name defines the name of the mesh to create
  75631. * @param size sets the size (float) of each box side (default 1)
  75632. * @param scene defines the hosting scene
  75633. * @param updatable defines if the mesh must be flagged as updatable
  75634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75635. * @returns a new Mesh
  75636. */
  75637. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  75638. /**
  75639. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  75640. * @param name defines the name of the mesh to create
  75641. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  75642. * @param diameter sets the diameter size (float) of the sphere (default 1)
  75643. * @param scene defines the hosting scene
  75644. * @param updatable defines if the mesh must be flagged as updatable
  75645. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75646. * @returns a new Mesh
  75647. */
  75648. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75649. /**
  75650. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  75651. * @param name defines the name of the mesh to create
  75652. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  75653. * @param diameterTop set the top cap diameter (floats, default 1)
  75654. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  75655. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  75656. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  75657. * @param scene defines the hosting scene
  75658. * @param updatable defines if the mesh must be flagged as updatable
  75659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75660. * @returns a new Mesh
  75661. */
  75662. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  75663. /**
  75664. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  75665. * @param name defines the name of the mesh to create
  75666. * @param diameter sets the diameter size (float) of the torus (default 1)
  75667. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  75668. * @param tessellation sets the number of torus sides (postive integer, default 16)
  75669. * @param scene defines the hosting scene
  75670. * @param updatable defines if the mesh must be flagged as updatable
  75671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75672. * @returns a new Mesh
  75673. */
  75674. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75675. /**
  75676. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  75677. * @param name defines the name of the mesh to create
  75678. * @param radius sets the global radius size (float) of the torus knot (default 2)
  75679. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  75680. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  75681. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  75682. * @param p the number of windings on X axis (positive integers, default 2)
  75683. * @param q the number of windings on Y axis (positive integers, default 3)
  75684. * @param scene defines the hosting scene
  75685. * @param updatable defines if the mesh must be flagged as updatable
  75686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75687. * @returns a new Mesh
  75688. */
  75689. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75690. /**
  75691. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  75692. * @param name defines the name of the mesh to create
  75693. * @param points is an array successive Vector3
  75694. * @param scene defines the hosting scene
  75695. * @param updatable defines if the mesh must be flagged as updatable
  75696. * @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).
  75697. * @returns a new Mesh
  75698. */
  75699. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  75700. /**
  75701. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  75702. * @param name defines the name of the mesh to create
  75703. * @param points is an array successive Vector3
  75704. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  75705. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  75706. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  75707. * @param scene defines the hosting scene
  75708. * @param updatable defines if the mesh must be flagged as updatable
  75709. * @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)
  75710. * @returns a new Mesh
  75711. */
  75712. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  75713. /**
  75714. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  75715. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  75716. * 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.
  75717. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75718. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75719. * Remember you can only change the shape positions, not their number when updating a polygon.
  75720. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  75721. * @param name defines the name of the mesh to create
  75722. * @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
  75723. * @param scene defines the hosting scene
  75724. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  75725. * @param updatable defines if the mesh must be flagged as updatable
  75726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75727. * @returns a new Mesh
  75728. */
  75729. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  75730. /**
  75731. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  75732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  75733. * @param name defines the name of the mesh to create
  75734. * @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
  75735. * @param depth defines the height of extrusion
  75736. * @param scene defines the hosting scene
  75737. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  75738. * @param updatable defines if the mesh must be flagged as updatable
  75739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75740. * @returns a new Mesh
  75741. */
  75742. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  75743. /**
  75744. * Creates an extruded shape mesh.
  75745. * 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
  75746. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75747. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  75748. * @param name defines the name of the mesh to create
  75749. * @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
  75750. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  75751. * @param scale is the value to scale the shape
  75752. * @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
  75753. * @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
  75754. * @param scene defines the hosting scene
  75755. * @param updatable defines if the mesh must be flagged as updatable
  75756. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75757. * @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)
  75758. * @returns a new Mesh
  75759. */
  75760. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75761. /**
  75762. * Creates an custom extruded shape mesh.
  75763. * The custom extrusion is a parametric shape.
  75764. * It has no predefined shape. Its final shape will depend on the input parameters.
  75765. * Please consider using the same method from the MeshBuilder class instead
  75766. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  75767. * @param name defines the name of the mesh to create
  75768. * @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
  75769. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  75770. * @param scaleFunction is a custom Javascript function called on each path point
  75771. * @param rotationFunction is a custom Javascript function called on each path point
  75772. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  75773. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  75774. * @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
  75775. * @param scene defines the hosting scene
  75776. * @param updatable defines if the mesh must be flagged as updatable
  75777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75778. * @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)
  75779. * @returns a new Mesh
  75780. */
  75781. 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;
  75782. /**
  75783. * Creates lathe mesh.
  75784. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  75785. * Please consider using the same method from the MeshBuilder class instead
  75786. * @param name defines the name of the mesh to create
  75787. * @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
  75788. * @param radius is the radius value of the lathe
  75789. * @param tessellation is the side number of the lathe.
  75790. * @param scene defines the hosting scene
  75791. * @param updatable defines if the mesh must be flagged as updatable
  75792. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75793. * @returns a new Mesh
  75794. */
  75795. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75796. /**
  75797. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  75798. * @param name defines the name of the mesh to create
  75799. * @param size sets the size (float) of both sides of the plane at once (default 1)
  75800. * @param scene defines the hosting scene
  75801. * @param updatable defines if the mesh must be flagged as updatable
  75802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75803. * @returns a new Mesh
  75804. */
  75805. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75806. /**
  75807. * Creates a ground mesh.
  75808. * Please consider using the same method from the MeshBuilder class instead
  75809. * @param name defines the name of the mesh to create
  75810. * @param width set the width of the ground
  75811. * @param height set the height of the ground
  75812. * @param subdivisions sets the number of subdivisions per side
  75813. * @param scene defines the hosting scene
  75814. * @param updatable defines if the mesh must be flagged as updatable
  75815. * @returns a new Mesh
  75816. */
  75817. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  75818. /**
  75819. * Creates a tiled ground mesh.
  75820. * Please consider using the same method from the MeshBuilder class instead
  75821. * @param name defines the name of the mesh to create
  75822. * @param xmin set the ground minimum X coordinate
  75823. * @param zmin set the ground minimum Y coordinate
  75824. * @param xmax set the ground maximum X coordinate
  75825. * @param zmax set the ground maximum Z coordinate
  75826. * @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
  75827. * @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
  75828. * @param scene defines the hosting scene
  75829. * @param updatable defines if the mesh must be flagged as updatable
  75830. * @returns a new Mesh
  75831. */
  75832. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  75833. w: number;
  75834. h: number;
  75835. }, precision: {
  75836. w: number;
  75837. h: number;
  75838. }, scene: Scene, updatable?: boolean): Mesh;
  75839. /**
  75840. * Creates a ground mesh from a height map.
  75841. * Please consider using the same method from the MeshBuilder class instead
  75842. * @see http://doc.babylonjs.com/babylon101/height_map
  75843. * @param name defines the name of the mesh to create
  75844. * @param url sets the URL of the height map image resource
  75845. * @param width set the ground width size
  75846. * @param height set the ground height size
  75847. * @param subdivisions sets the number of subdivision per side
  75848. * @param minHeight is the minimum altitude on the ground
  75849. * @param maxHeight is the maximum altitude on the ground
  75850. * @param scene defines the hosting scene
  75851. * @param updatable defines if the mesh must be flagged as updatable
  75852. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  75853. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75854. * @returns a new Mesh
  75855. */
  75856. 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;
  75857. /**
  75858. * Creates a tube mesh.
  75859. * The tube is a parametric shape.
  75860. * It has no predefined shape. Its final shape will depend on the input parameters.
  75861. * Please consider using the same method from the MeshBuilder class instead
  75862. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75863. * @param name defines the name of the mesh to create
  75864. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  75865. * @param radius sets the tube radius size
  75866. * @param tessellation is the number of sides on the tubular surface
  75867. * @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
  75868. * @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
  75869. * @param scene defines the hosting scene
  75870. * @param updatable defines if the mesh must be flagged as updatable
  75871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75872. * @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)
  75873. * @returns a new Mesh
  75874. */
  75875. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  75876. (i: number, distance: number): number;
  75877. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75878. /**
  75879. * Creates a polyhedron mesh.
  75880. * Please consider using the same method from the MeshBuilder class instead.
  75881. * * 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
  75882. * * The parameter `size` (positive float, default 1) sets the polygon size
  75883. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  75884. * * 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`
  75885. * * 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
  75886. * * 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)`)
  75887. * * 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
  75888. * * 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
  75889. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75890. * * If you create a double-sided mesh, you can choose what parts of 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
  75891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75892. * @param name defines the name of the mesh to create
  75893. * @param options defines the options used to create the mesh
  75894. * @param scene defines the hosting scene
  75895. * @returns a new Mesh
  75896. */
  75897. static CreatePolyhedron(name: string, options: {
  75898. type?: number;
  75899. size?: number;
  75900. sizeX?: number;
  75901. sizeY?: number;
  75902. sizeZ?: number;
  75903. custom?: any;
  75904. faceUV?: Vector4[];
  75905. faceColors?: Color4[];
  75906. updatable?: boolean;
  75907. sideOrientation?: number;
  75908. }, scene: Scene): Mesh;
  75909. /**
  75910. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  75911. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  75912. * * 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`)
  75913. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  75914. * * 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
  75915. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75916. * * If you create a double-sided mesh, you can choose what parts of 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
  75917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75918. * @param name defines the name of the mesh
  75919. * @param options defines the options used to create the mesh
  75920. * @param scene defines the hosting scene
  75921. * @returns a new Mesh
  75922. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  75923. */
  75924. static CreateIcoSphere(name: string, options: {
  75925. radius?: number;
  75926. flat?: boolean;
  75927. subdivisions?: number;
  75928. sideOrientation?: number;
  75929. updatable?: boolean;
  75930. }, scene: Scene): Mesh;
  75931. /**
  75932. * Creates a decal mesh.
  75933. * Please consider using the same method from the MeshBuilder class instead.
  75934. * A decal is a mesh usually applied as a model onto the surface of another mesh
  75935. * @param name defines the name of the mesh
  75936. * @param sourceMesh defines the mesh receiving the decal
  75937. * @param position sets the position of the decal in world coordinates
  75938. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  75939. * @param size sets the decal scaling
  75940. * @param angle sets the angle to rotate the decal
  75941. * @returns a new Mesh
  75942. */
  75943. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  75944. /**
  75945. * Prepare internal position array for software CPU skinning
  75946. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  75947. */
  75948. setPositionsForCPUSkinning(): Float32Array;
  75949. /**
  75950. * Prepare internal normal array for software CPU skinning
  75951. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  75952. */
  75953. setNormalsForCPUSkinning(): Float32Array;
  75954. /**
  75955. * Updates the vertex buffer by applying transformation from the bones
  75956. * @param skeleton defines the skeleton to apply to current mesh
  75957. * @returns the current mesh
  75958. */
  75959. applySkeleton(skeleton: Skeleton): Mesh;
  75960. /**
  75961. * 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
  75962. * @param meshes defines the list of meshes to scan
  75963. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  75964. */
  75965. static MinMax(meshes: AbstractMesh[]): {
  75966. min: Vector3;
  75967. max: Vector3;
  75968. };
  75969. /**
  75970. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  75971. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  75972. * @returns a vector3
  75973. */
  75974. static Center(meshesOrMinMaxVector: {
  75975. min: Vector3;
  75976. max: Vector3;
  75977. } | AbstractMesh[]): Vector3;
  75978. /**
  75979. * Merge the array of meshes into a single mesh for performance reasons.
  75980. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  75981. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  75982. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  75983. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  75984. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  75985. * @returns a new mesh
  75986. */
  75987. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  75988. /** @hidden */
  75989. addInstance(instance: InstancedMesh): void;
  75990. /** @hidden */
  75991. removeInstance(instance: InstancedMesh): void;
  75992. }
  75993. }
  75994. declare module BABYLON {
  75995. /**
  75996. * The action to be carried out following a trigger
  75997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75998. */
  75999. export class Action {
  76000. /** the trigger, with or without parameters, for the action */
  76001. triggerOptions: any;
  76002. /**
  76003. * Trigger for the action
  76004. */
  76005. trigger: number;
  76006. /**
  76007. * Internal only - manager for action
  76008. * @hidden
  76009. */
  76010. _actionManager: ActionManager;
  76011. private _nextActiveAction;
  76012. private _child;
  76013. private _condition?;
  76014. private _triggerParameter;
  76015. /**
  76016. * An event triggered prior to action being executed.
  76017. */
  76018. onBeforeExecuteObservable: Observable<Action>;
  76019. /**
  76020. * Creates a new Action
  76021. * @param triggerOptions the trigger, with or without parameters, for the action
  76022. * @param condition an optional determinant of action
  76023. */
  76024. constructor(
  76025. /** the trigger, with or without parameters, for the action */
  76026. triggerOptions: any, condition?: Condition);
  76027. /**
  76028. * Internal only
  76029. * @hidden
  76030. */
  76031. _prepare(): void;
  76032. /**
  76033. * Gets the trigger parameters
  76034. * @returns the trigger parameters
  76035. */
  76036. getTriggerParameter(): any;
  76037. /**
  76038. * Internal only - executes current action event
  76039. * @hidden
  76040. */
  76041. _executeCurrent(evt?: ActionEvent): void;
  76042. /**
  76043. * Execute placeholder for child classes
  76044. * @param evt optional action event
  76045. */
  76046. execute(evt?: ActionEvent): void;
  76047. /**
  76048. * Skips to next active action
  76049. */
  76050. skipToNextActiveAction(): void;
  76051. /**
  76052. * Adds action to chain of actions, may be a DoNothingAction
  76053. * @param action defines the next action to execute
  76054. * @returns The action passed in
  76055. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76056. */
  76057. then(action: Action): Action;
  76058. /**
  76059. * Internal only
  76060. * @hidden
  76061. */
  76062. _getProperty(propertyPath: string): string;
  76063. /**
  76064. * Internal only
  76065. * @hidden
  76066. */
  76067. _getEffectiveTarget(target: any, propertyPath: string): any;
  76068. /**
  76069. * Serialize placeholder for child classes
  76070. * @param parent of child
  76071. * @returns the serialized object
  76072. */
  76073. serialize(parent: any): any;
  76074. /**
  76075. * Internal only called by serialize
  76076. * @hidden
  76077. */
  76078. protected _serialize(serializedAction: any, parent?: any): any;
  76079. /**
  76080. * Internal only
  76081. * @hidden
  76082. */
  76083. static _SerializeValueAsString: (value: any) => string;
  76084. /**
  76085. * Internal only
  76086. * @hidden
  76087. */
  76088. static _GetTargetProperty: (target: Scene | Node) => {
  76089. name: string;
  76090. targetType: string;
  76091. value: string;
  76092. };
  76093. }
  76094. }
  76095. declare module BABYLON {
  76096. /**
  76097. * A Condition applied to an Action
  76098. */
  76099. export class Condition {
  76100. /**
  76101. * Internal only - manager for action
  76102. * @hidden
  76103. */
  76104. _actionManager: ActionManager;
  76105. /**
  76106. * Internal only
  76107. * @hidden
  76108. */
  76109. _evaluationId: number;
  76110. /**
  76111. * Internal only
  76112. * @hidden
  76113. */
  76114. _currentResult: boolean;
  76115. /**
  76116. * Creates a new Condition
  76117. * @param actionManager the manager of the action the condition is applied to
  76118. */
  76119. constructor(actionManager: ActionManager);
  76120. /**
  76121. * Check if the current condition is valid
  76122. * @returns a boolean
  76123. */
  76124. isValid(): boolean;
  76125. /**
  76126. * Internal only
  76127. * @hidden
  76128. */
  76129. _getProperty(propertyPath: string): string;
  76130. /**
  76131. * Internal only
  76132. * @hidden
  76133. */
  76134. _getEffectiveTarget(target: any, propertyPath: string): any;
  76135. /**
  76136. * Serialize placeholder for child classes
  76137. * @returns the serialized object
  76138. */
  76139. serialize(): any;
  76140. /**
  76141. * Internal only
  76142. * @hidden
  76143. */
  76144. protected _serialize(serializedCondition: any): any;
  76145. }
  76146. /**
  76147. * Defines specific conditional operators as extensions of Condition
  76148. */
  76149. export class ValueCondition extends Condition {
  76150. /** path to specify the property of the target the conditional operator uses */
  76151. propertyPath: string;
  76152. /** the value compared by the conditional operator against the current value of the property */
  76153. value: any;
  76154. /** the conditional operator, default ValueCondition.IsEqual */
  76155. operator: number;
  76156. /**
  76157. * Internal only
  76158. * @hidden
  76159. */
  76160. private static _IsEqual;
  76161. /**
  76162. * Internal only
  76163. * @hidden
  76164. */
  76165. private static _IsDifferent;
  76166. /**
  76167. * Internal only
  76168. * @hidden
  76169. */
  76170. private static _IsGreater;
  76171. /**
  76172. * Internal only
  76173. * @hidden
  76174. */
  76175. private static _IsLesser;
  76176. /**
  76177. * returns the number for IsEqual
  76178. */
  76179. static readonly IsEqual: number;
  76180. /**
  76181. * Returns the number for IsDifferent
  76182. */
  76183. static readonly IsDifferent: number;
  76184. /**
  76185. * Returns the number for IsGreater
  76186. */
  76187. static readonly IsGreater: number;
  76188. /**
  76189. * Returns the number for IsLesser
  76190. */
  76191. static readonly IsLesser: number;
  76192. /**
  76193. * Internal only The action manager for the condition
  76194. * @hidden
  76195. */
  76196. _actionManager: ActionManager;
  76197. /**
  76198. * Internal only
  76199. * @hidden
  76200. */
  76201. private _target;
  76202. /**
  76203. * Internal only
  76204. * @hidden
  76205. */
  76206. private _effectiveTarget;
  76207. /**
  76208. * Internal only
  76209. * @hidden
  76210. */
  76211. private _property;
  76212. /**
  76213. * Creates a new ValueCondition
  76214. * @param actionManager manager for the action the condition applies to
  76215. * @param target for the action
  76216. * @param propertyPath path to specify the property of the target the conditional operator uses
  76217. * @param value the value compared by the conditional operator against the current value of the property
  76218. * @param operator the conditional operator, default ValueCondition.IsEqual
  76219. */
  76220. constructor(actionManager: ActionManager, target: any,
  76221. /** path to specify the property of the target the conditional operator uses */
  76222. propertyPath: string,
  76223. /** the value compared by the conditional operator against the current value of the property */
  76224. value: any,
  76225. /** the conditional operator, default ValueCondition.IsEqual */
  76226. operator?: number);
  76227. /**
  76228. * Compares the given value with the property value for the specified conditional operator
  76229. * @returns the result of the comparison
  76230. */
  76231. isValid(): boolean;
  76232. /**
  76233. * Serialize the ValueCondition into a JSON compatible object
  76234. * @returns serialization object
  76235. */
  76236. serialize(): any;
  76237. /**
  76238. * Gets the name of the conditional operator for the ValueCondition
  76239. * @param operator the conditional operator
  76240. * @returns the name
  76241. */
  76242. static GetOperatorName(operator: number): string;
  76243. }
  76244. /**
  76245. * Defines a predicate condition as an extension of Condition
  76246. */
  76247. export class PredicateCondition extends Condition {
  76248. /** defines the predicate function used to validate the condition */
  76249. predicate: () => boolean;
  76250. /**
  76251. * Internal only - manager for action
  76252. * @hidden
  76253. */
  76254. _actionManager: ActionManager;
  76255. /**
  76256. * Creates a new PredicateCondition
  76257. * @param actionManager manager for the action the condition applies to
  76258. * @param predicate defines the predicate function used to validate the condition
  76259. */
  76260. constructor(actionManager: ActionManager,
  76261. /** defines the predicate function used to validate the condition */
  76262. predicate: () => boolean);
  76263. /**
  76264. * @returns the validity of the predicate condition
  76265. */
  76266. isValid(): boolean;
  76267. }
  76268. /**
  76269. * Defines a state condition as an extension of Condition
  76270. */
  76271. export class StateCondition extends Condition {
  76272. /** Value to compare with target state */
  76273. value: string;
  76274. /**
  76275. * Internal only - manager for action
  76276. * @hidden
  76277. */
  76278. _actionManager: ActionManager;
  76279. /**
  76280. * Internal only
  76281. * @hidden
  76282. */
  76283. private _target;
  76284. /**
  76285. * Creates a new StateCondition
  76286. * @param actionManager manager for the action the condition applies to
  76287. * @param target of the condition
  76288. * @param value to compare with target state
  76289. */
  76290. constructor(actionManager: ActionManager, target: any,
  76291. /** Value to compare with target state */
  76292. value: string);
  76293. /**
  76294. * Gets a boolean indicating if the current condition is met
  76295. * @returns the validity of the state
  76296. */
  76297. isValid(): boolean;
  76298. /**
  76299. * Serialize the StateCondition into a JSON compatible object
  76300. * @returns serialization object
  76301. */
  76302. serialize(): any;
  76303. }
  76304. }
  76305. declare module BABYLON {
  76306. /**
  76307. * This defines an action responsible to toggle a boolean once triggered.
  76308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76309. */
  76310. export class SwitchBooleanAction extends Action {
  76311. /**
  76312. * The path to the boolean property in the target object
  76313. */
  76314. propertyPath: string;
  76315. private _target;
  76316. private _effectiveTarget;
  76317. private _property;
  76318. /**
  76319. * Instantiate the action
  76320. * @param triggerOptions defines the trigger options
  76321. * @param target defines the object containing the boolean
  76322. * @param propertyPath defines the path to the boolean property in the target object
  76323. * @param condition defines the trigger related conditions
  76324. */
  76325. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76326. /** @hidden */
  76327. _prepare(): void;
  76328. /**
  76329. * Execute the action toggle the boolean value.
  76330. */
  76331. execute(): void;
  76332. /**
  76333. * Serializes the actions and its related information.
  76334. * @param parent defines the object to serialize in
  76335. * @returns the serialized object
  76336. */
  76337. serialize(parent: any): any;
  76338. }
  76339. /**
  76340. * This defines an action responsible to set a the state field of the target
  76341. * to a desired value once triggered.
  76342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76343. */
  76344. export class SetStateAction extends Action {
  76345. /**
  76346. * The value to store in the state field.
  76347. */
  76348. value: string;
  76349. private _target;
  76350. /**
  76351. * Instantiate the action
  76352. * @param triggerOptions defines the trigger options
  76353. * @param target defines the object containing the state property
  76354. * @param value defines the value to store in the state field
  76355. * @param condition defines the trigger related conditions
  76356. */
  76357. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76358. /**
  76359. * Execute the action and store the value on the target state property.
  76360. */
  76361. execute(): void;
  76362. /**
  76363. * Serializes the actions and its related information.
  76364. * @param parent defines the object to serialize in
  76365. * @returns the serialized object
  76366. */
  76367. serialize(parent: any): any;
  76368. }
  76369. /**
  76370. * This defines an action responsible to set a property of the target
  76371. * to a desired value once triggered.
  76372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76373. */
  76374. export class SetValueAction extends Action {
  76375. /**
  76376. * The path of the property to set in the target.
  76377. */
  76378. propertyPath: string;
  76379. /**
  76380. * The value to set in the property
  76381. */
  76382. value: any;
  76383. private _target;
  76384. private _effectiveTarget;
  76385. private _property;
  76386. /**
  76387. * Instantiate the action
  76388. * @param triggerOptions defines the trigger options
  76389. * @param target defines the object containing the property
  76390. * @param propertyPath defines the path of the property to set in the target
  76391. * @param value defines the value to set in the property
  76392. * @param condition defines the trigger related conditions
  76393. */
  76394. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76395. /** @hidden */
  76396. _prepare(): void;
  76397. /**
  76398. * Execute the action and set the targetted property to the desired value.
  76399. */
  76400. execute(): void;
  76401. /**
  76402. * Serializes the actions and its related information.
  76403. * @param parent defines the object to serialize in
  76404. * @returns the serialized object
  76405. */
  76406. serialize(parent: any): any;
  76407. }
  76408. /**
  76409. * This defines an action responsible to increment the target value
  76410. * to a desired value once triggered.
  76411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76412. */
  76413. export class IncrementValueAction extends Action {
  76414. /**
  76415. * The path of the property to increment in the target.
  76416. */
  76417. propertyPath: string;
  76418. /**
  76419. * The value we should increment the property by.
  76420. */
  76421. value: any;
  76422. private _target;
  76423. private _effectiveTarget;
  76424. private _property;
  76425. /**
  76426. * Instantiate the action
  76427. * @param triggerOptions defines the trigger options
  76428. * @param target defines the object containing the property
  76429. * @param propertyPath defines the path of the property to increment in the target
  76430. * @param value defines the value value we should increment the property by
  76431. * @param condition defines the trigger related conditions
  76432. */
  76433. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76434. /** @hidden */
  76435. _prepare(): void;
  76436. /**
  76437. * Execute the action and increment the target of the value amount.
  76438. */
  76439. execute(): void;
  76440. /**
  76441. * Serializes the actions and its related information.
  76442. * @param parent defines the object to serialize in
  76443. * @returns the serialized object
  76444. */
  76445. serialize(parent: any): any;
  76446. }
  76447. /**
  76448. * This defines an action responsible to start an animation once triggered.
  76449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76450. */
  76451. export class PlayAnimationAction extends Action {
  76452. /**
  76453. * Where the animation should start (animation frame)
  76454. */
  76455. from: number;
  76456. /**
  76457. * Where the animation should stop (animation frame)
  76458. */
  76459. to: number;
  76460. /**
  76461. * Define if the animation should loop or stop after the first play.
  76462. */
  76463. loop?: boolean;
  76464. private _target;
  76465. /**
  76466. * Instantiate the action
  76467. * @param triggerOptions defines the trigger options
  76468. * @param target defines the target animation or animation name
  76469. * @param from defines from where the animation should start (animation frame)
  76470. * @param end defines where the animation should stop (animation frame)
  76471. * @param loop defines if the animation should loop or stop after the first play
  76472. * @param condition defines the trigger related conditions
  76473. */
  76474. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76475. /** @hidden */
  76476. _prepare(): void;
  76477. /**
  76478. * Execute the action and play the animation.
  76479. */
  76480. execute(): void;
  76481. /**
  76482. * Serializes the actions and its related information.
  76483. * @param parent defines the object to serialize in
  76484. * @returns the serialized object
  76485. */
  76486. serialize(parent: any): any;
  76487. }
  76488. /**
  76489. * This defines an action responsible to stop an animation once triggered.
  76490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76491. */
  76492. export class StopAnimationAction extends Action {
  76493. private _target;
  76494. /**
  76495. * Instantiate the action
  76496. * @param triggerOptions defines the trigger options
  76497. * @param target defines the target animation or animation name
  76498. * @param condition defines the trigger related conditions
  76499. */
  76500. constructor(triggerOptions: any, target: any, condition?: Condition);
  76501. /** @hidden */
  76502. _prepare(): void;
  76503. /**
  76504. * Execute the action and stop the animation.
  76505. */
  76506. execute(): void;
  76507. /**
  76508. * Serializes the actions and its related information.
  76509. * @param parent defines the object to serialize in
  76510. * @returns the serialized object
  76511. */
  76512. serialize(parent: any): any;
  76513. }
  76514. /**
  76515. * This defines an action responsible that does nothing once triggered.
  76516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76517. */
  76518. export class DoNothingAction extends Action {
  76519. /**
  76520. * Instantiate the action
  76521. * @param triggerOptions defines the trigger options
  76522. * @param condition defines the trigger related conditions
  76523. */
  76524. constructor(triggerOptions?: any, condition?: Condition);
  76525. /**
  76526. * Execute the action and do nothing.
  76527. */
  76528. execute(): void;
  76529. /**
  76530. * Serializes the actions and its related information.
  76531. * @param parent defines the object to serialize in
  76532. * @returns the serialized object
  76533. */
  76534. serialize(parent: any): any;
  76535. }
  76536. /**
  76537. * This defines an action responsible to trigger several actions once triggered.
  76538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76539. */
  76540. export class CombineAction extends Action {
  76541. /**
  76542. * The list of aggregated animations to run.
  76543. */
  76544. children: Action[];
  76545. /**
  76546. * Instantiate the action
  76547. * @param triggerOptions defines the trigger options
  76548. * @param children defines the list of aggregated animations to run
  76549. * @param condition defines the trigger related conditions
  76550. */
  76551. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76552. /** @hidden */
  76553. _prepare(): void;
  76554. /**
  76555. * Execute the action and executes all the aggregated actions.
  76556. */
  76557. execute(evt: ActionEvent): void;
  76558. /**
  76559. * Serializes the actions and its related information.
  76560. * @param parent defines the object to serialize in
  76561. * @returns the serialized object
  76562. */
  76563. serialize(parent: any): any;
  76564. }
  76565. /**
  76566. * This defines an action responsible to run code (external event) once triggered.
  76567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76568. */
  76569. export class ExecuteCodeAction extends Action {
  76570. /**
  76571. * The callback function to run.
  76572. */
  76573. func: (evt: ActionEvent) => void;
  76574. /**
  76575. * Instantiate the action
  76576. * @param triggerOptions defines the trigger options
  76577. * @param func defines the callback function to run
  76578. * @param condition defines the trigger related conditions
  76579. */
  76580. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76581. /**
  76582. * Execute the action and run the attached code.
  76583. */
  76584. execute(evt: ActionEvent): void;
  76585. }
  76586. /**
  76587. * This defines an action responsible to set the parent property of the target once triggered.
  76588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76589. */
  76590. export class SetParentAction extends Action {
  76591. private _parent;
  76592. private _target;
  76593. /**
  76594. * Instantiate the action
  76595. * @param triggerOptions defines the trigger options
  76596. * @param target defines the target containing the parent property
  76597. * @param parent defines from where the animation should start (animation frame)
  76598. * @param condition defines the trigger related conditions
  76599. */
  76600. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76601. /** @hidden */
  76602. _prepare(): void;
  76603. /**
  76604. * Execute the action and set the parent property.
  76605. */
  76606. execute(): void;
  76607. /**
  76608. * Serializes the actions and its related information.
  76609. * @param parent defines the object to serialize in
  76610. * @returns the serialized object
  76611. */
  76612. serialize(parent: any): any;
  76613. }
  76614. }
  76615. declare module BABYLON {
  76616. /**
  76617. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76618. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76620. */
  76621. export class ActionManager {
  76622. /**
  76623. * Nothing
  76624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76625. */
  76626. static readonly NothingTrigger: number;
  76627. /**
  76628. * On pick
  76629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76630. */
  76631. static readonly OnPickTrigger: number;
  76632. /**
  76633. * On left pick
  76634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76635. */
  76636. static readonly OnLeftPickTrigger: number;
  76637. /**
  76638. * On right pick
  76639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76640. */
  76641. static readonly OnRightPickTrigger: number;
  76642. /**
  76643. * On center pick
  76644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76645. */
  76646. static readonly OnCenterPickTrigger: number;
  76647. /**
  76648. * On pick down
  76649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76650. */
  76651. static readonly OnPickDownTrigger: number;
  76652. /**
  76653. * On double pick
  76654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76655. */
  76656. static readonly OnDoublePickTrigger: number;
  76657. /**
  76658. * On pick up
  76659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76660. */
  76661. static readonly OnPickUpTrigger: number;
  76662. /**
  76663. * On pick out.
  76664. * This trigger will only be raised if you also declared a OnPickDown
  76665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76666. */
  76667. static readonly OnPickOutTrigger: number;
  76668. /**
  76669. * On long press
  76670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76671. */
  76672. static readonly OnLongPressTrigger: number;
  76673. /**
  76674. * On pointer over
  76675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76676. */
  76677. static readonly OnPointerOverTrigger: number;
  76678. /**
  76679. * On pointer out
  76680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76681. */
  76682. static readonly OnPointerOutTrigger: number;
  76683. /**
  76684. * On every frame
  76685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76686. */
  76687. static readonly OnEveryFrameTrigger: number;
  76688. /**
  76689. * On intersection enter
  76690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76691. */
  76692. static readonly OnIntersectionEnterTrigger: number;
  76693. /**
  76694. * On intersection exit
  76695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76696. */
  76697. static readonly OnIntersectionExitTrigger: number;
  76698. /**
  76699. * On key down
  76700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76701. */
  76702. static readonly OnKeyDownTrigger: number;
  76703. /**
  76704. * On key up
  76705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76706. */
  76707. static readonly OnKeyUpTrigger: number;
  76708. /** Gets the list of active triggers */
  76709. static Triggers: {
  76710. [key: string]: number;
  76711. };
  76712. /** Gets the list of actions */
  76713. actions: Action[];
  76714. /** Gets the cursor to use when hovering items */
  76715. hoverCursor: string;
  76716. private _scene;
  76717. /**
  76718. * Creates a new action manager
  76719. * @param scene defines the hosting scene
  76720. */
  76721. constructor(scene: Scene);
  76722. /**
  76723. * Releases all associated resources
  76724. */
  76725. dispose(): void;
  76726. /**
  76727. * Gets hosting scene
  76728. * @returns the hosting scene
  76729. */
  76730. getScene(): Scene;
  76731. /**
  76732. * Does this action manager handles actions of any of the given triggers
  76733. * @param triggers defines the triggers to be tested
  76734. * @return a boolean indicating whether one (or more) of the triggers is handled
  76735. */
  76736. hasSpecificTriggers(triggers: number[]): boolean;
  76737. /**
  76738. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76739. * speed.
  76740. * @param triggerA defines the trigger to be tested
  76741. * @param triggerB defines the trigger to be tested
  76742. * @return a boolean indicating whether one (or more) of the triggers is handled
  76743. */
  76744. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76745. /**
  76746. * Does this action manager handles actions of a given trigger
  76747. * @param trigger defines the trigger to be tested
  76748. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76749. * @return whether the trigger is handled
  76750. */
  76751. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76752. /**
  76753. * Does this action manager has pointer triggers
  76754. */
  76755. readonly hasPointerTriggers: boolean;
  76756. /**
  76757. * Does this action manager has pick triggers
  76758. */
  76759. readonly hasPickTriggers: boolean;
  76760. /**
  76761. * Does exist one action manager with at least one trigger
  76762. **/
  76763. static readonly HasTriggers: boolean;
  76764. /**
  76765. * Does exist one action manager with at least one pick trigger
  76766. **/
  76767. static readonly HasPickTriggers: boolean;
  76768. /**
  76769. * Does exist one action manager that handles actions of a given trigger
  76770. * @param trigger defines the trigger to be tested
  76771. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  76772. **/
  76773. static HasSpecificTrigger(trigger: number): boolean;
  76774. /**
  76775. * Registers an action to this action manager
  76776. * @param action defines the action to be registered
  76777. * @return the action amended (prepared) after registration
  76778. */
  76779. registerAction(action: Action): Nullable<Action>;
  76780. /**
  76781. * Unregisters an action to this action manager
  76782. * @param action defines the action to be unregistered
  76783. * @return a boolean indicating whether the action has been unregistered
  76784. */
  76785. unregisterAction(action: Action): Boolean;
  76786. /**
  76787. * Process a specific trigger
  76788. * @param trigger defines the trigger to process
  76789. * @param evt defines the event details to be processed
  76790. */
  76791. processTrigger(trigger: number, evt?: ActionEvent): void;
  76792. /** @hidden */
  76793. _getEffectiveTarget(target: any, propertyPath: string): any;
  76794. /** @hidden */
  76795. _getProperty(propertyPath: string): string;
  76796. /**
  76797. * Serialize this manager to a JSON object
  76798. * @param name defines the property name to store this manager
  76799. * @returns a JSON representation of this manager
  76800. */
  76801. serialize(name: string): any;
  76802. /**
  76803. * Creates a new ActionManager from a JSON data
  76804. * @param parsedActions defines the JSON data to read from
  76805. * @param object defines the hosting mesh
  76806. * @param scene defines the hosting scene
  76807. */
  76808. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76809. /**
  76810. * Get a trigger name by index
  76811. * @param trigger defines the trigger index
  76812. * @returns a trigger name
  76813. */
  76814. static GetTriggerName(trigger: number): string;
  76815. }
  76816. }
  76817. declare module BABYLON {
  76818. /**
  76819. * Class used to represent a sprite
  76820. * @see http://doc.babylonjs.com/babylon101/sprites
  76821. */
  76822. export class Sprite {
  76823. /** defines the name */
  76824. name: string;
  76825. /** Gets or sets the current world position */
  76826. position: Vector3;
  76827. /** Gets or sets the main color */
  76828. color: Color4;
  76829. /** Gets or sets the width */
  76830. width: number;
  76831. /** Gets or sets the height */
  76832. height: number;
  76833. /** Gets or sets rotation angle */
  76834. angle: number;
  76835. /** Gets or sets the cell index in the sprite sheet */
  76836. cellIndex: number;
  76837. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76838. invertU: number;
  76839. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76840. invertV: number;
  76841. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76842. disposeWhenFinishedAnimating: boolean;
  76843. /** Gets the list of attached animations */
  76844. animations: Animation[];
  76845. /** Gets or sets a boolean indicating if the sprite can be picked */
  76846. isPickable: boolean;
  76847. /**
  76848. * Gets or sets the associated action manager
  76849. */
  76850. actionManager: Nullable<ActionManager>;
  76851. private _animationStarted;
  76852. private _loopAnimation;
  76853. private _fromIndex;
  76854. private _toIndex;
  76855. private _delay;
  76856. private _direction;
  76857. private _manager;
  76858. private _time;
  76859. private _onAnimationEnd;
  76860. /**
  76861. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76862. */
  76863. isVisible: boolean;
  76864. /**
  76865. * Gets or sets the sprite size
  76866. */
  76867. size: number;
  76868. /**
  76869. * Creates a new Sprite
  76870. * @param name defines the name
  76871. * @param manager defines the manager
  76872. */
  76873. constructor(
  76874. /** defines the name */
  76875. name: string, manager: ISpriteManager);
  76876. /**
  76877. * Starts an animation
  76878. * @param from defines the initial key
  76879. * @param to defines the end key
  76880. * @param loop defines if the animation must loop
  76881. * @param delay defines the start delay (in ms)
  76882. * @param onAnimationEnd defines a callback to call when animation ends
  76883. */
  76884. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76885. /** Stops current animation (if any) */
  76886. stopAnimation(): void;
  76887. /** @hidden */
  76888. _animate(deltaTime: number): void;
  76889. /** Release associated resources */
  76890. dispose(): void;
  76891. }
  76892. }
  76893. declare module BABYLON {
  76894. /**
  76895. * Information about the result of picking within a scene
  76896. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76897. */
  76898. export class PickingInfo {
  76899. /**
  76900. * If the pick collided with an object
  76901. */
  76902. hit: boolean;
  76903. /**
  76904. * Distance away where the pick collided
  76905. */
  76906. distance: number;
  76907. /**
  76908. * The location of pick collision
  76909. */
  76910. pickedPoint: Nullable<Vector3>;
  76911. /**
  76912. * The mesh corresponding the the pick collision
  76913. */
  76914. pickedMesh: Nullable<AbstractMesh>;
  76915. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  76916. bu: number;
  76917. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  76918. bv: number;
  76919. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76920. faceId: number;
  76921. /** Id of the the submesh that was picked */
  76922. subMeshId: number;
  76923. /** If a sprite was picked, this will be the sprite the pick collided with */
  76924. pickedSprite: Nullable<Sprite>;
  76925. /**
  76926. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76927. */
  76928. originMesh: Nullable<AbstractMesh>;
  76929. /**
  76930. * The ray that was used to perform the picking.
  76931. */
  76932. ray: Nullable<Ray>;
  76933. /**
  76934. * Gets the normal correspodning to the face the pick collided with
  76935. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76936. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76937. * @returns The normal correspodning to the face the pick collided with
  76938. */
  76939. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76940. /**
  76941. * Gets the texture coordinates of where the pick occured
  76942. * @returns the vector containing the coordnates of the texture
  76943. */
  76944. getTextureCoordinates(): Nullable<Vector2>;
  76945. }
  76946. }
  76947. declare module BABYLON {
  76948. /**
  76949. * Class representing a ray with position and direction
  76950. */
  76951. export class Ray {
  76952. /** origin point */
  76953. origin: Vector3;
  76954. /** direction */
  76955. direction: Vector3;
  76956. /** length of the ray */
  76957. length: number;
  76958. private static readonly TmpVector3;
  76959. private _tmpRay;
  76960. /**
  76961. * Creates a new ray
  76962. * @param origin origin point
  76963. * @param direction direction
  76964. * @param length length of the ray
  76965. */
  76966. constructor(
  76967. /** origin point */
  76968. origin: Vector3,
  76969. /** direction */
  76970. direction: Vector3,
  76971. /** length of the ray */
  76972. length?: number);
  76973. /**
  76974. * Checks if the ray intersects a box
  76975. * @param minimum bound of the box
  76976. * @param maximum bound of the box
  76977. * @param intersectionTreshold extra extend to be added to the box in all direction
  76978. * @returns if the box was hit
  76979. */
  76980. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76981. /**
  76982. * Checks if the ray intersects a box
  76983. * @param box the bounding box to check
  76984. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76985. * @returns if the box was hit
  76986. */
  76987. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76988. /**
  76989. * If the ray hits a sphere
  76990. * @param sphere the bounding sphere to check
  76991. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76992. * @returns true if it hits the sphere
  76993. */
  76994. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76995. /**
  76996. * If the ray hits a triange
  76997. * @param vertex0 triangle vertex
  76998. * @param vertex1 triangle vertex
  76999. * @param vertex2 triangle vertex
  77000. * @returns intersection information if hit
  77001. */
  77002. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77003. /**
  77004. * Checks if ray intersects a plane
  77005. * @param plane the plane to check
  77006. * @returns the distance away it was hit
  77007. */
  77008. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77009. /**
  77010. * Checks if ray intersects a mesh
  77011. * @param mesh the mesh to check
  77012. * @param fastCheck if only the bounding box should checked
  77013. * @returns picking info of the intersecton
  77014. */
  77015. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77016. /**
  77017. * Checks if ray intersects a mesh
  77018. * @param meshes the meshes to check
  77019. * @param fastCheck if only the bounding box should checked
  77020. * @param results array to store result in
  77021. * @returns Array of picking infos
  77022. */
  77023. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77024. private _comparePickingInfo;
  77025. private static smallnum;
  77026. private static rayl;
  77027. /**
  77028. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77029. * @param sega the first point of the segment to test the intersection against
  77030. * @param segb the second point of the segment to test the intersection against
  77031. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77032. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77033. */
  77034. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77035. /**
  77036. * Update the ray from viewport position
  77037. * @param x position
  77038. * @param y y position
  77039. * @param viewportWidth viewport width
  77040. * @param viewportHeight viewport height
  77041. * @param world world matrix
  77042. * @param view view matrix
  77043. * @param projection projection matrix
  77044. * @returns this ray updated
  77045. */
  77046. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77047. /**
  77048. * Creates a ray with origin and direction of 0,0,0
  77049. * @returns the new ray
  77050. */
  77051. static Zero(): Ray;
  77052. /**
  77053. * Creates a new ray from screen space and viewport
  77054. * @param x position
  77055. * @param y y position
  77056. * @param viewportWidth viewport width
  77057. * @param viewportHeight viewport height
  77058. * @param world world matrix
  77059. * @param view view matrix
  77060. * @param projection projection matrix
  77061. * @returns new ray
  77062. */
  77063. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77064. /**
  77065. * 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
  77066. * transformed to the given world matrix.
  77067. * @param origin The origin point
  77068. * @param end The end point
  77069. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77070. * @returns the new ray
  77071. */
  77072. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77073. /**
  77074. * Transforms a ray by a matrix
  77075. * @param ray ray to transform
  77076. * @param matrix matrix to apply
  77077. * @returns the resulting new ray
  77078. */
  77079. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77080. /**
  77081. * Transforms a ray by a matrix
  77082. * @param ray ray to transform
  77083. * @param matrix matrix to apply
  77084. * @param result ray to store result in
  77085. */
  77086. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77087. /**
  77088. * Unproject a ray from screen space to object space
  77089. * @param sourceX defines the screen space x coordinate to use
  77090. * @param sourceY defines the screen space y coordinate to use
  77091. * @param viewportWidth defines the current width of the viewport
  77092. * @param viewportHeight defines the current height of the viewport
  77093. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77094. * @param view defines the view matrix to use
  77095. * @param projection defines the projection matrix to use
  77096. */
  77097. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77098. }
  77099. }
  77100. declare module BABYLON {
  77101. /**
  77102. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77103. * separate meshes. This can be use to improve performances.
  77104. * @see http://doc.babylonjs.com/how_to/multi_materials
  77105. */
  77106. export class MultiMaterial extends Material {
  77107. private _subMaterials;
  77108. /**
  77109. * Gets or Sets the list of Materials used within the multi material.
  77110. * They need to be ordered according to the submeshes order in the associated mesh
  77111. */
  77112. subMaterials: Nullable<Material>[];
  77113. /**
  77114. * Function used to align with Node.getChildren()
  77115. * @returns the list of Materials used within the multi material
  77116. */
  77117. getChildren(): Nullable<Material>[];
  77118. /**
  77119. * Instantiates a new Multi Material
  77120. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77121. * separate meshes. This can be use to improve performances.
  77122. * @see http://doc.babylonjs.com/how_to/multi_materials
  77123. * @param name Define the name in the scene
  77124. * @param scene Define the scene the material belongs to
  77125. */
  77126. constructor(name: string, scene: Scene);
  77127. private _hookArray;
  77128. /**
  77129. * Get one of the submaterial by its index in the submaterials array
  77130. * @param index The index to look the sub material at
  77131. * @returns The Material if the index has been defined
  77132. */
  77133. getSubMaterial(index: number): Nullable<Material>;
  77134. /**
  77135. * Get the list of active textures for the whole sub materials list.
  77136. * @returns All the textures that will be used during the rendering
  77137. */
  77138. getActiveTextures(): BaseTexture[];
  77139. /**
  77140. * Gets the current class name of the material e.g. "MultiMaterial"
  77141. * Mainly use in serialization.
  77142. * @returns the class name
  77143. */
  77144. getClassName(): string;
  77145. /**
  77146. * Checks if the material is ready to render the requested sub mesh
  77147. * @param mesh Define the mesh the submesh belongs to
  77148. * @param subMesh Define the sub mesh to look readyness for
  77149. * @param useInstances Define whether or not the material is used with instances
  77150. * @returns true if ready, otherwise false
  77151. */
  77152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77153. /**
  77154. * Clones the current material and its related sub materials
  77155. * @param name Define the name of the newly cloned material
  77156. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  77157. * @returns the cloned material
  77158. */
  77159. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  77160. /**
  77161. * Serializes the materials into a JSON representation.
  77162. * @returns the JSON representation
  77163. */
  77164. serialize(): any;
  77165. /**
  77166. * Dispose the material and release its associated resources
  77167. * @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)
  77168. * @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)
  77169. * @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)
  77170. */
  77171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  77172. /**
  77173. * Creates a MultiMaterial from parsed MultiMaterial data.
  77174. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  77175. * @param scene defines the hosting scene
  77176. * @returns a new MultiMaterial
  77177. */
  77178. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  77179. }
  77180. }
  77181. declare module BABYLON {
  77182. /**
  77183. * Base class for submeshes
  77184. */
  77185. export class BaseSubMesh {
  77186. /** @hidden */
  77187. _materialDefines: Nullable<MaterialDefines>;
  77188. /** @hidden */
  77189. _materialEffect: Nullable<Effect>;
  77190. /**
  77191. * Gets associated effect
  77192. */
  77193. readonly effect: Nullable<Effect>;
  77194. /**
  77195. * Sets associated effect (effect used to render this submesh)
  77196. * @param effect defines the effect to associate with
  77197. * @param defines defines the set of defines used to compile this effect
  77198. */
  77199. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77200. }
  77201. /**
  77202. * Defines a subdivision inside a mesh
  77203. */
  77204. export class SubMesh extends BaseSubMesh implements ICullable {
  77205. /** the material index to use */
  77206. materialIndex: number;
  77207. /** vertex index start */
  77208. verticesStart: number;
  77209. /** vertices count */
  77210. verticesCount: number;
  77211. /** index start */
  77212. indexStart: number;
  77213. /** indices count */
  77214. indexCount: number;
  77215. /** @hidden */
  77216. _linesIndexCount: number;
  77217. private _mesh;
  77218. private _renderingMesh;
  77219. private _boundingInfo;
  77220. private _linesIndexBuffer;
  77221. /** @hidden */
  77222. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77223. /** @hidden */
  77224. _trianglePlanes: Plane[];
  77225. /** @hidden */
  77226. _lastColliderTransformMatrix: Matrix;
  77227. /** @hidden */
  77228. _renderId: number;
  77229. /** @hidden */
  77230. _alphaIndex: number;
  77231. /** @hidden */
  77232. _distanceToCamera: number;
  77233. /** @hidden */
  77234. _id: number;
  77235. private _currentMaterial;
  77236. /**
  77237. * Add a new submesh to a mesh
  77238. * @param materialIndex defines the material index to use
  77239. * @param verticesStart defines vertex index start
  77240. * @param verticesCount defines vertices count
  77241. * @param indexStart defines index start
  77242. * @param indexCount defines indices count
  77243. * @param mesh defines the parent mesh
  77244. * @param renderingMesh defines an optional rendering mesh
  77245. * @param createBoundingBox defines if bounding box should be created for this submesh
  77246. * @returns the new submesh
  77247. */
  77248. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77249. /**
  77250. * Creates a new submesh
  77251. * @param materialIndex defines the material index to use
  77252. * @param verticesStart defines vertex index start
  77253. * @param verticesCount defines vertices count
  77254. * @param indexStart defines index start
  77255. * @param indexCount defines indices count
  77256. * @param mesh defines the parent mesh
  77257. * @param renderingMesh defines an optional rendering mesh
  77258. * @param createBoundingBox defines if bounding box should be created for this submesh
  77259. */
  77260. constructor(
  77261. /** the material index to use */
  77262. materialIndex: number,
  77263. /** vertex index start */
  77264. verticesStart: number,
  77265. /** vertices count */
  77266. verticesCount: number,
  77267. /** index start */
  77268. indexStart: number,
  77269. /** indices count */
  77270. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77271. /**
  77272. * Returns true if this submesh covers the entire parent mesh
  77273. * @ignorenaming
  77274. */
  77275. readonly IsGlobal: boolean;
  77276. /**
  77277. * Returns the submesh BoudingInfo object
  77278. * @returns current bounding info (or mesh's one if the submesh is global)
  77279. */
  77280. getBoundingInfo(): BoundingInfo;
  77281. /**
  77282. * Sets the submesh BoundingInfo
  77283. * @param boundingInfo defines the new bounding info to use
  77284. * @returns the SubMesh
  77285. */
  77286. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77287. /**
  77288. * Returns the mesh of the current submesh
  77289. * @return the parent mesh
  77290. */
  77291. getMesh(): AbstractMesh;
  77292. /**
  77293. * Returns the rendering mesh of the submesh
  77294. * @returns the rendering mesh (could be different from parent mesh)
  77295. */
  77296. getRenderingMesh(): Mesh;
  77297. /**
  77298. * Returns the submesh material
  77299. * @returns null or the current material
  77300. */
  77301. getMaterial(): Nullable<Material>;
  77302. /**
  77303. * Sets a new updated BoundingInfo object to the submesh
  77304. * @returns the SubMesh
  77305. */
  77306. refreshBoundingInfo(): SubMesh;
  77307. /** @hidden */
  77308. _checkCollision(collider: Collider): boolean;
  77309. /**
  77310. * Updates the submesh BoundingInfo
  77311. * @param world defines the world matrix to use to update the bounding info
  77312. * @returns the submesh
  77313. */
  77314. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77315. /**
  77316. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77317. * @param frustumPlanes defines the frustum planes
  77318. * @returns true if the submesh is intersecting with the frustum
  77319. */
  77320. isInFrustum(frustumPlanes: Plane[]): boolean;
  77321. /**
  77322. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77323. * @param frustumPlanes defines the frustum planes
  77324. * @returns true if the submesh is inside the frustum
  77325. */
  77326. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77327. /**
  77328. * Renders the submesh
  77329. * @param enableAlphaMode defines if alpha needs to be used
  77330. * @returns the submesh
  77331. */
  77332. render(enableAlphaMode: boolean): SubMesh;
  77333. /**
  77334. * @hidden
  77335. */
  77336. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77337. /**
  77338. * Checks if the submesh intersects with a ray
  77339. * @param ray defines the ray to test
  77340. * @returns true is the passed ray intersects the submesh bounding box
  77341. */
  77342. canIntersects(ray: Ray): boolean;
  77343. /**
  77344. * Intersects current submesh with a ray
  77345. * @param ray defines the ray to test
  77346. * @param positions defines mesh's positions array
  77347. * @param indices defines mesh's indices array
  77348. * @param fastCheck defines if only bounding info should be used
  77349. * @returns intersection info or null if no intersection
  77350. */
  77351. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77352. /** @hidden */
  77353. private _intersectLines;
  77354. /** @hidden */
  77355. private _intersectTriangles;
  77356. /** @hidden */
  77357. _rebuild(): void;
  77358. /**
  77359. * Creates a new submesh from the passed mesh
  77360. * @param newMesh defines the new hosting mesh
  77361. * @param newRenderingMesh defines an optional rendering mesh
  77362. * @returns the new submesh
  77363. */
  77364. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77365. /**
  77366. * Release associated resources
  77367. */
  77368. dispose(): void;
  77369. /**
  77370. * Gets the class name
  77371. * @returns the string "SubMesh".
  77372. */
  77373. getClassName(): string;
  77374. /**
  77375. * Creates a new submesh from indices data
  77376. * @param materialIndex the index of the main mesh material
  77377. * @param startIndex the index where to start the copy in the mesh indices array
  77378. * @param indexCount the number of indices to copy then from the startIndex
  77379. * @param mesh the main mesh to create the submesh from
  77380. * @param renderingMesh the optional rendering mesh
  77381. * @returns a new submesh
  77382. */
  77383. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77384. }
  77385. }
  77386. declare module BABYLON {
  77387. /**
  77388. * Class used to store geometry data (vertex buffers + index buffer)
  77389. */
  77390. export class Geometry implements IGetSetVerticesData {
  77391. /**
  77392. * Gets or sets the ID of the geometry
  77393. */
  77394. id: string;
  77395. /**
  77396. * Gets or sets the unique ID of the geometry
  77397. */
  77398. uniqueId: number;
  77399. /**
  77400. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77401. */
  77402. delayLoadState: number;
  77403. /**
  77404. * Gets the file containing the data to load when running in delay load state
  77405. */
  77406. delayLoadingFile: Nullable<string>;
  77407. /**
  77408. * Callback called when the geometry is updated
  77409. */
  77410. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77411. private _scene;
  77412. private _engine;
  77413. private _meshes;
  77414. private _totalVertices;
  77415. /** @hidden */
  77416. _indices: IndicesArray;
  77417. /** @hidden */
  77418. _vertexBuffers: {
  77419. [key: string]: VertexBuffer;
  77420. };
  77421. private _isDisposed;
  77422. private _extend;
  77423. private _boundingBias;
  77424. /** @hidden */
  77425. _delayInfo: Array<string>;
  77426. private _indexBuffer;
  77427. private _indexBufferIsUpdatable;
  77428. /** @hidden */
  77429. _boundingInfo: Nullable<BoundingInfo>;
  77430. /** @hidden */
  77431. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77432. /** @hidden */
  77433. _softwareSkinningFrameId: number;
  77434. private _vertexArrayObjects;
  77435. private _updatable;
  77436. /** @hidden */
  77437. _positions: Nullable<Vector3[]>;
  77438. /**
  77439. * 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
  77440. */
  77441. /**
  77442. * 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
  77443. */
  77444. boundingBias: Vector2;
  77445. /**
  77446. * Static function used to attach a new empty geometry to a mesh
  77447. * @param mesh defines the mesh to attach the geometry to
  77448. * @returns the new Geometry
  77449. */
  77450. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77451. /**
  77452. * Creates a new geometry
  77453. * @param id defines the unique ID
  77454. * @param scene defines the hosting scene
  77455. * @param vertexData defines the VertexData used to get geometry data
  77456. * @param updatable defines if geometry must be updatable (false by default)
  77457. * @param mesh defines the mesh that will be associated with the geometry
  77458. */
  77459. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77460. /**
  77461. * Gets the current extend of the geometry
  77462. */
  77463. readonly extend: {
  77464. minimum: Vector3;
  77465. maximum: Vector3;
  77466. };
  77467. /**
  77468. * Gets the hosting scene
  77469. * @returns the hosting Scene
  77470. */
  77471. getScene(): Scene;
  77472. /**
  77473. * Gets the hosting engine
  77474. * @returns the hosting Engine
  77475. */
  77476. getEngine(): Engine;
  77477. /**
  77478. * Defines if the geometry is ready to use
  77479. * @returns true if the geometry is ready to be used
  77480. */
  77481. isReady(): boolean;
  77482. /**
  77483. * Gets a value indicating that the geometry should not be serialized
  77484. */
  77485. readonly doNotSerialize: boolean;
  77486. /** @hidden */
  77487. _rebuild(): void;
  77488. /**
  77489. * Affects all geometry data in one call
  77490. * @param vertexData defines the geometry data
  77491. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77492. */
  77493. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77494. /**
  77495. * Set specific vertex data
  77496. * @param kind defines the data kind (Position, normal, etc...)
  77497. * @param data defines the vertex data to use
  77498. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77499. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77500. */
  77501. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77502. /**
  77503. * Removes a specific vertex data
  77504. * @param kind defines the data kind (Position, normal, etc...)
  77505. */
  77506. removeVerticesData(kind: string): void;
  77507. /**
  77508. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77509. * @param buffer defines the vertex buffer to use
  77510. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77511. */
  77512. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77513. /**
  77514. * Update a specific vertex buffer
  77515. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77516. * It will do nothing if the buffer is not updatable
  77517. * @param kind defines the data kind (Position, normal, etc...)
  77518. * @param data defines the data to use
  77519. * @param offset defines the offset in the target buffer where to store the data
  77520. * @param useBytes set to true if the offset is in bytes
  77521. */
  77522. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77523. /**
  77524. * Update a specific vertex buffer
  77525. * This function will create a new buffer if the current one is not updatable
  77526. * @param kind defines the data kind (Position, normal, etc...)
  77527. * @param data defines the data to use
  77528. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77529. */
  77530. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77531. private _updateBoundingInfo;
  77532. /** @hidden */
  77533. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77534. /**
  77535. * Gets total number of vertices
  77536. * @returns the total number of vertices
  77537. */
  77538. getTotalVertices(): number;
  77539. /**
  77540. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77541. * @param kind defines the data kind (Position, normal, etc...)
  77542. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77543. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77544. * @returns a float array containing vertex data
  77545. */
  77546. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77547. /**
  77548. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77549. * @param kind defines the data kind (Position, normal, etc...)
  77550. * @returns true if the vertex buffer with the specified kind is updatable
  77551. */
  77552. isVertexBufferUpdatable(kind: string): boolean;
  77553. /**
  77554. * Gets a specific vertex buffer
  77555. * @param kind defines the data kind (Position, normal, etc...)
  77556. * @returns a VertexBuffer
  77557. */
  77558. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77559. /**
  77560. * Returns all vertex buffers
  77561. * @return an object holding all vertex buffers indexed by kind
  77562. */
  77563. getVertexBuffers(): Nullable<{
  77564. [key: string]: VertexBuffer;
  77565. }>;
  77566. /**
  77567. * Gets a boolean indicating if specific vertex buffer is present
  77568. * @param kind defines the data kind (Position, normal, etc...)
  77569. * @returns true if data is present
  77570. */
  77571. isVerticesDataPresent(kind: string): boolean;
  77572. /**
  77573. * Gets a list of all attached data kinds (Position, normal, etc...)
  77574. * @returns a list of string containing all kinds
  77575. */
  77576. getVerticesDataKinds(): string[];
  77577. /**
  77578. * Update index buffer
  77579. * @param indices defines the indices to store in the index buffer
  77580. * @param offset defines the offset in the target buffer where to store the data
  77581. */
  77582. updateIndices(indices: IndicesArray, offset?: number): void;
  77583. /**
  77584. * Creates a new index buffer
  77585. * @param indices defines the indices to store in the index buffer
  77586. * @param totalVertices defines the total number of vertices (could be null)
  77587. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77588. */
  77589. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77590. /**
  77591. * Return the total number of indices
  77592. * @returns the total number of indices
  77593. */
  77594. getTotalIndices(): number;
  77595. /**
  77596. * Gets the index buffer array
  77597. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77599. * @returns the index buffer array
  77600. */
  77601. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77602. /**
  77603. * Gets the index buffer
  77604. * @return the index buffer
  77605. */
  77606. getIndexBuffer(): Nullable<WebGLBuffer>;
  77607. /** @hidden */
  77608. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77609. /**
  77610. * Release the associated resources for a specific mesh
  77611. * @param mesh defines the source mesh
  77612. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77613. */
  77614. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77615. /**
  77616. * Apply current geometry to a given mesh
  77617. * @param mesh defines the mesh to apply geometry to
  77618. */
  77619. applyToMesh(mesh: Mesh): void;
  77620. private _updateExtend;
  77621. private _applyToMesh;
  77622. private notifyUpdate;
  77623. /**
  77624. * Load the geometry if it was flagged as delay loaded
  77625. * @param scene defines the hosting scene
  77626. * @param onLoaded defines a callback called when the geometry is loaded
  77627. */
  77628. load(scene: Scene, onLoaded?: () => void): void;
  77629. private _queueLoad;
  77630. /**
  77631. * Invert the geometry to move from a right handed system to a left handed one.
  77632. */
  77633. toLeftHanded(): void;
  77634. /** @hidden */
  77635. _resetPointsArrayCache(): void;
  77636. /** @hidden */
  77637. _generatePointsArray(): boolean;
  77638. /**
  77639. * Gets a value indicating if the geometry is disposed
  77640. * @returns true if the geometry was disposed
  77641. */
  77642. isDisposed(): boolean;
  77643. private _disposeVertexArrayObjects;
  77644. /**
  77645. * Free all associated resources
  77646. */
  77647. dispose(): void;
  77648. /**
  77649. * Clone the current geometry into a new geometry
  77650. * @param id defines the unique ID of the new geometry
  77651. * @returns a new geometry object
  77652. */
  77653. copy(id: string): Geometry;
  77654. /**
  77655. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77656. * @return a JSON representation of the current geometry data (without the vertices data)
  77657. */
  77658. serialize(): any;
  77659. private toNumberArray;
  77660. /**
  77661. * Serialize all vertices data into a JSON oject
  77662. * @returns a JSON representation of the current geometry data
  77663. */
  77664. serializeVerticeData(): any;
  77665. /**
  77666. * Extracts a clone of a mesh geometry
  77667. * @param mesh defines the source mesh
  77668. * @param id defines the unique ID of the new geometry object
  77669. * @returns the new geometry object
  77670. */
  77671. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77672. /**
  77673. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77674. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77675. * Be aware Math.random() could cause collisions, but:
  77676. * "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"
  77677. * @returns a string containing a new GUID
  77678. */
  77679. static RandomId(): string;
  77680. /** @hidden */
  77681. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77682. private static _CleanMatricesWeights;
  77683. /**
  77684. * Create a new geometry from persisted data (Using .babylon file format)
  77685. * @param parsedVertexData defines the persisted data
  77686. * @param scene defines the hosting scene
  77687. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77688. * @returns the new geometry object
  77689. */
  77690. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77691. }
  77692. /**
  77693. * Abstract class used to provide common services for all typed geometries
  77694. * @hidden
  77695. */
  77696. export class _PrimitiveGeometry extends Geometry {
  77697. private _canBeRegenerated;
  77698. private _beingRegenerated;
  77699. /**
  77700. * Creates a new typed geometry
  77701. * @param id defines the unique ID of the geometry
  77702. * @param scene defines the hosting scene
  77703. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77704. * @param mesh defines the hosting mesh (can be null)
  77705. */
  77706. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  77707. /**
  77708. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  77709. * @returns true if the geometry can be regenerated
  77710. */
  77711. canBeRegenerated(): boolean;
  77712. /**
  77713. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  77714. */
  77715. regenerate(): void;
  77716. /**
  77717. * Clone the geometry
  77718. * @param id defines the unique ID of the new geometry
  77719. * @returns the new geometry
  77720. */
  77721. asNewGeometry(id: string): Geometry;
  77722. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77723. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  77724. /** @hidden */
  77725. _regenerateVertexData(): VertexData;
  77726. copy(id: string): Geometry;
  77727. serialize(): any;
  77728. }
  77729. /**
  77730. * Creates a ribbon geometry
  77731. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  77732. */
  77733. export class RibbonGeometry extends _PrimitiveGeometry {
  77734. /**
  77735. * Defines the array of paths to use
  77736. */
  77737. pathArray: Vector3[][];
  77738. /**
  77739. * Defines if the last and first points of each path in your pathArray must be joined
  77740. */
  77741. closeArray: boolean;
  77742. /**
  77743. * Defines if the last and first points of each path in your pathArray must be joined
  77744. */
  77745. closePath: boolean;
  77746. /**
  77747. * Defines the offset between points
  77748. */
  77749. offset: number;
  77750. /**
  77751. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77752. */
  77753. side: number;
  77754. /**
  77755. * Creates a ribbon geometry
  77756. * @param id defines the unique ID of the geometry
  77757. * @param scene defines the hosting scene
  77758. * @param pathArray defines the array of paths to use
  77759. * @param closeArray defines if the last path and the first path must be joined
  77760. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  77761. * @param offset defines the offset between points
  77762. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77763. * @param mesh defines the hosting mesh (can be null)
  77764. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77765. */
  77766. constructor(id: string, scene: Scene,
  77767. /**
  77768. * Defines the array of paths to use
  77769. */
  77770. pathArray: Vector3[][],
  77771. /**
  77772. * Defines if the last and first points of each path in your pathArray must be joined
  77773. */
  77774. closeArray: boolean,
  77775. /**
  77776. * Defines if the last and first points of each path in your pathArray must be joined
  77777. */
  77778. closePath: boolean,
  77779. /**
  77780. * Defines the offset between points
  77781. */
  77782. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  77783. /**
  77784. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77785. */
  77786. side?: number);
  77787. /** @hidden */
  77788. _regenerateVertexData(): VertexData;
  77789. copy(id: string): Geometry;
  77790. }
  77791. /**
  77792. * Creates a box geometry
  77793. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  77794. */
  77795. export class BoxGeometry extends _PrimitiveGeometry {
  77796. /**
  77797. * Defines the zise of the box (width, height and depth are the same)
  77798. */
  77799. size: number;
  77800. /**
  77801. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77802. */
  77803. side: number;
  77804. /**
  77805. * Creates a box geometry
  77806. * @param id defines the unique ID of the geometry
  77807. * @param scene defines the hosting scene
  77808. * @param size defines the zise of the box (width, height and depth are the same)
  77809. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77810. * @param mesh defines the hosting mesh (can be null)
  77811. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77812. */
  77813. constructor(id: string, scene: Scene,
  77814. /**
  77815. * Defines the zise of the box (width, height and depth are the same)
  77816. */
  77817. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  77818. /**
  77819. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77820. */
  77821. side?: number);
  77822. /** @hidden */
  77823. _regenerateVertexData(): VertexData;
  77824. copy(id: string): Geometry;
  77825. serialize(): any;
  77826. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  77827. }
  77828. /**
  77829. * Creates a sphere geometry
  77830. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  77831. */
  77832. export class SphereGeometry extends _PrimitiveGeometry {
  77833. /**
  77834. * Defines the number of segments to use to create the sphere
  77835. */
  77836. segments: number;
  77837. /**
  77838. * Defines the diameter of the sphere
  77839. */
  77840. diameter: number;
  77841. /**
  77842. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77843. */
  77844. side: number;
  77845. /**
  77846. * Create a new sphere geometry
  77847. * @param id defines the unique ID of the geometry
  77848. * @param scene defines the hosting scene
  77849. * @param segments defines the number of segments to use to create the sphere
  77850. * @param diameter defines the diameter of the sphere
  77851. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77852. * @param mesh defines the hosting mesh (can be null)
  77853. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77854. */
  77855. constructor(id: string, scene: Scene,
  77856. /**
  77857. * Defines the number of segments to use to create the sphere
  77858. */
  77859. segments: number,
  77860. /**
  77861. * Defines the diameter of the sphere
  77862. */
  77863. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  77864. /**
  77865. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77866. */
  77867. side?: number);
  77868. /** @hidden */
  77869. _regenerateVertexData(): VertexData;
  77870. copy(id: string): Geometry;
  77871. serialize(): any;
  77872. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  77873. }
  77874. /**
  77875. * Creates a disc geometry
  77876. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  77877. */
  77878. export class DiscGeometry extends _PrimitiveGeometry {
  77879. /**
  77880. * Defines the radius of the disc
  77881. */
  77882. radius: number;
  77883. /**
  77884. * Defines the tesselation factor to apply to the disc
  77885. */
  77886. tessellation: number;
  77887. /**
  77888. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77889. */
  77890. side: number;
  77891. /**
  77892. * Creates a new disc geometry
  77893. * @param id defines the unique ID of the geometry
  77894. * @param scene defines the hosting scene
  77895. * @param radius defines the radius of the disc
  77896. * @param tessellation defines the tesselation factor to apply to the disc
  77897. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77898. * @param mesh defines the hosting mesh (can be null)
  77899. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77900. */
  77901. constructor(id: string, scene: Scene,
  77902. /**
  77903. * Defines the radius of the disc
  77904. */
  77905. radius: number,
  77906. /**
  77907. * Defines the tesselation factor to apply to the disc
  77908. */
  77909. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  77910. /**
  77911. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77912. */
  77913. side?: number);
  77914. /** @hidden */
  77915. _regenerateVertexData(): VertexData;
  77916. copy(id: string): Geometry;
  77917. }
  77918. /**
  77919. * Creates a new cylinder geometry
  77920. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  77921. */
  77922. export class CylinderGeometry extends _PrimitiveGeometry {
  77923. /**
  77924. * Defines the height of the cylinder
  77925. */
  77926. height: number;
  77927. /**
  77928. * Defines the diameter of the cylinder's top cap
  77929. */
  77930. diameterTop: number;
  77931. /**
  77932. * Defines the diameter of the cylinder's bottom cap
  77933. */
  77934. diameterBottom: number;
  77935. /**
  77936. * Defines the tessellation factor to apply to the cylinder
  77937. */
  77938. tessellation: number;
  77939. /**
  77940. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  77941. */
  77942. subdivisions: number;
  77943. /**
  77944. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77945. */
  77946. side: number;
  77947. /**
  77948. * Creates a new cylinder geometry
  77949. * @param id defines the unique ID of the geometry
  77950. * @param scene defines the hosting scene
  77951. * @param height defines the height of the cylinder
  77952. * @param diameterTop defines the diameter of the cylinder's top cap
  77953. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  77954. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  77955. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  77956. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  77957. * @param mesh defines the hosting mesh (can be null)
  77958. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77959. */
  77960. constructor(id: string, scene: Scene,
  77961. /**
  77962. * Defines the height of the cylinder
  77963. */
  77964. height: number,
  77965. /**
  77966. * Defines the diameter of the cylinder's top cap
  77967. */
  77968. diameterTop: number,
  77969. /**
  77970. * Defines the diameter of the cylinder's bottom cap
  77971. */
  77972. diameterBottom: number,
  77973. /**
  77974. * Defines the tessellation factor to apply to the cylinder
  77975. */
  77976. tessellation: number,
  77977. /**
  77978. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  77979. */
  77980. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  77981. /**
  77982. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  77983. */
  77984. side?: number);
  77985. /** @hidden */
  77986. _regenerateVertexData(): VertexData;
  77987. copy(id: string): Geometry;
  77988. serialize(): any;
  77989. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  77990. }
  77991. /**
  77992. * Creates a new torus geometry
  77993. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  77994. */
  77995. export class TorusGeometry extends _PrimitiveGeometry {
  77996. /**
  77997. * Defines the diameter of the torus
  77998. */
  77999. diameter: number;
  78000. /**
  78001. * Defines the thickness of the torus (ie. internal diameter)
  78002. */
  78003. thickness: number;
  78004. /**
  78005. * Defines the tesselation factor to apply to the torus
  78006. */
  78007. tessellation: number;
  78008. /**
  78009. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78010. */
  78011. side: number;
  78012. /**
  78013. * Creates a new torus geometry
  78014. * @param id defines the unique ID of the geometry
  78015. * @param scene defines the hosting scene
  78016. * @param diameter defines the diameter of the torus
  78017. * @param thickness defines the thickness of the torus (ie. internal diameter)
  78018. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  78019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78020. * @param mesh defines the hosting mesh (can be null)
  78021. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78022. */
  78023. constructor(id: string, scene: Scene,
  78024. /**
  78025. * Defines the diameter of the torus
  78026. */
  78027. diameter: number,
  78028. /**
  78029. * Defines the thickness of the torus (ie. internal diameter)
  78030. */
  78031. thickness: number,
  78032. /**
  78033. * Defines the tesselation factor to apply to the torus
  78034. */
  78035. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  78036. /**
  78037. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78038. */
  78039. side?: number);
  78040. /** @hidden */
  78041. _regenerateVertexData(): VertexData;
  78042. copy(id: string): Geometry;
  78043. serialize(): any;
  78044. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  78045. }
  78046. /**
  78047. * Creates a new ground geometry
  78048. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  78049. */
  78050. export class GroundGeometry extends _PrimitiveGeometry {
  78051. /**
  78052. * Defines the width of the ground
  78053. */
  78054. width: number;
  78055. /**
  78056. * Defines the height of the ground
  78057. */
  78058. height: number;
  78059. /**
  78060. * Defines the subdivisions to apply to the ground
  78061. */
  78062. subdivisions: number;
  78063. /**
  78064. * Creates a new ground geometry
  78065. * @param id defines the unique ID of the geometry
  78066. * @param scene defines the hosting scene
  78067. * @param width defines the width of the ground
  78068. * @param height defines the height of the ground
  78069. * @param subdivisions defines the subdivisions to apply to the ground
  78070. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78071. * @param mesh defines the hosting mesh (can be null)
  78072. */
  78073. constructor(id: string, scene: Scene,
  78074. /**
  78075. * Defines the width of the ground
  78076. */
  78077. width: number,
  78078. /**
  78079. * Defines the height of the ground
  78080. */
  78081. height: number,
  78082. /**
  78083. * Defines the subdivisions to apply to the ground
  78084. */
  78085. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  78086. /** @hidden */
  78087. _regenerateVertexData(): VertexData;
  78088. copy(id: string): Geometry;
  78089. serialize(): any;
  78090. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  78091. }
  78092. /**
  78093. * Creates a tiled ground geometry
  78094. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  78095. */
  78096. export class TiledGroundGeometry extends _PrimitiveGeometry {
  78097. /**
  78098. * Defines the minimum value on X axis
  78099. */
  78100. xmin: number;
  78101. /**
  78102. * Defines the minimum value on Z axis
  78103. */
  78104. zmin: number;
  78105. /**
  78106. * Defines the maximum value on X axis
  78107. */
  78108. xmax: number;
  78109. /**
  78110. * Defines the maximum value on Z axis
  78111. */
  78112. zmax: number;
  78113. /**
  78114. * Defines the subdivisions to apply to the ground
  78115. */
  78116. subdivisions: {
  78117. w: number;
  78118. h: number;
  78119. };
  78120. /**
  78121. * Defines the precision to use when computing the tiles
  78122. */
  78123. precision: {
  78124. w: number;
  78125. h: number;
  78126. };
  78127. /**
  78128. * Creates a tiled ground geometry
  78129. * @param id defines the unique ID of the geometry
  78130. * @param scene defines the hosting scene
  78131. * @param xmin defines the minimum value on X axis
  78132. * @param zmin defines the minimum value on Z axis
  78133. * @param xmax defines the maximum value on X axis
  78134. * @param zmax defines the maximum value on Z axis
  78135. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  78136. * @param precision defines the precision to use when computing the tiles
  78137. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78138. * @param mesh defines the hosting mesh (can be null)
  78139. */
  78140. constructor(id: string, scene: Scene,
  78141. /**
  78142. * Defines the minimum value on X axis
  78143. */
  78144. xmin: number,
  78145. /**
  78146. * Defines the minimum value on Z axis
  78147. */
  78148. zmin: number,
  78149. /**
  78150. * Defines the maximum value on X axis
  78151. */
  78152. xmax: number,
  78153. /**
  78154. * Defines the maximum value on Z axis
  78155. */
  78156. zmax: number,
  78157. /**
  78158. * Defines the subdivisions to apply to the ground
  78159. */
  78160. subdivisions: {
  78161. w: number;
  78162. h: number;
  78163. },
  78164. /**
  78165. * Defines the precision to use when computing the tiles
  78166. */
  78167. precision: {
  78168. w: number;
  78169. h: number;
  78170. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  78171. /** @hidden */
  78172. _regenerateVertexData(): VertexData;
  78173. copy(id: string): Geometry;
  78174. }
  78175. /**
  78176. * Creates a plane geometry
  78177. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  78178. */
  78179. export class PlaneGeometry extends _PrimitiveGeometry {
  78180. /**
  78181. * Defines the size of the plane (width === height)
  78182. */
  78183. size: number;
  78184. /**
  78185. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78186. */
  78187. side: number;
  78188. /**
  78189. * Creates a plane geometry
  78190. * @param id defines the unique ID of the geometry
  78191. * @param scene defines the hosting scene
  78192. * @param size defines the size of the plane (width === height)
  78193. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78194. * @param mesh defines the hosting mesh (can be null)
  78195. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78196. */
  78197. constructor(id: string, scene: Scene,
  78198. /**
  78199. * Defines the size of the plane (width === height)
  78200. */
  78201. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  78202. /**
  78203. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78204. */
  78205. side?: number);
  78206. /** @hidden */
  78207. _regenerateVertexData(): VertexData;
  78208. copy(id: string): Geometry;
  78209. serialize(): any;
  78210. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  78211. }
  78212. /**
  78213. * Creates a torus knot geometry
  78214. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  78215. */
  78216. export class TorusKnotGeometry extends _PrimitiveGeometry {
  78217. /**
  78218. * Defines the radius of the torus knot
  78219. */
  78220. radius: number;
  78221. /**
  78222. * Defines the thickness of the torus knot tube
  78223. */
  78224. tube: number;
  78225. /**
  78226. * Defines the number of radial segments
  78227. */
  78228. radialSegments: number;
  78229. /**
  78230. * Defines the number of tubular segments
  78231. */
  78232. tubularSegments: number;
  78233. /**
  78234. * Defines the first number of windings
  78235. */
  78236. p: number;
  78237. /**
  78238. * Defines the second number of windings
  78239. */
  78240. q: number;
  78241. /**
  78242. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78243. */
  78244. side: number;
  78245. /**
  78246. * Creates a torus knot geometry
  78247. * @param id defines the unique ID of the geometry
  78248. * @param scene defines the hosting scene
  78249. * @param radius defines the radius of the torus knot
  78250. * @param tube defines the thickness of the torus knot tube
  78251. * @param radialSegments defines the number of radial segments
  78252. * @param tubularSegments defines the number of tubular segments
  78253. * @param p defines the first number of windings
  78254. * @param q defines the second number of windings
  78255. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  78256. * @param mesh defines the hosting mesh (can be null)
  78257. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78258. */
  78259. constructor(id: string, scene: Scene,
  78260. /**
  78261. * Defines the radius of the torus knot
  78262. */
  78263. radius: number,
  78264. /**
  78265. * Defines the thickness of the torus knot tube
  78266. */
  78267. tube: number,
  78268. /**
  78269. * Defines the number of radial segments
  78270. */
  78271. radialSegments: number,
  78272. /**
  78273. * Defines the number of tubular segments
  78274. */
  78275. tubularSegments: number,
  78276. /**
  78277. * Defines the first number of windings
  78278. */
  78279. p: number,
  78280. /**
  78281. * Defines the second number of windings
  78282. */
  78283. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  78284. /**
  78285. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  78286. */
  78287. side?: number);
  78288. /** @hidden */
  78289. _regenerateVertexData(): VertexData;
  78290. copy(id: string): Geometry;
  78291. serialize(): any;
  78292. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  78293. }
  78294. }
  78295. declare module BABYLON {
  78296. /**
  78297. * Define an interface for all classes that will get and set the data on vertices
  78298. */
  78299. export interface IGetSetVerticesData {
  78300. /**
  78301. * Gets a boolean indicating if specific vertex data is present
  78302. * @param kind defines the vertex data kind to use
  78303. * @returns true is data kind is present
  78304. */
  78305. isVerticesDataPresent(kind: string): boolean;
  78306. /**
  78307. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78308. * @param kind defines the data kind (Position, normal, etc...)
  78309. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78310. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78311. * @returns a float array containing vertex data
  78312. */
  78313. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78314. /**
  78315. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78316. * @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.
  78317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78318. * @returns the indices array or an empty array if the mesh has no geometry
  78319. */
  78320. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78321. /**
  78322. * Set specific vertex data
  78323. * @param kind defines the data kind (Position, normal, etc...)
  78324. * @param data defines the vertex data to use
  78325. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78326. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78327. */
  78328. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  78329. /**
  78330. * Update a specific associated vertex buffer
  78331. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78332. * - VertexBuffer.PositionKind
  78333. * - VertexBuffer.UVKind
  78334. * - VertexBuffer.UV2Kind
  78335. * - VertexBuffer.UV3Kind
  78336. * - VertexBuffer.UV4Kind
  78337. * - VertexBuffer.UV5Kind
  78338. * - VertexBuffer.UV6Kind
  78339. * - VertexBuffer.ColorKind
  78340. * - VertexBuffer.MatricesIndicesKind
  78341. * - VertexBuffer.MatricesIndicesExtraKind
  78342. * - VertexBuffer.MatricesWeightsKind
  78343. * - VertexBuffer.MatricesWeightsExtraKind
  78344. * @param data defines the data source
  78345. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78346. * @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)
  78347. */
  78348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  78349. /**
  78350. * Creates a new index buffer
  78351. * @param indices defines the indices to store in the index buffer
  78352. * @param totalVertices defines the total number of vertices (could be null)
  78353. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78354. */
  78355. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  78356. }
  78357. /**
  78358. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  78359. */
  78360. export class VertexData {
  78361. /**
  78362. * Mesh side orientation : usually the external or front surface
  78363. */
  78364. static readonly FRONTSIDE: number;
  78365. /**
  78366. * Mesh side orientation : usually the internal or back surface
  78367. */
  78368. static readonly BACKSIDE: number;
  78369. /**
  78370. * Mesh side orientation : both internal and external or front and back surfaces
  78371. */
  78372. static readonly DOUBLESIDE: number;
  78373. /**
  78374. * Mesh side orientation : by default, `FRONTSIDE`
  78375. */
  78376. static readonly DEFAULTSIDE: number;
  78377. /**
  78378. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  78379. */
  78380. positions: Nullable<FloatArray>;
  78381. /**
  78382. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  78383. */
  78384. normals: Nullable<FloatArray>;
  78385. /**
  78386. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  78387. */
  78388. tangents: Nullable<FloatArray>;
  78389. /**
  78390. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78391. */
  78392. uvs: Nullable<FloatArray>;
  78393. /**
  78394. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78395. */
  78396. uvs2: Nullable<FloatArray>;
  78397. /**
  78398. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78399. */
  78400. uvs3: Nullable<FloatArray>;
  78401. /**
  78402. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78403. */
  78404. uvs4: Nullable<FloatArray>;
  78405. /**
  78406. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78407. */
  78408. uvs5: Nullable<FloatArray>;
  78409. /**
  78410. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78411. */
  78412. uvs6: Nullable<FloatArray>;
  78413. /**
  78414. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  78415. */
  78416. colors: Nullable<FloatArray>;
  78417. /**
  78418. * 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).
  78419. */
  78420. matricesIndices: Nullable<FloatArray>;
  78421. /**
  78422. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  78423. */
  78424. matricesWeights: Nullable<FloatArray>;
  78425. /**
  78426. * An array extending the number of possible indices
  78427. */
  78428. matricesIndicesExtra: Nullable<FloatArray>;
  78429. /**
  78430. * An array extending the number of possible weights when the number of indices is extended
  78431. */
  78432. matricesWeightsExtra: Nullable<FloatArray>;
  78433. /**
  78434. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  78435. */
  78436. indices: Nullable<IndicesArray>;
  78437. /**
  78438. * Uses the passed data array to set the set the values for the specified kind of data
  78439. * @param data a linear array of floating numbers
  78440. * @param kind the type of data that is being set, eg positions, colors etc
  78441. */
  78442. set(data: FloatArray, kind: string): void;
  78443. /**
  78444. * Associates the vertexData to the passed Mesh.
  78445. * Sets it as updatable or not (default `false`)
  78446. * @param mesh the mesh the vertexData is applied to
  78447. * @param updatable when used and having the value true allows new data to update the vertexData
  78448. * @returns the VertexData
  78449. */
  78450. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  78451. /**
  78452. * Associates the vertexData to the passed Geometry.
  78453. * Sets it as updatable or not (default `false`)
  78454. * @param geometry the geometry the vertexData is applied to
  78455. * @param updatable when used and having the value true allows new data to update the vertexData
  78456. * @returns VertexData
  78457. */
  78458. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  78459. /**
  78460. * Updates the associated mesh
  78461. * @param mesh the mesh to be updated
  78462. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78463. * @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
  78464. * @returns VertexData
  78465. */
  78466. updateMesh(mesh: Mesh): VertexData;
  78467. /**
  78468. * Updates the associated geometry
  78469. * @param geometry the geometry to be updated
  78470. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78471. * @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
  78472. * @returns VertexData.
  78473. */
  78474. updateGeometry(geometry: Geometry): VertexData;
  78475. private _applyTo;
  78476. private _update;
  78477. /**
  78478. * Transforms each position and each normal of the vertexData according to the passed Matrix
  78479. * @param matrix the transforming matrix
  78480. * @returns the VertexData
  78481. */
  78482. transform(matrix: Matrix): VertexData;
  78483. /**
  78484. * Merges the passed VertexData into the current one
  78485. * @param other the VertexData to be merged into the current one
  78486. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  78487. * @returns the modified VertexData
  78488. */
  78489. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  78490. private _mergeElement;
  78491. private _validate;
  78492. /**
  78493. * Serializes the VertexData
  78494. * @returns a serialized object
  78495. */
  78496. serialize(): any;
  78497. /**
  78498. * Extracts the vertexData from a mesh
  78499. * @param mesh the mesh from which to extract the VertexData
  78500. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  78501. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78502. * @returns the object VertexData associated to the passed mesh
  78503. */
  78504. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78505. /**
  78506. * Extracts the vertexData from the geometry
  78507. * @param geometry the geometry from which to extract the VertexData
  78508. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  78509. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78510. * @returns the object VertexData associated to the passed mesh
  78511. */
  78512. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78513. private static _ExtractFrom;
  78514. /**
  78515. * Creates the VertexData for a Ribbon
  78516. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  78517. * * pathArray array of paths, each of which an array of successive Vector3
  78518. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  78519. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  78520. * * 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
  78521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78522. * * 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)
  78523. * * 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)
  78524. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  78525. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  78526. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  78527. * @returns the VertexData of the ribbon
  78528. */
  78529. static CreateRibbon(options: {
  78530. pathArray: Vector3[][];
  78531. closeArray?: boolean;
  78532. closePath?: boolean;
  78533. offset?: number;
  78534. sideOrientation?: number;
  78535. frontUVs?: Vector4;
  78536. backUVs?: Vector4;
  78537. invertUV?: boolean;
  78538. uvs?: Vector2[];
  78539. colors?: Color4[];
  78540. }): VertexData;
  78541. /**
  78542. * Creates the VertexData for a box
  78543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78544. * * size sets the width, height and depth of the box to the value of size, optional default 1
  78545. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  78546. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  78547. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  78548. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  78549. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  78550. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78551. * * 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)
  78552. * * 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)
  78553. * @returns the VertexData of the box
  78554. */
  78555. static CreateBox(options: {
  78556. size?: number;
  78557. width?: number;
  78558. height?: number;
  78559. depth?: number;
  78560. faceUV?: Vector4[];
  78561. faceColors?: Color4[];
  78562. sideOrientation?: number;
  78563. frontUVs?: Vector4;
  78564. backUVs?: Vector4;
  78565. }): VertexData;
  78566. /**
  78567. * Creates the VertexData for an ellipsoid, defaults to a sphere
  78568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78569. * * segments sets the number of horizontal strips optional, default 32
  78570. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  78571. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  78572. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  78573. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  78574. * * 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
  78575. * * 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
  78576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78577. * * 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)
  78578. * * 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)
  78579. * @returns the VertexData of the ellipsoid
  78580. */
  78581. static CreateSphere(options: {
  78582. segments?: number;
  78583. diameter?: number;
  78584. diameterX?: number;
  78585. diameterY?: number;
  78586. diameterZ?: number;
  78587. arc?: number;
  78588. slice?: number;
  78589. sideOrientation?: number;
  78590. frontUVs?: Vector4;
  78591. backUVs?: Vector4;
  78592. }): VertexData;
  78593. /**
  78594. * Creates the VertexData for a cylinder, cone or prism
  78595. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78596. * * height sets the height (y direction) of the cylinder, optional, default 2
  78597. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78598. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78599. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78600. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78601. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78602. * * 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
  78603. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78604. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78605. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78606. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78608. * * 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)
  78609. * * 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)
  78610. * @returns the VertexData of the cylinder, cone or prism
  78611. */
  78612. static CreateCylinder(options: {
  78613. height?: number;
  78614. diameterTop?: number;
  78615. diameterBottom?: number;
  78616. diameter?: number;
  78617. tessellation?: number;
  78618. subdivisions?: number;
  78619. arc?: number;
  78620. faceColors?: Color4[];
  78621. faceUV?: Vector4[];
  78622. hasRings?: boolean;
  78623. enclose?: boolean;
  78624. sideOrientation?: number;
  78625. frontUVs?: Vector4;
  78626. backUVs?: Vector4;
  78627. }): VertexData;
  78628. /**
  78629. * Creates the VertexData for a torus
  78630. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78631. * * diameter the diameter of the torus, optional default 1
  78632. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78633. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78635. * * 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)
  78636. * * 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)
  78637. * @returns the VertexData of the torus
  78638. */
  78639. static CreateTorus(options: {
  78640. diameter?: number;
  78641. thickness?: number;
  78642. tessellation?: number;
  78643. sideOrientation?: number;
  78644. frontUVs?: Vector4;
  78645. backUVs?: Vector4;
  78646. }): VertexData;
  78647. /**
  78648. * Creates the VertexData of the LineSystem
  78649. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78650. * - lines an array of lines, each line being an array of successive Vector3
  78651. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78652. * @returns the VertexData of the LineSystem
  78653. */
  78654. static CreateLineSystem(options: {
  78655. lines: Vector3[][];
  78656. colors?: Nullable<Color4[][]>;
  78657. }): VertexData;
  78658. /**
  78659. * Create the VertexData for a DashedLines
  78660. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78661. * - points an array successive Vector3
  78662. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78663. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78664. * - dashNb the intended total number of dashes, optional, default 200
  78665. * @returns the VertexData for the DashedLines
  78666. */
  78667. static CreateDashedLines(options: {
  78668. points: Vector3[];
  78669. dashSize?: number;
  78670. gapSize?: number;
  78671. dashNb?: number;
  78672. }): VertexData;
  78673. /**
  78674. * Creates the VertexData for a Ground
  78675. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78676. * - width the width (x direction) of the ground, optional, default 1
  78677. * - height the height (z direction) of the ground, optional, default 1
  78678. * - subdivisions the number of subdivisions per side, optional, default 1
  78679. * @returns the VertexData of the Ground
  78680. */
  78681. static CreateGround(options: {
  78682. width?: number;
  78683. height?: number;
  78684. subdivisions?: number;
  78685. subdivisionsX?: number;
  78686. subdivisionsY?: number;
  78687. }): VertexData;
  78688. /**
  78689. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78690. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78691. * * xmin the ground minimum X coordinate, optional, default -1
  78692. * * zmin the ground minimum Z coordinate, optional, default -1
  78693. * * xmax the ground maximum X coordinate, optional, default 1
  78694. * * zmax the ground maximum Z coordinate, optional, default 1
  78695. * * 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}
  78696. * * 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}
  78697. * @returns the VertexData of the TiledGround
  78698. */
  78699. static CreateTiledGround(options: {
  78700. xmin: number;
  78701. zmin: number;
  78702. xmax: number;
  78703. zmax: number;
  78704. subdivisions?: {
  78705. w: number;
  78706. h: number;
  78707. };
  78708. precision?: {
  78709. w: number;
  78710. h: number;
  78711. };
  78712. }): VertexData;
  78713. /**
  78714. * Creates the VertexData of the Ground designed from a heightmap
  78715. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78716. * * width the width (x direction) of the ground
  78717. * * height the height (z direction) of the ground
  78718. * * subdivisions the number of subdivisions per side
  78719. * * minHeight the minimum altitude on the ground, optional, default 0
  78720. * * maxHeight the maximum altitude on the ground, optional default 1
  78721. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78722. * * buffer the array holding the image color data
  78723. * * bufferWidth the width of image
  78724. * * bufferHeight the height of image
  78725. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78726. * @returns the VertexData of the Ground designed from a heightmap
  78727. */
  78728. static CreateGroundFromHeightMap(options: {
  78729. width: number;
  78730. height: number;
  78731. subdivisions: number;
  78732. minHeight: number;
  78733. maxHeight: number;
  78734. colorFilter: Color3;
  78735. buffer: Uint8Array;
  78736. bufferWidth: number;
  78737. bufferHeight: number;
  78738. alphaFilter: number;
  78739. }): VertexData;
  78740. /**
  78741. * Creates the VertexData for a Plane
  78742. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78743. * * size sets the width and height of the plane to the value of size, optional default 1
  78744. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78745. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78747. * * 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)
  78748. * * 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)
  78749. * @returns the VertexData of the box
  78750. */
  78751. static CreatePlane(options: {
  78752. size?: number;
  78753. width?: number;
  78754. height?: number;
  78755. sideOrientation?: number;
  78756. frontUVs?: Vector4;
  78757. backUVs?: Vector4;
  78758. }): VertexData;
  78759. /**
  78760. * Creates the VertexData of the Disc or regular Polygon
  78761. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78762. * * radius the radius of the disc, optional default 0.5
  78763. * * tessellation the number of polygon sides, optional, default 64
  78764. * * 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
  78765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78766. * * 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)
  78767. * * 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)
  78768. * @returns the VertexData of the box
  78769. */
  78770. static CreateDisc(options: {
  78771. radius?: number;
  78772. tessellation?: number;
  78773. arc?: number;
  78774. sideOrientation?: number;
  78775. frontUVs?: Vector4;
  78776. backUVs?: Vector4;
  78777. }): VertexData;
  78778. /**
  78779. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78780. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78781. * @param polygon a mesh built from polygonTriangulation.build()
  78782. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78783. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78784. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78785. * @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)
  78786. * @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)
  78787. * @returns the VertexData of the Polygon
  78788. */
  78789. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78790. /**
  78791. * Creates the VertexData of the IcoSphere
  78792. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78793. * * radius the radius of the IcoSphere, optional default 1
  78794. * * radiusX allows stretching in the x direction, optional, default radius
  78795. * * radiusY allows stretching in the y direction, optional, default radius
  78796. * * radiusZ allows stretching in the z direction, optional, default radius
  78797. * * flat when true creates a flat shaded mesh, optional, default true
  78798. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78800. * * 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)
  78801. * * 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)
  78802. * @returns the VertexData of the IcoSphere
  78803. */
  78804. static CreateIcoSphere(options: {
  78805. radius?: number;
  78806. radiusX?: number;
  78807. radiusY?: number;
  78808. radiusZ?: number;
  78809. flat?: boolean;
  78810. subdivisions?: number;
  78811. sideOrientation?: number;
  78812. frontUVs?: Vector4;
  78813. backUVs?: Vector4;
  78814. }): VertexData;
  78815. /**
  78816. * Creates the VertexData for a Polyhedron
  78817. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78818. * * type provided types are:
  78819. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78820. * * 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)
  78821. * * size the size of the IcoSphere, optional default 1
  78822. * * sizeX allows stretching in the x direction, optional, default size
  78823. * * sizeY allows stretching in the y direction, optional, default size
  78824. * * sizeZ allows stretching in the z direction, optional, default size
  78825. * * 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
  78826. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78827. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78828. * * flat when true creates a flat shaded mesh, optional, default true
  78829. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78831. * * 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)
  78832. * * 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)
  78833. * @returns the VertexData of the Polyhedron
  78834. */
  78835. static CreatePolyhedron(options: {
  78836. type?: number;
  78837. size?: number;
  78838. sizeX?: number;
  78839. sizeY?: number;
  78840. sizeZ?: number;
  78841. custom?: any;
  78842. faceUV?: Vector4[];
  78843. faceColors?: Color4[];
  78844. flat?: boolean;
  78845. sideOrientation?: number;
  78846. frontUVs?: Vector4;
  78847. backUVs?: Vector4;
  78848. }): VertexData;
  78849. /**
  78850. * Creates the VertexData for a TorusKnot
  78851. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78852. * * radius the radius of the torus knot, optional, default 2
  78853. * * tube the thickness of the tube, optional, default 0.5
  78854. * * radialSegments the number of sides on each tube segments, optional, default 32
  78855. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78856. * * p the number of windings around the z axis, optional, default 2
  78857. * * q the number of windings around the x axis, optional, default 3
  78858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78859. * * 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)
  78860. * * 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)
  78861. * @returns the VertexData of the Torus Knot
  78862. */
  78863. static CreateTorusKnot(options: {
  78864. radius?: number;
  78865. tube?: number;
  78866. radialSegments?: number;
  78867. tubularSegments?: number;
  78868. p?: number;
  78869. q?: number;
  78870. sideOrientation?: number;
  78871. frontUVs?: Vector4;
  78872. backUVs?: Vector4;
  78873. }): VertexData;
  78874. /**
  78875. * Compute normals for given positions and indices
  78876. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78877. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78878. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78879. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78880. * * facetNormals : optional array of facet normals (vector3)
  78881. * * facetPositions : optional array of facet positions (vector3)
  78882. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78883. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78884. * * bInfo : optional bounding info, required for facetPartitioning computation
  78885. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78886. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78887. * * useRightHandedSystem: optional boolean to for right handed system computation
  78888. * * depthSort : optional boolean to enable the facet depth sort computation
  78889. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78890. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78891. */
  78892. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78893. facetNormals?: any;
  78894. facetPositions?: any;
  78895. facetPartitioning?: any;
  78896. ratio?: number;
  78897. bInfo?: any;
  78898. bbSize?: Vector3;
  78899. subDiv?: any;
  78900. useRightHandedSystem?: boolean;
  78901. depthSort?: boolean;
  78902. distanceTo?: Vector3;
  78903. depthSortedFacets?: any;
  78904. }): void;
  78905. private static _ComputeSides;
  78906. /**
  78907. * Applies VertexData created from the imported parameters to the geometry
  78908. * @param parsedVertexData the parsed data from an imported file
  78909. * @param geometry the geometry to apply the VertexData to
  78910. */
  78911. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78912. }
  78913. }
  78914. declare module BABYLON {
  78915. /**
  78916. * Polygon
  78917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78918. */
  78919. export class Polygon {
  78920. /**
  78921. * Creates a rectangle
  78922. * @param xmin bottom X coord
  78923. * @param ymin bottom Y coord
  78924. * @param xmax top X coord
  78925. * @param ymax top Y coord
  78926. * @returns points that make the resulting rectation
  78927. */
  78928. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  78929. /**
  78930. * Creates a circle
  78931. * @param radius radius of circle
  78932. * @param cx scale in x
  78933. * @param cy scale in y
  78934. * @param numberOfSides number of sides that make up the circle
  78935. * @returns points that make the resulting circle
  78936. */
  78937. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  78938. /**
  78939. * Creates a polygon from input string
  78940. * @param input Input polygon data
  78941. * @returns the parsed points
  78942. */
  78943. static Parse(input: string): Vector2[];
  78944. /**
  78945. * Starts building a polygon from x and y coordinates
  78946. * @param x x coordinate
  78947. * @param y y coordinate
  78948. * @returns the started path2
  78949. */
  78950. static StartingAt(x: number, y: number): Path2;
  78951. }
  78952. /**
  78953. * Builds a polygon
  78954. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  78955. */
  78956. export class PolygonMeshBuilder {
  78957. private _points;
  78958. private _outlinepoints;
  78959. private _holes;
  78960. private _name;
  78961. private _scene;
  78962. private _epoints;
  78963. private _eholes;
  78964. private _addToepoint;
  78965. /**
  78966. * Babylon reference to the earcut plugin.
  78967. */
  78968. bjsEarcut: any;
  78969. /**
  78970. * Creates a PolygonMeshBuilder
  78971. * @param name name of the builder
  78972. * @param contours Path of the polygon
  78973. * @param scene scene to add to
  78974. */
  78975. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  78976. /**
  78977. * Adds a whole within the polygon
  78978. * @param hole Array of points defining the hole
  78979. * @returns this
  78980. */
  78981. addHole(hole: Vector2[]): PolygonMeshBuilder;
  78982. /**
  78983. * Creates the polygon
  78984. * @param updatable If the mesh should be updatable
  78985. * @param depth The depth of the mesh created
  78986. * @returns the created mesh
  78987. */
  78988. build(updatable?: boolean, depth?: number): Mesh;
  78989. /**
  78990. * Adds a side to the polygon
  78991. * @param positions points that make the polygon
  78992. * @param normals normals of the polygon
  78993. * @param uvs uvs of the polygon
  78994. * @param indices indices of the polygon
  78995. * @param bounds bounds of the polygon
  78996. * @param points points of the polygon
  78997. * @param depth depth of the polygon
  78998. * @param flip flip of the polygon
  78999. */
  79000. private addSide;
  79001. }
  79002. }
  79003. declare module BABYLON {
  79004. /**
  79005. * Class containing static functions to help procedurally build meshes
  79006. */
  79007. export class MeshBuilder {
  79008. private static _UpdateSideOrientation;
  79009. /**
  79010. * Creates a box mesh
  79011. * * The parameter `size` sets the size (float) of each box side (default 1)
  79012. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  79013. * * 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)
  79014. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  79015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  79019. * @param name defines the name of the mesh
  79020. * @param options defines the options used to create the mesh
  79021. * @param scene defines the hosting scene
  79022. * @returns the box mesh
  79023. */
  79024. static CreateBox(name: string, options: {
  79025. size?: number;
  79026. width?: number;
  79027. height?: number;
  79028. depth?: number;
  79029. faceUV?: Vector4[];
  79030. faceColors?: Color4[];
  79031. sideOrientation?: number;
  79032. frontUVs?: Vector4;
  79033. backUVs?: Vector4;
  79034. updatable?: boolean;
  79035. }, scene?: Nullable<Scene>): Mesh;
  79036. /**
  79037. * Creates a sphere mesh
  79038. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  79039. * * 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`)
  79040. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  79041. * * 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
  79042. * * 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)
  79043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79046. * @param name defines the name of the mesh
  79047. * @param options defines the options used to create the mesh
  79048. * @param scene defines the hosting scene
  79049. * @returns the sphere mesh
  79050. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  79051. */
  79052. static CreateSphere(name: string, options: {
  79053. segments?: number;
  79054. diameter?: number;
  79055. diameterX?: number;
  79056. diameterY?: number;
  79057. diameterZ?: number;
  79058. arc?: number;
  79059. slice?: number;
  79060. sideOrientation?: number;
  79061. frontUVs?: Vector4;
  79062. backUVs?: Vector4;
  79063. updatable?: boolean;
  79064. }, scene: any): Mesh;
  79065. /**
  79066. * Creates a plane polygonal mesh. By default, this is a disc
  79067. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79068. * * 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
  79069. * * 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
  79070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79073. * @param name defines the name of the mesh
  79074. * @param options defines the options used to create the mesh
  79075. * @param scene defines the hosting scene
  79076. * @returns the plane polygonal mesh
  79077. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79078. */
  79079. static CreateDisc(name: string, options: {
  79080. radius?: number;
  79081. tessellation?: number;
  79082. arc?: number;
  79083. updatable?: boolean;
  79084. sideOrientation?: number;
  79085. frontUVs?: Vector4;
  79086. backUVs?: Vector4;
  79087. }, scene?: Nullable<Scene>): Mesh;
  79088. /**
  79089. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79090. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79091. * * 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`)
  79092. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79093. * * 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
  79094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79097. * @param name defines the name of the mesh
  79098. * @param options defines the options used to create the mesh
  79099. * @param scene defines the hosting scene
  79100. * @returns the icosahedron mesh
  79101. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79102. */
  79103. static CreateIcoSphere(name: string, options: {
  79104. radius?: number;
  79105. radiusX?: number;
  79106. radiusY?: number;
  79107. radiusZ?: number;
  79108. flat?: boolean;
  79109. subdivisions?: number;
  79110. sideOrientation?: number;
  79111. frontUVs?: Vector4;
  79112. backUVs?: Vector4;
  79113. updatable?: boolean;
  79114. }, scene: Scene): Mesh;
  79115. /**
  79116. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79117. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  79118. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  79119. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  79120. * * 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
  79121. * * 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
  79122. * * 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
  79123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79126. * * 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
  79127. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  79128. * * 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
  79129. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  79130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79131. * @param name defines the name of the mesh
  79132. * @param options defines the options used to create the mesh
  79133. * @param scene defines the hosting scene
  79134. * @returns the ribbon mesh
  79135. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  79136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79137. */
  79138. static CreateRibbon(name: string, options: {
  79139. pathArray: Vector3[][];
  79140. closeArray?: boolean;
  79141. closePath?: boolean;
  79142. offset?: number;
  79143. updatable?: boolean;
  79144. sideOrientation?: number;
  79145. frontUVs?: Vector4;
  79146. backUVs?: Vector4;
  79147. instance?: Mesh;
  79148. invertUV?: boolean;
  79149. uvs?: Vector2[];
  79150. colors?: Color4[];
  79151. }, scene?: Nullable<Scene>): Mesh;
  79152. /**
  79153. * Creates a cylinder or a cone mesh
  79154. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  79155. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  79156. * * 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.
  79157. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  79158. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  79159. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  79160. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  79161. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  79162. * * 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).
  79163. * * 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
  79164. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  79165. * * 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
  79166. * * 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.
  79167. * * If `enclose` is false, a ring surface is one element.
  79168. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  79169. * * 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
  79170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79173. * @param name defines the name of the mesh
  79174. * @param options defines the options used to create the mesh
  79175. * @param scene defines the hosting scene
  79176. * @returns the cylinder mesh
  79177. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  79178. */
  79179. static CreateCylinder(name: string, options: {
  79180. height?: number;
  79181. diameterTop?: number;
  79182. diameterBottom?: number;
  79183. diameter?: number;
  79184. tessellation?: number;
  79185. subdivisions?: number;
  79186. arc?: number;
  79187. faceColors?: Color4[];
  79188. faceUV?: Vector4[];
  79189. updatable?: boolean;
  79190. hasRings?: boolean;
  79191. enclose?: boolean;
  79192. sideOrientation?: number;
  79193. frontUVs?: Vector4;
  79194. backUVs?: Vector4;
  79195. }, scene: any): Mesh;
  79196. /**
  79197. * Creates a torus mesh
  79198. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  79199. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  79200. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  79201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79204. * @param name defines the name of the mesh
  79205. * @param options defines the options used to create the mesh
  79206. * @param scene defines the hosting scene
  79207. * @returns the torus mesh
  79208. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  79209. */
  79210. static CreateTorus(name: string, options: {
  79211. diameter?: number;
  79212. thickness?: number;
  79213. tessellation?: number;
  79214. updatable?: boolean;
  79215. sideOrientation?: number;
  79216. frontUVs?: Vector4;
  79217. backUVs?: Vector4;
  79218. }, scene: any): Mesh;
  79219. /**
  79220. * Creates a torus knot mesh
  79221. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  79222. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  79223. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  79224. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  79225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79228. * @param name defines the name of the mesh
  79229. * @param options defines the options used to create the mesh
  79230. * @param scene defines the hosting scene
  79231. * @returns the torus knot mesh
  79232. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  79233. */
  79234. static CreateTorusKnot(name: string, options: {
  79235. radius?: number;
  79236. tube?: number;
  79237. radialSegments?: number;
  79238. tubularSegments?: number;
  79239. p?: number;
  79240. q?: number;
  79241. updatable?: boolean;
  79242. sideOrientation?: number;
  79243. frontUVs?: Vector4;
  79244. backUVs?: Vector4;
  79245. }, scene: any): Mesh;
  79246. /**
  79247. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  79248. * * 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
  79249. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  79250. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  79251. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  79252. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  79253. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  79254. * * 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
  79255. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  79256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  79258. * @param name defines the name of the new line system
  79259. * @param options defines the options used to create the line system
  79260. * @param scene defines the hosting scene
  79261. * @returns a new line system mesh
  79262. */
  79263. static CreateLineSystem(name: string, options: {
  79264. lines: Vector3[][];
  79265. updatable?: boolean;
  79266. instance?: Nullable<LinesMesh>;
  79267. colors?: Nullable<Color4[][]>;
  79268. useVertexAlpha?: boolean;
  79269. }, scene: Nullable<Scene>): LinesMesh;
  79270. /**
  79271. * Creates a line mesh
  79272. * 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
  79273. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79274. * * The parameter `points` is an array successive Vector3
  79275. * * 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
  79276. * * The optional parameter `colors` is an array of successive Color4, one per line point
  79277. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  79278. * * When updating an instance, remember that only point positions can change, not the number of points
  79279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  79281. * @param name defines the name of the new line system
  79282. * @param options defines the options used to create the line system
  79283. * @param scene defines the hosting scene
  79284. * @returns a new line mesh
  79285. */
  79286. static CreateLines(name: string, options: {
  79287. points: Vector3[];
  79288. updatable?: boolean;
  79289. instance?: Nullable<LinesMesh>;
  79290. colors?: Color4[];
  79291. useVertexAlpha?: boolean;
  79292. }, scene?: Nullable<Scene>): LinesMesh;
  79293. /**
  79294. * Creates a dashed line mesh
  79295. * * 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
  79296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79297. * * The parameter `points` is an array successive Vector3
  79298. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  79299. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  79300. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79301. * * 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
  79302. * * When updating an instance, remember that only point positions can change, not the number of points
  79303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79304. * @param name defines the name of the mesh
  79305. * @param options defines the options used to create the mesh
  79306. * @param scene defines the hosting scene
  79307. * @returns the dashed line mesh
  79308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  79309. */
  79310. static CreateDashedLines(name: string, options: {
  79311. points: Vector3[];
  79312. dashSize?: number;
  79313. gapSize?: number;
  79314. dashNb?: number;
  79315. updatable?: boolean;
  79316. instance?: LinesMesh;
  79317. }, scene?: Nullable<Scene>): LinesMesh;
  79318. /**
  79319. * 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.
  79320. * * 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.
  79321. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79322. * * 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.
  79323. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  79324. * * 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
  79325. * * 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
  79326. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  79327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  79330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79331. * @param name defines the name of the mesh
  79332. * @param options defines the options used to create the mesh
  79333. * @param scene defines the hosting scene
  79334. * @returns the extruded shape mesh
  79335. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79337. */
  79338. static ExtrudeShape(name: string, options: {
  79339. shape: Vector3[];
  79340. path: Vector3[];
  79341. scale?: number;
  79342. rotation?: number;
  79343. cap?: number;
  79344. updatable?: boolean;
  79345. sideOrientation?: number;
  79346. frontUVs?: Vector4;
  79347. backUVs?: Vector4;
  79348. instance?: Mesh;
  79349. invertUV?: boolean;
  79350. }, scene?: Nullable<Scene>): Mesh;
  79351. /**
  79352. * Creates an custom extruded shape mesh.
  79353. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  79354. * * 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.
  79355. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  79356. * * 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
  79357. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  79358. * * 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
  79359. * * It must returns a float value that will be the scale value applied to the shape on each path point
  79360. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79361. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  79362. * * 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
  79363. * * 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
  79364. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  79365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79369. * @param name defines the name of the mesh
  79370. * @param options defines the options used to create the mesh
  79371. * @param scene defines the hosting scene
  79372. * @returns the custom extruded shape mesh
  79373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  79374. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79376. */
  79377. static ExtrudeShapeCustom(name: string, options: {
  79378. shape: Vector3[];
  79379. path: Vector3[];
  79380. scaleFunction?: any;
  79381. rotationFunction?: any;
  79382. ribbonCloseArray?: boolean;
  79383. ribbonClosePath?: boolean;
  79384. cap?: number;
  79385. updatable?: boolean;
  79386. sideOrientation?: number;
  79387. frontUVs?: Vector4;
  79388. backUVs?: Vector4;
  79389. instance?: Mesh;
  79390. invertUV?: boolean;
  79391. }, scene: Scene): Mesh;
  79392. /**
  79393. * Creates lathe mesh.
  79394. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  79395. * * 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
  79396. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  79397. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  79398. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  79399. * * 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
  79400. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  79401. * * 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
  79402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79406. * @param name defines the name of the mesh
  79407. * @param options defines the options used to create the mesh
  79408. * @param scene defines the hosting scene
  79409. * @returns the lathe mesh
  79410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  79411. */
  79412. static CreateLathe(name: string, options: {
  79413. shape: Vector3[];
  79414. radius?: number;
  79415. tessellation?: number;
  79416. clip?: number;
  79417. arc?: number;
  79418. closed?: boolean;
  79419. updatable?: boolean;
  79420. sideOrientation?: number;
  79421. frontUVs?: Vector4;
  79422. backUVs?: Vector4;
  79423. cap?: number;
  79424. invertUV?: boolean;
  79425. }, scene: Scene): Mesh;
  79426. /**
  79427. * Creates a plane mesh
  79428. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  79429. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  79430. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  79431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79434. * @param name defines the name of the mesh
  79435. * @param options defines the options used to create the mesh
  79436. * @param scene defines the hosting scene
  79437. * @returns the plane mesh
  79438. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  79439. */
  79440. static CreatePlane(name: string, options: {
  79441. size?: number;
  79442. width?: number;
  79443. height?: number;
  79444. sideOrientation?: number;
  79445. frontUVs?: Vector4;
  79446. backUVs?: Vector4;
  79447. updatable?: boolean;
  79448. sourcePlane?: Plane;
  79449. }, scene: Scene): Mesh;
  79450. /**
  79451. * Creates a ground mesh
  79452. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  79453. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  79454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79455. * @param name defines the name of the mesh
  79456. * @param options defines the options used to create the mesh
  79457. * @param scene defines the hosting scene
  79458. * @returns the ground mesh
  79459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  79460. */
  79461. static CreateGround(name: string, options: {
  79462. width?: number;
  79463. height?: number;
  79464. subdivisions?: number;
  79465. subdivisionsX?: number;
  79466. subdivisionsY?: number;
  79467. updatable?: boolean;
  79468. }, scene: any): Mesh;
  79469. /**
  79470. * Creates a tiled ground mesh
  79471. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  79472. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  79473. * * 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
  79474. * * 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
  79475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79476. * @param name defines the name of the mesh
  79477. * @param options defines the options used to create the mesh
  79478. * @param scene defines the hosting scene
  79479. * @returns the tiled ground mesh
  79480. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79481. */
  79482. static CreateTiledGround(name: string, options: {
  79483. xmin: number;
  79484. zmin: number;
  79485. xmax: number;
  79486. zmax: number;
  79487. subdivisions?: {
  79488. w: number;
  79489. h: number;
  79490. };
  79491. precision?: {
  79492. w: number;
  79493. h: number;
  79494. };
  79495. updatable?: boolean;
  79496. }, scene: Scene): Mesh;
  79497. /**
  79498. * Creates a ground mesh from a height map
  79499. * * The parameter `url` sets the URL of the height map image resource.
  79500. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  79501. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  79502. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  79503. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  79504. * * 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.
  79505. * * 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).
  79506. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79508. * @param name defines the name of the mesh
  79509. * @param url defines the url to the height map
  79510. * @param options defines the options used to create the mesh
  79511. * @param scene defines the hosting scene
  79512. * @returns the ground mesh
  79513. * @see https://doc.babylonjs.com/babylon101/height_map
  79514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  79515. */
  79516. static CreateGroundFromHeightMap(name: string, url: string, options: {
  79517. width?: number;
  79518. height?: number;
  79519. subdivisions?: number;
  79520. minHeight?: number;
  79521. maxHeight?: number;
  79522. colorFilter?: Color3;
  79523. alphaFilter?: number;
  79524. updatable?: boolean;
  79525. onReady?: (mesh: GroundMesh) => void;
  79526. }, scene: Scene): GroundMesh;
  79527. /**
  79528. * Creates a polygon mesh
  79529. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  79530. * * 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
  79531. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  79534. * * Remember you can only change the shape positions, not their number when updating a polygon
  79535. * @param name defines the name of the mesh
  79536. * @param options defines the options used to create the mesh
  79537. * @param scene defines the hosting scene
  79538. * @returns the polygon mesh
  79539. */
  79540. static CreatePolygon(name: string, options: {
  79541. shape: Vector3[];
  79542. holes?: Vector3[][];
  79543. depth?: number;
  79544. faceUV?: Vector4[];
  79545. faceColors?: Color4[];
  79546. updatable?: boolean;
  79547. sideOrientation?: number;
  79548. frontUVs?: Vector4;
  79549. backUVs?: Vector4;
  79550. }, scene: Scene): Mesh;
  79551. /**
  79552. * Creates an extruded polygon mesh, with depth in the Y direction.
  79553. * * 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)
  79554. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  79555. * @param name defines the name of the mesh
  79556. * @param options defines the options used to create the mesh
  79557. * @param scene defines the hosting scene
  79558. * @returns the polygon mesh
  79559. */
  79560. static ExtrudePolygon(name: string, options: {
  79561. shape: Vector3[];
  79562. holes?: Vector3[][];
  79563. depth?: number;
  79564. faceUV?: Vector4[];
  79565. faceColors?: Color4[];
  79566. updatable?: boolean;
  79567. sideOrientation?: number;
  79568. frontUVs?: Vector4;
  79569. backUVs?: Vector4;
  79570. }, scene: Scene): Mesh;
  79571. /**
  79572. * Creates a tube mesh.
  79573. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  79574. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  79575. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  79576. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  79577. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  79578. * * 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)
  79579. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  79580. * * 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
  79581. * * 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
  79582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79586. * @param name defines the name of the mesh
  79587. * @param options defines the options used to create the mesh
  79588. * @param scene defines the hosting scene
  79589. * @returns the tube mesh
  79590. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  79591. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  79592. */
  79593. static CreateTube(name: string, options: {
  79594. path: Vector3[];
  79595. radius?: number;
  79596. tessellation?: number;
  79597. radiusFunction?: {
  79598. (i: number, distance: number): number;
  79599. };
  79600. cap?: number;
  79601. arc?: number;
  79602. updatable?: boolean;
  79603. sideOrientation?: number;
  79604. frontUVs?: Vector4;
  79605. backUVs?: Vector4;
  79606. instance?: Mesh;
  79607. invertUV?: boolean;
  79608. }, scene: Scene): Mesh;
  79609. /**
  79610. * Creates a polyhedron mesh
  79611. * * 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
  79612. * * The parameter `size` (positive float, default 1) sets the polygon size
  79613. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79614. * * 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`
  79615. * * 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
  79616. * * 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)`)
  79617. * * 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
  79618. * * 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
  79619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79622. * @param name defines the name of the mesh
  79623. * @param options defines the options used to create the mesh
  79624. * @param scene defines the hosting scene
  79625. * @returns the polyhedron mesh
  79626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  79627. */
  79628. static CreatePolyhedron(name: string, options: {
  79629. type?: number;
  79630. size?: number;
  79631. sizeX?: number;
  79632. sizeY?: number;
  79633. sizeZ?: number;
  79634. custom?: any;
  79635. faceUV?: Vector4[];
  79636. faceColors?: Color4[];
  79637. flat?: boolean;
  79638. updatable?: boolean;
  79639. sideOrientation?: number;
  79640. frontUVs?: Vector4;
  79641. backUVs?: Vector4;
  79642. }, scene: Scene): Mesh;
  79643. /**
  79644. * Creates a decal mesh.
  79645. * 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
  79646. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  79647. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  79648. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  79649. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  79650. * @param name defines the name of the mesh
  79651. * @param sourceMesh defines the mesh where the decal must be applied
  79652. * @param options defines the options used to create the mesh
  79653. * @param scene defines the hosting scene
  79654. * @returns the decal mesh
  79655. * @see https://doc.babylonjs.com/how_to/decals
  79656. */
  79657. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  79658. position?: Vector3;
  79659. normal?: Vector3;
  79660. size?: Vector3;
  79661. angle?: number;
  79662. }): Mesh;
  79663. private static _ExtrudeShapeGeneric;
  79664. }
  79665. }
  79666. declare module BABYLON {
  79667. /**
  79668. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  79669. *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.
  79670. * The SPS is also a particle system. It provides some methods to manage the particles.
  79671. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  79672. *
  79673. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  79674. */
  79675. export class SolidParticleSystem implements IDisposable {
  79676. /**
  79677. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  79678. * Example : var p = SPS.particles[i];
  79679. */
  79680. particles: SolidParticle[];
  79681. /**
  79682. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  79683. */
  79684. nbParticles: number;
  79685. /**
  79686. * If the particles must ever face the camera (default false). Useful for planar particles.
  79687. */
  79688. billboard: boolean;
  79689. /**
  79690. * Recompute normals when adding a shape
  79691. */
  79692. recomputeNormals: boolean;
  79693. /**
  79694. * This a counter ofr your own usage. It's not set by any SPS functions.
  79695. */
  79696. counter: number;
  79697. /**
  79698. * The SPS name. This name is also given to the underlying mesh.
  79699. */
  79700. name: string;
  79701. /**
  79702. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  79703. */
  79704. mesh: Mesh;
  79705. /**
  79706. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  79707. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  79708. */
  79709. vars: any;
  79710. /**
  79711. * This array is populated when the SPS is set as 'pickable'.
  79712. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  79713. * Each element of this array is an object `{idx: int, faceId: int}`.
  79714. * `idx` is the picked particle index in the `SPS.particles` array
  79715. * `faceId` is the picked face index counted within this particle.
  79716. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  79717. */
  79718. pickedParticles: {
  79719. idx: number;
  79720. faceId: number;
  79721. }[];
  79722. /**
  79723. * This array is populated when `enableDepthSort` is set to true.
  79724. * Each element of this array is an instance of the class DepthSortedParticle.
  79725. */
  79726. depthSortedParticles: DepthSortedParticle[];
  79727. /**
  79728. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  79729. * @hidden
  79730. */
  79731. _bSphereOnly: boolean;
  79732. /**
  79733. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  79734. * @hidden
  79735. */
  79736. _bSphereRadiusFactor: number;
  79737. private _scene;
  79738. private _positions;
  79739. private _indices;
  79740. private _normals;
  79741. private _colors;
  79742. private _uvs;
  79743. private _indices32;
  79744. private _positions32;
  79745. private _normals32;
  79746. private _fixedNormal32;
  79747. private _colors32;
  79748. private _uvs32;
  79749. private _index;
  79750. private _updatable;
  79751. private _pickable;
  79752. private _isVisibilityBoxLocked;
  79753. private _alwaysVisible;
  79754. private _depthSort;
  79755. private _shapeCounter;
  79756. private _copy;
  79757. private _color;
  79758. private _computeParticleColor;
  79759. private _computeParticleTexture;
  79760. private _computeParticleRotation;
  79761. private _computeParticleVertex;
  79762. private _computeBoundingBox;
  79763. private _depthSortParticles;
  79764. private _camera;
  79765. private _mustUnrotateFixedNormals;
  79766. private _particlesIntersect;
  79767. private _needs32Bits;
  79768. /**
  79769. * Creates a SPS (Solid Particle System) object.
  79770. * @param name (String) is the SPS name, this will be the underlying mesh name.
  79771. * @param scene (Scene) is the scene in which the SPS is added.
  79772. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  79773. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  79774. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  79775. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  79776. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  79777. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  79778. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  79779. */
  79780. constructor(name: string, scene: Scene, options?: {
  79781. updatable?: boolean;
  79782. isPickable?: boolean;
  79783. enableDepthSort?: boolean;
  79784. particleIntersection?: boolean;
  79785. boundingSphereOnly?: boolean;
  79786. bSphereRadiusFactor?: number;
  79787. });
  79788. /**
  79789. * Builds the SPS underlying mesh. Returns a standard Mesh.
  79790. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  79791. * @returns the created mesh
  79792. */
  79793. buildMesh(): Mesh;
  79794. /**
  79795. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  79796. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  79797. * Thus the particles generated from `digest()` have their property `position` set yet.
  79798. * @param mesh ( Mesh ) is the mesh to be digested
  79799. * @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
  79800. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  79801. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  79802. * @returns the current SPS
  79803. */
  79804. digest(mesh: Mesh, options?: {
  79805. facetNb?: number;
  79806. number?: number;
  79807. delta?: number;
  79808. }): SolidParticleSystem;
  79809. private _unrotateFixedNormals;
  79810. private _resetCopy;
  79811. private _meshBuilder;
  79812. private _posToShape;
  79813. private _uvsToShapeUV;
  79814. private _addParticle;
  79815. /**
  79816. * Adds some particles to the SPS from the model shape. Returns the shape id.
  79817. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  79818. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  79819. * @param nb (positive integer) the number of particles to be created from this model
  79820. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  79821. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  79822. * @returns the number of shapes in the system
  79823. */
  79824. addShape(mesh: Mesh, nb: number, options?: {
  79825. positionFunction?: any;
  79826. vertexFunction?: any;
  79827. }): number;
  79828. private _rebuildParticle;
  79829. /**
  79830. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  79831. * @returns the SPS.
  79832. */
  79833. rebuildMesh(): SolidParticleSystem;
  79834. /**
  79835. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  79836. * This method calls `updateParticle()` for each particle of the SPS.
  79837. * For an animated SPS, it is usually called within the render loop.
  79838. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  79839. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  79840. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  79841. * @returns the SPS.
  79842. */
  79843. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  79844. /**
  79845. * Disposes the SPS.
  79846. */
  79847. dispose(): void;
  79848. /**
  79849. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  79850. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79851. * @returns the SPS.
  79852. */
  79853. refreshVisibleSize(): SolidParticleSystem;
  79854. /**
  79855. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  79856. * @param size the size (float) of the visibility box
  79857. * note : this doesn't lock the SPS mesh bounding box.
  79858. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79859. */
  79860. setVisibilityBox(size: number): void;
  79861. /**
  79862. * Gets whether the SPS as always visible or not
  79863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79864. */
  79865. /**
  79866. * Sets the SPS as always visible or not
  79867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79868. */
  79869. isAlwaysVisible: boolean;
  79870. /**
  79871. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79873. */
  79874. /**
  79875. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79877. */
  79878. isVisibilityBoxLocked: boolean;
  79879. /**
  79880. * Tells to `setParticles()` to compute the particle rotations or not.
  79881. * Default value : true. The SPS is faster when it's set to false.
  79882. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79883. */
  79884. /**
  79885. * Gets if `setParticles()` computes the particle rotations or not.
  79886. * Default value : true. The SPS is faster when it's set to false.
  79887. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79888. */
  79889. computeParticleRotation: boolean;
  79890. /**
  79891. * Tells to `setParticles()` to compute the particle colors or not.
  79892. * Default value : true. The SPS is faster when it's set to false.
  79893. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79894. */
  79895. /**
  79896. * Gets if `setParticles()` computes the particle colors or not.
  79897. * Default value : true. The SPS is faster when it's set to false.
  79898. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79899. */
  79900. computeParticleColor: boolean;
  79901. /**
  79902. * Gets if `setParticles()` computes the particle textures or not.
  79903. * Default value : true. The SPS is faster when it's set to false.
  79904. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  79905. */
  79906. computeParticleTexture: boolean;
  79907. /**
  79908. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  79909. * Default value : false. The SPS is faster when it's set to false.
  79910. * Note : the particle custom vertex positions aren't stored values.
  79911. */
  79912. /**
  79913. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  79914. * Default value : false. The SPS is faster when it's set to false.
  79915. * Note : the particle custom vertex positions aren't stored values.
  79916. */
  79917. computeParticleVertex: boolean;
  79918. /**
  79919. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  79920. */
  79921. /**
  79922. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  79923. */
  79924. computeBoundingBox: boolean;
  79925. /**
  79926. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  79927. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79928. * Default : `true`
  79929. */
  79930. /**
  79931. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  79932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79933. * Default : `true`
  79934. */
  79935. depthSortParticles: boolean;
  79936. /**
  79937. * This function does nothing. It may be overwritten to set all the particle first values.
  79938. * The SPS doesn't call this function, you may have to call it by your own.
  79939. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79940. */
  79941. initParticles(): void;
  79942. /**
  79943. * This function does nothing. It may be overwritten to recycle a particle.
  79944. * The SPS doesn't call this function, you may have to call it by your own.
  79945. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79946. * @param particle The particle to recycle
  79947. * @returns the recycled particle
  79948. */
  79949. recycleParticle(particle: SolidParticle): SolidParticle;
  79950. /**
  79951. * Updates a particle : this function should be overwritten by the user.
  79952. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  79953. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79954. * @example : just set a particle position or velocity and recycle conditions
  79955. * @param particle The particle to update
  79956. * @returns the updated particle
  79957. */
  79958. updateParticle(particle: SolidParticle): SolidParticle;
  79959. /**
  79960. * Updates a vertex of a particle : it can be overwritten by the user.
  79961. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  79962. * @param particle the current particle
  79963. * @param vertex the current index of the current particle
  79964. * @param pt the index of the current vertex in the particle shape
  79965. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  79966. * @example : just set a vertex particle position
  79967. * @returns the updated vertex
  79968. */
  79969. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  79970. /**
  79971. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  79972. * This does nothing and may be overwritten by the user.
  79973. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79974. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79975. * @param update the boolean update value actually passed to setParticles()
  79976. */
  79977. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79978. /**
  79979. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  79980. * This will be passed three parameters.
  79981. * This does nothing and may be overwritten by the user.
  79982. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79983. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79984. * @param update the boolean update value actually passed to setParticles()
  79985. */
  79986. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79987. }
  79988. }
  79989. declare module BABYLON {
  79990. /**
  79991. * Represents one particle of a solid particle system.
  79992. */
  79993. export class SolidParticle {
  79994. /**
  79995. * particle global index
  79996. */
  79997. idx: number;
  79998. /**
  79999. * The color of the particle
  80000. */
  80001. color: Nullable<Color4>;
  80002. /**
  80003. * The world space position of the particle.
  80004. */
  80005. position: Vector3;
  80006. /**
  80007. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80008. */
  80009. rotation: Vector3;
  80010. /**
  80011. * The world space rotation quaternion of the particle.
  80012. */
  80013. rotationQuaternion: Nullable<Quaternion>;
  80014. /**
  80015. * The scaling of the particle.
  80016. */
  80017. scaling: Vector3;
  80018. /**
  80019. * The uvs of the particle.
  80020. */
  80021. uvs: Vector4;
  80022. /**
  80023. * The current speed of the particle.
  80024. */
  80025. velocity: Vector3;
  80026. /**
  80027. * The pivot point in the particle local space.
  80028. */
  80029. pivot: Vector3;
  80030. /**
  80031. * Must the particle be translated from its pivot point in its local space ?
  80032. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80033. * Default : false
  80034. */
  80035. translateFromPivot: boolean;
  80036. /**
  80037. * Is the particle active or not ?
  80038. */
  80039. alive: boolean;
  80040. /**
  80041. * Is the particle visible or not ?
  80042. */
  80043. isVisible: boolean;
  80044. /**
  80045. * Index of this particle in the global "positions" array (Internal use)
  80046. * @hidden
  80047. */
  80048. _pos: number;
  80049. /**
  80050. * @hidden Index of this particle in the global "indices" array (Internal use)
  80051. */
  80052. _ind: number;
  80053. /**
  80054. * @hidden ModelShape of this particle (Internal use)
  80055. */
  80056. _model: ModelShape;
  80057. /**
  80058. * ModelShape id of this particle
  80059. */
  80060. shapeId: number;
  80061. /**
  80062. * Index of the particle in its shape id (Internal use)
  80063. */
  80064. idxInShape: number;
  80065. /**
  80066. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80067. */
  80068. _modelBoundingInfo: BoundingInfo;
  80069. /**
  80070. * @hidden Particle BoundingInfo object (Internal use)
  80071. */
  80072. _boundingInfo: BoundingInfo;
  80073. /**
  80074. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80075. */
  80076. _sps: SolidParticleSystem;
  80077. /**
  80078. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80079. */
  80080. _stillInvisible: boolean;
  80081. /**
  80082. * @hidden Last computed particle rotation matrix
  80083. */
  80084. _rotationMatrix: number[];
  80085. /**
  80086. * Parent particle Id, if any.
  80087. * Default null.
  80088. */
  80089. parentId: Nullable<number>;
  80090. /**
  80091. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80092. * The possible values are :
  80093. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80094. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80095. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80096. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80097. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80098. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80099. * */
  80100. cullingStrategy: number;
  80101. /**
  80102. * @hidden Internal global position in the SPS.
  80103. */
  80104. _globalPosition: Vector3;
  80105. /**
  80106. * Creates a Solid Particle object.
  80107. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80108. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80109. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80110. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80111. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80112. * @param shapeId (integer) is the model shape identifier in the SPS.
  80113. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80114. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80115. */
  80116. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80117. /**
  80118. * Legacy support, changed scale to scaling
  80119. */
  80120. /**
  80121. * Legacy support, changed scale to scaling
  80122. */
  80123. scale: Vector3;
  80124. /**
  80125. * Legacy support, changed quaternion to rotationQuaternion
  80126. */
  80127. /**
  80128. * Legacy support, changed quaternion to rotationQuaternion
  80129. */
  80130. quaternion: Nullable<Quaternion>;
  80131. /**
  80132. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80133. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80134. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80135. * @returns true if it intersects
  80136. */
  80137. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80138. /**
  80139. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80140. * A particle is in the frustum if its bounding box intersects the frustum
  80141. * @param frustumPlanes defines the frustum to test
  80142. * @returns true if the particle is in the frustum planes
  80143. */
  80144. isInFrustum(frustumPlanes: Plane[]): boolean;
  80145. /**
  80146. * get the rotation matrix of the particle
  80147. * @hidden
  80148. */
  80149. getRotationMatrix(m: Matrix): void;
  80150. }
  80151. /**
  80152. * Represents the shape of the model used by one particle of a solid particle system.
  80153. * SPS internal tool, don't use it manually.
  80154. */
  80155. export class ModelShape {
  80156. /**
  80157. * The shape id
  80158. * @hidden
  80159. */
  80160. shapeID: number;
  80161. /**
  80162. * flat array of model positions (internal use)
  80163. * @hidden
  80164. */
  80165. _shape: Vector3[];
  80166. /**
  80167. * flat array of model UVs (internal use)
  80168. * @hidden
  80169. */
  80170. _shapeUV: number[];
  80171. /**
  80172. * length of the shape in the model indices array (internal use)
  80173. * @hidden
  80174. */
  80175. _indicesLength: number;
  80176. /**
  80177. * Custom position function (internal use)
  80178. * @hidden
  80179. */
  80180. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80181. /**
  80182. * Custom vertex function (internal use)
  80183. * @hidden
  80184. */
  80185. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80186. /**
  80187. * 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.
  80188. * SPS internal tool, don't use it manually.
  80189. * @hidden
  80190. */
  80191. 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>);
  80192. }
  80193. /**
  80194. * Represents a Depth Sorted Particle in the solid particle system.
  80195. */
  80196. export class DepthSortedParticle {
  80197. /**
  80198. * Index of the particle in the "indices" array
  80199. */
  80200. ind: number;
  80201. /**
  80202. * Length of the particle shape in the "indices" array
  80203. */
  80204. indicesLength: number;
  80205. /**
  80206. * Squared distance from the particle to the camera
  80207. */
  80208. sqDistance: number;
  80209. }
  80210. }
  80211. declare module BABYLON {
  80212. /**
  80213. * Class used to store all common mesh properties
  80214. */
  80215. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80216. /** No occlusion */
  80217. static OCCLUSION_TYPE_NONE: number;
  80218. /** Occlusion set to optimisitic */
  80219. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80220. /** Occlusion set to strict */
  80221. static OCCLUSION_TYPE_STRICT: number;
  80222. /** Use an accurante occlusion algorithm */
  80223. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80224. /** Use a conservative occlusion algorithm */
  80225. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80226. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80227. * Test order :
  80228. * Is the bounding sphere outside the frustum ?
  80229. * If not, are the bounding box vertices outside the frustum ?
  80230. * It not, then the cullable object is in the frustum.
  80231. */
  80232. static readonly CULLINGSTRATEGY_STANDARD: number;
  80233. /** Culling strategy : Bounding Sphere Only.
  80234. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80235. * It's also less accurate than the standard because some not visible objects can still be selected.
  80236. * Test : is the bounding sphere outside the frustum ?
  80237. * If not, then the cullable object is in the frustum.
  80238. */
  80239. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80240. /** Culling strategy : Optimistic Inclusion.
  80241. * This in an inclusion test first, then the standard exclusion test.
  80242. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80243. * 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.
  80244. * Anyway, it's as accurate as the standard strategy.
  80245. * Test :
  80246. * Is the cullable object bounding sphere center in the frustum ?
  80247. * If not, apply the default culling strategy.
  80248. */
  80249. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80250. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80251. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80252. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80253. * 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.
  80254. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80255. * Test :
  80256. * Is the cullable object bounding sphere center in the frustum ?
  80257. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80258. */
  80259. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80260. /**
  80261. * No billboard
  80262. */
  80263. static readonly BILLBOARDMODE_NONE: number;
  80264. /** Billboard on X axis */
  80265. static readonly BILLBOARDMODE_X: number;
  80266. /** Billboard on Y axis */
  80267. static readonly BILLBOARDMODE_Y: number;
  80268. /** Billboard on Z axis */
  80269. static readonly BILLBOARDMODE_Z: number;
  80270. /** Billboard on all axes */
  80271. static readonly BILLBOARDMODE_ALL: number;
  80272. private _facetData;
  80273. /**
  80274. * The culling strategy to use to check whether the mesh must be rendered or not.
  80275. * This value can be changed at any time and will be used on the next render mesh selection.
  80276. * The possible values are :
  80277. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80278. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80279. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80281. * Please read each static variable documentation to get details about the culling process.
  80282. * */
  80283. cullingStrategy: number;
  80284. /**
  80285. * Gets the number of facets in the mesh
  80286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80287. */
  80288. readonly facetNb: number;
  80289. /**
  80290. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80292. */
  80293. partitioningSubdivisions: number;
  80294. /**
  80295. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80296. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80298. */
  80299. partitioningBBoxRatio: number;
  80300. /**
  80301. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80302. * Works only for updatable meshes.
  80303. * Doesn't work with multi-materials
  80304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80305. */
  80306. mustDepthSortFacets: boolean;
  80307. /**
  80308. * The location (Vector3) where the facet depth sort must be computed from.
  80309. * By default, the active camera position.
  80310. * Used only when facet depth sort is enabled
  80311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80312. */
  80313. facetDepthSortFrom: Vector3;
  80314. /**
  80315. * gets a boolean indicating if facetData is enabled
  80316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80317. */
  80318. readonly isFacetDataEnabled: boolean;
  80319. /** @hidden */
  80320. _updateNonUniformScalingState(value: boolean): boolean;
  80321. /**
  80322. * An event triggered when this mesh collides with another one
  80323. */
  80324. onCollideObservable: Observable<AbstractMesh>;
  80325. private _onCollideObserver;
  80326. /** Set a function to call when this mesh collides with another one */
  80327. onCollide: () => void;
  80328. /**
  80329. * An event triggered when the collision's position changes
  80330. */
  80331. onCollisionPositionChangeObservable: Observable<Vector3>;
  80332. private _onCollisionPositionChangeObserver;
  80333. /** Set a function to call when the collision's position changes */
  80334. onCollisionPositionChange: () => void;
  80335. /**
  80336. * An event triggered when material is changed
  80337. */
  80338. onMaterialChangedObservable: Observable<AbstractMesh>;
  80339. /**
  80340. * Gets or sets the orientation for POV movement & rotation
  80341. */
  80342. definedFacingForward: boolean;
  80343. /** @hidden */
  80344. _occlusionQuery: Nullable<WebGLQuery>;
  80345. private _visibility;
  80346. /**
  80347. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80348. */
  80349. /**
  80350. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80351. */
  80352. visibility: number;
  80353. /** Gets or sets the alpha index used to sort transparent meshes
  80354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80355. */
  80356. alphaIndex: number;
  80357. /**
  80358. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80359. */
  80360. isVisible: boolean;
  80361. /**
  80362. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80363. */
  80364. isPickable: boolean;
  80365. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80366. showSubMeshesBoundingBox: boolean;
  80367. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80369. */
  80370. isBlocker: boolean;
  80371. /**
  80372. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80373. */
  80374. enablePointerMoveEvents: boolean;
  80375. /**
  80376. * Specifies the rendering group id for this mesh (0 by default)
  80377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80378. */
  80379. renderingGroupId: number;
  80380. private _material;
  80381. /** Gets or sets current material */
  80382. material: Nullable<Material>;
  80383. private _receiveShadows;
  80384. /**
  80385. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80386. * @see http://doc.babylonjs.com/babylon101/shadows
  80387. */
  80388. receiveShadows: boolean;
  80389. /** Defines color to use when rendering outline */
  80390. outlineColor: Color3;
  80391. /** Define width to use when rendering outline */
  80392. outlineWidth: number;
  80393. /** Defines color to use when rendering overlay */
  80394. overlayColor: Color3;
  80395. /** Defines alpha to use when rendering overlay */
  80396. overlayAlpha: number;
  80397. private _hasVertexAlpha;
  80398. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80399. hasVertexAlpha: boolean;
  80400. private _useVertexColors;
  80401. /** 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) */
  80402. useVertexColors: boolean;
  80403. private _computeBonesUsingShaders;
  80404. /**
  80405. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80406. */
  80407. computeBonesUsingShaders: boolean;
  80408. private _numBoneInfluencers;
  80409. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80410. numBoneInfluencers: number;
  80411. private _applyFog;
  80412. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80413. applyFog: boolean;
  80414. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80415. useOctreeForRenderingSelection: boolean;
  80416. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80417. useOctreeForPicking: boolean;
  80418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80419. useOctreeForCollisions: boolean;
  80420. private _layerMask;
  80421. /**
  80422. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80423. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80424. */
  80425. layerMask: number;
  80426. /**
  80427. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80428. */
  80429. alwaysSelectAsActiveMesh: boolean;
  80430. /**
  80431. * Gets or sets the current action manager
  80432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80433. */
  80434. actionManager: Nullable<ActionManager>;
  80435. private _checkCollisions;
  80436. private _collisionMask;
  80437. private _collisionGroup;
  80438. /**
  80439. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80441. */
  80442. ellipsoid: Vector3;
  80443. /**
  80444. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80446. */
  80447. ellipsoidOffset: Vector3;
  80448. private _collider;
  80449. private _oldPositionForCollisions;
  80450. private _diffPositionForCollisions;
  80451. /**
  80452. * Gets or sets a collision mask used to mask collisions (default is -1).
  80453. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80454. */
  80455. collisionMask: number;
  80456. /**
  80457. * Gets or sets the current collision group mask (-1 by default).
  80458. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80459. */
  80460. collisionGroup: number;
  80461. /**
  80462. * Defines edge width used when edgesRenderer is enabled
  80463. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80464. */
  80465. edgesWidth: number;
  80466. /**
  80467. * Defines edge color used when edgesRenderer is enabled
  80468. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80469. */
  80470. edgesColor: Color4;
  80471. /** @hidden */
  80472. _edgesRenderer: Nullable<IEdgesRenderer>;
  80473. /** @hidden */
  80474. _masterMesh: Nullable<AbstractMesh>;
  80475. /** @hidden */
  80476. _boundingInfo: Nullable<BoundingInfo>;
  80477. /** @hidden */
  80478. _renderId: number;
  80479. /**
  80480. * Gets or sets the list of subMeshes
  80481. * @see http://doc.babylonjs.com/how_to/multi_materials
  80482. */
  80483. subMeshes: SubMesh[];
  80484. /** @hidden */
  80485. _intersectionsInProgress: AbstractMesh[];
  80486. /** @hidden */
  80487. _unIndexed: boolean;
  80488. /** @hidden */
  80489. _lightSources: Light[];
  80490. /** @hidden */
  80491. readonly _positions: Nullable<Vector3[]>;
  80492. /** @hidden */
  80493. _waitingActions: any;
  80494. /** @hidden */
  80495. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80496. private _skeleton;
  80497. /** @hidden */
  80498. _bonesTransformMatrices: Nullable<Float32Array>;
  80499. /**
  80500. * Gets or sets a skeleton to apply skining transformations
  80501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80502. */
  80503. skeleton: Nullable<Skeleton>;
  80504. /**
  80505. * An event triggered when the mesh is rebuilt.
  80506. */
  80507. onRebuildObservable: Observable<AbstractMesh>;
  80508. /**
  80509. * Creates a new AbstractMesh
  80510. * @param name defines the name of the mesh
  80511. * @param scene defines the hosting scene
  80512. */
  80513. constructor(name: string, scene?: Nullable<Scene>);
  80514. /**
  80515. * Returns the string "AbstractMesh"
  80516. * @returns "AbstractMesh"
  80517. */
  80518. getClassName(): string;
  80519. /**
  80520. * Gets a string representation of the current mesh
  80521. * @param fullDetails defines a boolean indicating if full details must be included
  80522. * @returns a string representation of the current mesh
  80523. */
  80524. toString(fullDetails?: boolean): string;
  80525. /** @hidden */
  80526. _rebuild(): void;
  80527. /** @hidden */
  80528. _resyncLightSources(): void;
  80529. /** @hidden */
  80530. _resyncLighSource(light: Light): void;
  80531. /** @hidden */
  80532. _unBindEffect(): void;
  80533. /** @hidden */
  80534. _removeLightSource(light: Light): void;
  80535. private _markSubMeshesAsDirty;
  80536. /** @hidden */
  80537. _markSubMeshesAsLightDirty(): void;
  80538. /** @hidden */
  80539. _markSubMeshesAsAttributesDirty(): void;
  80540. /** @hidden */
  80541. _markSubMeshesAsMiscDirty(): void;
  80542. /**
  80543. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80544. */
  80545. scaling: Vector3;
  80546. /**
  80547. * Returns true if the mesh is blocked. Implemented by child classes
  80548. */
  80549. readonly isBlocked: boolean;
  80550. /**
  80551. * Returns the mesh itself by default. Implemented by child classes
  80552. * @param camera defines the camera to use to pick the right LOD level
  80553. * @returns the currentAbstractMesh
  80554. */
  80555. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80556. /**
  80557. * Returns 0 by default. Implemented by child classes
  80558. * @returns an integer
  80559. */
  80560. getTotalVertices(): number;
  80561. /**
  80562. * Returns a positive integer : the total number of indices in this mesh geometry.
  80563. * @returns the numner of indices or zero if the mesh has no geometry.
  80564. */
  80565. getTotalIndices(): number;
  80566. /**
  80567. * Returns null by default. Implemented by child classes
  80568. * @returns null
  80569. */
  80570. getIndices(): Nullable<IndicesArray>;
  80571. /**
  80572. * Returns the array of the requested vertex data kind. Implemented by child classes
  80573. * @param kind defines the vertex data kind to use
  80574. * @returns null
  80575. */
  80576. getVerticesData(kind: string): Nullable<FloatArray>;
  80577. /**
  80578. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80579. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80580. * Note that a new underlying VertexBuffer object is created each call.
  80581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80582. * @param kind defines vertex data kind:
  80583. * * VertexBuffer.PositionKind
  80584. * * VertexBuffer.UVKind
  80585. * * VertexBuffer.UV2Kind
  80586. * * VertexBuffer.UV3Kind
  80587. * * VertexBuffer.UV4Kind
  80588. * * VertexBuffer.UV5Kind
  80589. * * VertexBuffer.UV6Kind
  80590. * * VertexBuffer.ColorKind
  80591. * * VertexBuffer.MatricesIndicesKind
  80592. * * VertexBuffer.MatricesIndicesExtraKind
  80593. * * VertexBuffer.MatricesWeightsKind
  80594. * * VertexBuffer.MatricesWeightsExtraKind
  80595. * @param data defines the data source
  80596. * @param updatable defines if the data must be flagged as updatable (or static)
  80597. * @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
  80598. * @returns the current mesh
  80599. */
  80600. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80601. /**
  80602. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80603. * If the mesh has no geometry, it is simply returned as it is.
  80604. * @param kind defines vertex data kind:
  80605. * * VertexBuffer.PositionKind
  80606. * * VertexBuffer.UVKind
  80607. * * VertexBuffer.UV2Kind
  80608. * * VertexBuffer.UV3Kind
  80609. * * VertexBuffer.UV4Kind
  80610. * * VertexBuffer.UV5Kind
  80611. * * VertexBuffer.UV6Kind
  80612. * * VertexBuffer.ColorKind
  80613. * * VertexBuffer.MatricesIndicesKind
  80614. * * VertexBuffer.MatricesIndicesExtraKind
  80615. * * VertexBuffer.MatricesWeightsKind
  80616. * * VertexBuffer.MatricesWeightsExtraKind
  80617. * @param data defines the data source
  80618. * @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
  80619. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80620. * @returns the current mesh
  80621. */
  80622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  80623. /**
  80624. * Sets the mesh indices,
  80625. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80626. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80627. * @param totalVertices Defines the total number of vertices
  80628. * @returns the current mesh
  80629. */
  80630. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  80631. /**
  80632. * Gets a boolean indicating if specific vertex data is present
  80633. * @param kind defines the vertex data kind to use
  80634. * @returns true is data kind is present
  80635. */
  80636. isVerticesDataPresent(kind: string): boolean;
  80637. /**
  80638. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80639. * @returns a BoundingInfo
  80640. */
  80641. getBoundingInfo(): BoundingInfo;
  80642. /**
  80643. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80644. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80645. * @returns the current mesh
  80646. */
  80647. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  80648. /**
  80649. * Overwrite the current bounding info
  80650. * @param boundingInfo defines the new bounding info
  80651. * @returns the current mesh
  80652. */
  80653. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  80654. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80655. readonly useBones: boolean;
  80656. /** @hidden */
  80657. _preActivate(): void;
  80658. /** @hidden */
  80659. _preActivateForIntermediateRendering(renderId: number): void;
  80660. /** @hidden */
  80661. _activate(renderId: number): void;
  80662. /**
  80663. * Gets the current world matrix
  80664. * @returns a Matrix
  80665. */
  80666. getWorldMatrix(): Matrix;
  80667. /** @hidden */
  80668. _getWorldMatrixDeterminant(): number;
  80669. /**
  80670. * Perform relative position change from the point of view of behind the front of the mesh.
  80671. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80672. * Supports definition of mesh facing forward or backward
  80673. * @param amountRight defines the distance on the right axis
  80674. * @param amountUp defines the distance on the up axis
  80675. * @param amountForward defines the distance on the forward axis
  80676. * @returns the current mesh
  80677. */
  80678. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  80679. /**
  80680. * Calculate relative position change from the point of view of behind the front of the mesh.
  80681. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80682. * Supports definition of mesh facing forward or backward
  80683. * @param amountRight defines the distance on the right axis
  80684. * @param amountUp defines the distance on the up axis
  80685. * @param amountForward defines the distance on the forward axis
  80686. * @returns the new displacement vector
  80687. */
  80688. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  80689. /**
  80690. * Perform relative rotation change from the point of view of behind the front of the mesh.
  80691. * Supports definition of mesh facing forward or backward
  80692. * @param flipBack defines the flip
  80693. * @param twirlClockwise defines the twirl
  80694. * @param tiltRight defines the tilt
  80695. * @returns the current mesh
  80696. */
  80697. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  80698. /**
  80699. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  80700. * Supports definition of mesh facing forward or backward.
  80701. * @param flipBack defines the flip
  80702. * @param twirlClockwise defines the twirl
  80703. * @param tiltRight defines the tilt
  80704. * @returns the new rotation vector
  80705. */
  80706. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  80707. /**
  80708. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  80709. * @param includeDescendants Include bounding info from descendants as well (true by default)
  80710. * @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
  80711. * @returns the new bounding vectors
  80712. */
  80713. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  80714. min: Vector3;
  80715. max: Vector3;
  80716. };
  80717. /**
  80718. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80719. * This means the mesh underlying bounding box and sphere are recomputed.
  80720. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80721. * @returns the current mesh
  80722. */
  80723. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  80724. /** @hidden */
  80725. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  80726. /** @hidden */
  80727. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  80728. /** @hidden */
  80729. _updateBoundingInfo(): AbstractMesh;
  80730. /** @hidden */
  80731. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  80732. /** @hidden */
  80733. protected _afterComputeWorldMatrix(): void;
  80734. /**
  80735. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80736. * A mesh is in the frustum if its bounding box intersects the frustum
  80737. * @param frustumPlanes defines the frustum to test
  80738. * @returns true if the mesh is in the frustum planes
  80739. */
  80740. isInFrustum(frustumPlanes: Plane[]): boolean;
  80741. /**
  80742. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  80743. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  80744. * @param frustumPlanes defines the frustum to test
  80745. * @returns true if the mesh is completely in the frustum planes
  80746. */
  80747. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80748. /**
  80749. * True if the mesh intersects another mesh or a SolidParticle object
  80750. * @param mesh defines a target mesh or SolidParticle to test
  80751. * @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)
  80752. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  80753. * @returns true if there is an intersection
  80754. */
  80755. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  80756. /**
  80757. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  80758. * @param point defines the point to test
  80759. * @returns true if there is an intersection
  80760. */
  80761. intersectsPoint(point: Vector3): boolean;
  80762. /**
  80763. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80765. */
  80766. checkCollisions: boolean;
  80767. /**
  80768. * Gets Collider object used to compute collisions (not physics)
  80769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80770. */
  80771. readonly collider: Collider;
  80772. /**
  80773. * Move the mesh using collision engine
  80774. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80775. * @param displacement defines the requested displacement vector
  80776. * @returns the current mesh
  80777. */
  80778. moveWithCollisions(displacement: Vector3): AbstractMesh;
  80779. private _onCollisionPositionChange;
  80780. /** @hidden */
  80781. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  80782. /** @hidden */
  80783. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  80784. /** @hidden */
  80785. _checkCollision(collider: Collider): AbstractMesh;
  80786. /** @hidden */
  80787. _generatePointsArray(): boolean;
  80788. /**
  80789. * Checks if the passed Ray intersects with the mesh
  80790. * @param ray defines the ray to use
  80791. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80792. * @returns the picking info
  80793. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80794. */
  80795. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  80796. /**
  80797. * Clones the current mesh
  80798. * @param name defines the mesh name
  80799. * @param newParent defines the new mesh parent
  80800. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80801. * @returns the new mesh
  80802. */
  80803. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  80804. /**
  80805. * Disposes all the submeshes of the current meshnp
  80806. * @returns the current mesh
  80807. */
  80808. releaseSubMeshes(): AbstractMesh;
  80809. /**
  80810. * Releases resources associated with this abstract mesh.
  80811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80813. */
  80814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80815. /**
  80816. * Adds the passed mesh as a child to the current mesh
  80817. * @param mesh defines the child mesh
  80818. * @returns the current mesh
  80819. */
  80820. addChild(mesh: AbstractMesh): AbstractMesh;
  80821. /**
  80822. * Removes the passed mesh from the current mesh children list
  80823. * @param mesh defines the child mesh
  80824. * @returns the current mesh
  80825. */
  80826. removeChild(mesh: AbstractMesh): AbstractMesh;
  80827. /** @hidden */
  80828. private _initFacetData;
  80829. /**
  80830. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80831. * This method can be called within the render loop.
  80832. * 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
  80833. * @returns the current mesh
  80834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80835. */
  80836. updateFacetData(): AbstractMesh;
  80837. /**
  80838. * Returns the facetLocalNormals array.
  80839. * The normals are expressed in the mesh local spac
  80840. * @returns an array of Vector3
  80841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80842. */
  80843. getFacetLocalNormals(): Vector3[];
  80844. /**
  80845. * Returns the facetLocalPositions array.
  80846. * The facet positions are expressed in the mesh local space
  80847. * @returns an array of Vector3
  80848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80849. */
  80850. getFacetLocalPositions(): Vector3[];
  80851. /**
  80852. * Returns the facetLocalPartioning array
  80853. * @returns an array of array of numbers
  80854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80855. */
  80856. getFacetLocalPartitioning(): number[][];
  80857. /**
  80858. * Returns the i-th facet position in the world system.
  80859. * This method allocates a new Vector3 per call
  80860. * @param i defines the facet index
  80861. * @returns a new Vector3
  80862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80863. */
  80864. getFacetPosition(i: number): Vector3;
  80865. /**
  80866. * Sets the reference Vector3 with the i-th facet position in the world system
  80867. * @param i defines the facet index
  80868. * @param ref defines the target vector
  80869. * @returns the current mesh
  80870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80871. */
  80872. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  80873. /**
  80874. * Returns the i-th facet normal in the world system.
  80875. * This method allocates a new Vector3 per call
  80876. * @param i defines the facet index
  80877. * @returns a new Vector3
  80878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80879. */
  80880. getFacetNormal(i: number): Vector3;
  80881. /**
  80882. * Sets the reference Vector3 with the i-th facet normal in the world system
  80883. * @param i defines the facet index
  80884. * @param ref defines the target vector
  80885. * @returns the current mesh
  80886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80887. */
  80888. getFacetNormalToRef(i: number, ref: Vector3): this;
  80889. /**
  80890. * 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)
  80891. * @param x defines x coordinate
  80892. * @param y defines y coordinate
  80893. * @param z defines z coordinate
  80894. * @returns the array of facet indexes
  80895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80896. */
  80897. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  80898. /**
  80899. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80900. * @param projected sets as the (x,y,z) world projection on the facet
  80901. * @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
  80902. * @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
  80903. * @param x defines x coordinate
  80904. * @param y defines y coordinate
  80905. * @param z defines z coordinate
  80906. * @returns the face index if found (or null instead)
  80907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80908. */
  80909. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80910. /**
  80911. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80912. * @param projected sets as the (x,y,z) local projection on the facet
  80913. * @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
  80914. * @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
  80915. * @param x defines x coordinate
  80916. * @param y defines y coordinate
  80917. * @param z defines z coordinate
  80918. * @returns the face index if found (or null instead)
  80919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80920. */
  80921. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80922. /**
  80923. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80924. * @returns the parameters
  80925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80926. */
  80927. getFacetDataParameters(): any;
  80928. /**
  80929. * Disables the feature FacetData and frees the related memory
  80930. * @returns the current mesh
  80931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80932. */
  80933. disableFacetData(): AbstractMesh;
  80934. /**
  80935. * Updates the AbstractMesh indices array
  80936. * @param indices defines the data source
  80937. * @returns the current mesh
  80938. */
  80939. updateIndices(indices: IndicesArray): AbstractMesh;
  80940. /**
  80941. * Creates new normals data for the mesh
  80942. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80943. * @returns the current mesh
  80944. */
  80945. createNormals(updatable: boolean): AbstractMesh;
  80946. /**
  80947. * Align the mesh with a normal
  80948. * @param normal defines the normal to use
  80949. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80950. * @returns the current mesh
  80951. */
  80952. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  80953. /** @hidden */
  80954. _checkOcclusionQuery(): boolean;
  80955. }
  80956. }
  80957. declare module BABYLON {
  80958. /**
  80959. * Defines how a node can be built from a string name.
  80960. */
  80961. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80962. /**
  80963. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80964. */
  80965. export class Node implements IBehaviorAware<Node> {
  80966. /** @hidden */
  80967. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80968. private static _NodeConstructors;
  80969. /**
  80970. * Add a new node constructor
  80971. * @param type defines the type name of the node to construct
  80972. * @param constructorFunc defines the constructor function
  80973. */
  80974. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80975. /**
  80976. * Returns a node constructor based on type name
  80977. * @param type defines the type name
  80978. * @param name defines the new node name
  80979. * @param scene defines the hosting scene
  80980. * @param options defines optional options to transmit to constructors
  80981. * @returns the new constructor or null
  80982. */
  80983. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80984. /**
  80985. * Gets or sets the name of the node
  80986. */
  80987. name: string;
  80988. /**
  80989. * Gets or sets the id of the node
  80990. */
  80991. id: string;
  80992. /**
  80993. * Gets or sets the unique id of the node
  80994. */
  80995. uniqueId: number;
  80996. /**
  80997. * Gets or sets a string used to store user defined state for the node
  80998. */
  80999. state: string;
  81000. /**
  81001. * Gets or sets an object used to store user defined information for the node
  81002. */
  81003. metadata: any;
  81004. /**
  81005. * For internal use only. Please do not use.
  81006. */
  81007. reservedDataStore: any;
  81008. /**
  81009. * Gets or sets a boolean used to define if the node must be serialized
  81010. */
  81011. doNotSerialize: boolean;
  81012. /** @hidden */
  81013. _isDisposed: boolean;
  81014. /**
  81015. * Gets a list of Animations associated with the node
  81016. */
  81017. animations: Animation[];
  81018. protected _ranges: {
  81019. [name: string]: Nullable<AnimationRange>;
  81020. };
  81021. /**
  81022. * Callback raised when the node is ready to be used
  81023. */
  81024. onReady: (node: Node) => void;
  81025. private _isEnabled;
  81026. private _isParentEnabled;
  81027. private _isReady;
  81028. /** @hidden */
  81029. _currentRenderId: number;
  81030. private _parentRenderId;
  81031. protected _childRenderId: number;
  81032. /** @hidden */
  81033. _waitingParentId: Nullable<string>;
  81034. /** @hidden */
  81035. _scene: Scene;
  81036. /** @hidden */
  81037. _cache: any;
  81038. private _parentNode;
  81039. private _children;
  81040. /** @hidden */
  81041. _worldMatrix: Matrix;
  81042. /** @hidden */
  81043. _worldMatrixDeterminant: number;
  81044. /** @hidden */
  81045. private _sceneRootNodesIndex;
  81046. /**
  81047. * Gets a boolean indicating if the node has been disposed
  81048. * @returns true if the node was disposed
  81049. */
  81050. isDisposed(): boolean;
  81051. /**
  81052. * Gets or sets the parent of the node
  81053. */
  81054. parent: Nullable<Node>;
  81055. private addToSceneRootNodes;
  81056. private removeFromSceneRootNodes;
  81057. private _animationPropertiesOverride;
  81058. /**
  81059. * Gets or sets the animation properties override
  81060. */
  81061. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81062. /**
  81063. * Gets a string idenfifying the name of the class
  81064. * @returns "Node" string
  81065. */
  81066. getClassName(): string;
  81067. /** @hidden */
  81068. readonly _isNode: boolean;
  81069. /**
  81070. * An event triggered when the mesh is disposed
  81071. */
  81072. onDisposeObservable: Observable<Node>;
  81073. private _onDisposeObserver;
  81074. /**
  81075. * Sets a callback that will be raised when the node will be disposed
  81076. */
  81077. onDispose: () => void;
  81078. /**
  81079. * Creates a new Node
  81080. * @param name the name and id to be given to this node
  81081. * @param scene the scene this node will be added to
  81082. * @param addToRootNodes the node will be added to scene.rootNodes
  81083. */
  81084. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81085. /**
  81086. * Gets the scene of the node
  81087. * @returns a scene
  81088. */
  81089. getScene(): Scene;
  81090. /**
  81091. * Gets the engine of the node
  81092. * @returns a Engine
  81093. */
  81094. getEngine(): Engine;
  81095. private _behaviors;
  81096. /**
  81097. * Attach a behavior to the node
  81098. * @see http://doc.babylonjs.com/features/behaviour
  81099. * @param behavior defines the behavior to attach
  81100. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81101. * @returns the current Node
  81102. */
  81103. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81104. /**
  81105. * Remove an attached behavior
  81106. * @see http://doc.babylonjs.com/features/behaviour
  81107. * @param behavior defines the behavior to attach
  81108. * @returns the current Node
  81109. */
  81110. removeBehavior(behavior: Behavior<Node>): Node;
  81111. /**
  81112. * Gets the list of attached behaviors
  81113. * @see http://doc.babylonjs.com/features/behaviour
  81114. */
  81115. readonly behaviors: Behavior<Node>[];
  81116. /**
  81117. * Gets an attached behavior by name
  81118. * @param name defines the name of the behavior to look for
  81119. * @see http://doc.babylonjs.com/features/behaviour
  81120. * @returns null if behavior was not found else the requested behavior
  81121. */
  81122. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81123. /**
  81124. * Returns the latest update of the World matrix
  81125. * @returns a Matrix
  81126. */
  81127. getWorldMatrix(): Matrix;
  81128. /** @hidden */
  81129. _getWorldMatrixDeterminant(): number;
  81130. /**
  81131. * Returns directly the latest state of the mesh World matrix.
  81132. * A Matrix is returned.
  81133. */
  81134. readonly worldMatrixFromCache: Matrix;
  81135. /** @hidden */
  81136. _initCache(): void;
  81137. /** @hidden */
  81138. updateCache(force?: boolean): void;
  81139. /** @hidden */
  81140. _updateCache(ignoreParentClass?: boolean): void;
  81141. /** @hidden */
  81142. _isSynchronized(): boolean;
  81143. /** @hidden */
  81144. _markSyncedWithParent(): void;
  81145. /** @hidden */
  81146. isSynchronizedWithParent(): boolean;
  81147. /** @hidden */
  81148. isSynchronized(): boolean;
  81149. /**
  81150. * Is this node ready to be used/rendered
  81151. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81152. * @return true if the node is ready
  81153. */
  81154. isReady(completeCheck?: boolean): boolean;
  81155. /**
  81156. * Is this node enabled?
  81157. * 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
  81158. * @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
  81159. * @return whether this node (and its parent) is enabled
  81160. */
  81161. isEnabled(checkAncestors?: boolean): boolean;
  81162. /** @hidden */
  81163. protected _syncParentEnabledState(): void;
  81164. /**
  81165. * Set the enabled state of this node
  81166. * @param value defines the new enabled state
  81167. */
  81168. setEnabled(value: boolean): void;
  81169. /**
  81170. * Is this node a descendant of the given node?
  81171. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81172. * @param ancestor defines the parent node to inspect
  81173. * @returns a boolean indicating if this node is a descendant of the given node
  81174. */
  81175. isDescendantOf(ancestor: Node): boolean;
  81176. /** @hidden */
  81177. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81178. /**
  81179. * Will return all nodes that have this node as ascendant
  81180. * @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
  81181. * @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
  81182. * @return all children nodes of all types
  81183. */
  81184. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81185. /**
  81186. * Get all child-meshes of this node
  81187. * @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
  81188. * @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
  81189. * @returns an array of AbstractMesh
  81190. */
  81191. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81192. /**
  81193. * Get all direct children of this node
  81194. * @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
  81195. * @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)
  81196. * @returns an array of Node
  81197. */
  81198. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81199. /** @hidden */
  81200. _setReady(state: boolean): void;
  81201. /**
  81202. * Get an animation by name
  81203. * @param name defines the name of the animation to look for
  81204. * @returns null if not found else the requested animation
  81205. */
  81206. getAnimationByName(name: string): Nullable<Animation>;
  81207. /**
  81208. * Creates an animation range for this node
  81209. * @param name defines the name of the range
  81210. * @param from defines the starting key
  81211. * @param to defines the end key
  81212. */
  81213. createAnimationRange(name: string, from: number, to: number): void;
  81214. /**
  81215. * Delete a specific animation range
  81216. * @param name defines the name of the range to delete
  81217. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81218. */
  81219. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81220. /**
  81221. * Get an animation range by name
  81222. * @param name defines the name of the animation range to look for
  81223. * @returns null if not found else the requested animation range
  81224. */
  81225. getAnimationRange(name: string): Nullable<AnimationRange>;
  81226. /**
  81227. * Will start the animation sequence
  81228. * @param name defines the range frames for animation sequence
  81229. * @param loop defines if the animation should loop (false by default)
  81230. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81231. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81232. * @returns the object created for this animation. If range does not exist, it will return null
  81233. */
  81234. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81235. /**
  81236. * Serialize animation ranges into a JSON compatible object
  81237. * @returns serialization object
  81238. */
  81239. serializeAnimationRanges(): any;
  81240. /**
  81241. * Computes the world matrix of the node
  81242. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81243. * @returns the world matrix
  81244. */
  81245. computeWorldMatrix(force?: boolean): Matrix;
  81246. /**
  81247. * Releases resources associated with this node.
  81248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81250. */
  81251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81252. /**
  81253. * Parse animation range data from a serialization object and store them into a given node
  81254. * @param node defines where to store the animation ranges
  81255. * @param parsedNode defines the serialization object to read data from
  81256. * @param scene defines the hosting scene
  81257. */
  81258. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81259. }
  81260. }
  81261. declare module BABYLON {
  81262. /**
  81263. * Represents the range of an animation
  81264. */
  81265. export class AnimationRange {
  81266. /**The name of the animation range**/
  81267. name: string;
  81268. /**The starting frame of the animation */
  81269. from: number;
  81270. /**The ending frame of the animation*/
  81271. to: number;
  81272. /**
  81273. * Initializes the range of an animation
  81274. * @param name The name of the animation range
  81275. * @param from The starting frame of the animation
  81276. * @param to The ending frame of the animation
  81277. */
  81278. constructor(
  81279. /**The name of the animation range**/
  81280. name: string,
  81281. /**The starting frame of the animation */
  81282. from: number,
  81283. /**The ending frame of the animation*/
  81284. to: number);
  81285. /**
  81286. * Makes a copy of the animation range
  81287. * @returns A copy of the animation range
  81288. */
  81289. clone(): AnimationRange;
  81290. }
  81291. /**
  81292. * Composed of a frame, and an action function
  81293. */
  81294. export class AnimationEvent {
  81295. /** The frame for which the event is triggered **/
  81296. frame: number;
  81297. /** The event to perform when triggered **/
  81298. action: (currentFrame: number) => void;
  81299. /** Specifies if the event should be triggered only once**/
  81300. onlyOnce?: boolean | undefined;
  81301. /**
  81302. * Specifies if the animation event is done
  81303. */
  81304. isDone: boolean;
  81305. /**
  81306. * Initializes the animation event
  81307. * @param frame The frame for which the event is triggered
  81308. * @param action The event to perform when triggered
  81309. * @param onlyOnce Specifies if the event should be triggered only once
  81310. */
  81311. constructor(
  81312. /** The frame for which the event is triggered **/
  81313. frame: number,
  81314. /** The event to perform when triggered **/
  81315. action: (currentFrame: number) => void,
  81316. /** Specifies if the event should be triggered only once**/
  81317. onlyOnce?: boolean | undefined);
  81318. /** @hidden */
  81319. _clone(): AnimationEvent;
  81320. }
  81321. /**
  81322. * A cursor which tracks a point on a path
  81323. */
  81324. export class PathCursor {
  81325. private path;
  81326. /**
  81327. * Stores path cursor callbacks for when an onchange event is triggered
  81328. */
  81329. private _onchange;
  81330. /**
  81331. * The value of the path cursor
  81332. */
  81333. value: number;
  81334. /**
  81335. * The animation array of the path cursor
  81336. */
  81337. animations: Animation[];
  81338. /**
  81339. * Initializes the path cursor
  81340. * @param path The path to track
  81341. */
  81342. constructor(path: Path2);
  81343. /**
  81344. * Gets the cursor point on the path
  81345. * @returns A point on the path cursor at the cursor location
  81346. */
  81347. getPoint(): Vector3;
  81348. /**
  81349. * Moves the cursor ahead by the step amount
  81350. * @param step The amount to move the cursor forward
  81351. * @returns This path cursor
  81352. */
  81353. moveAhead(step?: number): PathCursor;
  81354. /**
  81355. * Moves the cursor behind by the step amount
  81356. * @param step The amount to move the cursor back
  81357. * @returns This path cursor
  81358. */
  81359. moveBack(step?: number): PathCursor;
  81360. /**
  81361. * Moves the cursor by the step amount
  81362. * If the step amount is greater than one, an exception is thrown
  81363. * @param step The amount to move the cursor
  81364. * @returns This path cursor
  81365. */
  81366. move(step: number): PathCursor;
  81367. /**
  81368. * Ensures that the value is limited between zero and one
  81369. * @returns This path cursor
  81370. */
  81371. private ensureLimits;
  81372. /**
  81373. * Runs onchange callbacks on change (used by the animation engine)
  81374. * @returns This path cursor
  81375. */
  81376. private raiseOnChange;
  81377. /**
  81378. * Executes a function on change
  81379. * @param f A path cursor onchange callback
  81380. * @returns This path cursor
  81381. */
  81382. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81383. }
  81384. /**
  81385. * Defines an interface which represents an animation key frame
  81386. */
  81387. export interface IAnimationKey {
  81388. /**
  81389. * Frame of the key frame
  81390. */
  81391. frame: number;
  81392. /**
  81393. * Value at the specifies key frame
  81394. */
  81395. value: any;
  81396. /**
  81397. * The input tangent for the cubic hermite spline
  81398. */
  81399. inTangent?: any;
  81400. /**
  81401. * The output tangent for the cubic hermite spline
  81402. */
  81403. outTangent?: any;
  81404. /**
  81405. * The animation interpolation type
  81406. */
  81407. interpolation?: AnimationKeyInterpolation;
  81408. }
  81409. /**
  81410. * Enum for the animation key frame interpolation type
  81411. */
  81412. export enum AnimationKeyInterpolation {
  81413. /**
  81414. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  81415. */
  81416. STEP = 1
  81417. }
  81418. /**
  81419. * Class used to store any kind of animation
  81420. */
  81421. export class Animation {
  81422. /**Name of the animation */
  81423. name: string;
  81424. /**Property to animate */
  81425. targetProperty: string;
  81426. /**The frames per second of the animation */
  81427. framePerSecond: number;
  81428. /**The data type of the animation */
  81429. dataType: number;
  81430. /**The loop mode of the animation */
  81431. loopMode?: number | undefined;
  81432. /**Specifies if blending should be enabled */
  81433. enableBlending?: boolean | undefined;
  81434. /**
  81435. * Use matrix interpolation instead of using direct key value when animating matrices
  81436. */
  81437. static AllowMatricesInterpolation: boolean;
  81438. /**
  81439. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81440. */
  81441. static AllowMatrixDecomposeForInterpolation: boolean;
  81442. /**
  81443. * Stores the key frames of the animation
  81444. */
  81445. private _keys;
  81446. /**
  81447. * Stores the easing function of the animation
  81448. */
  81449. private _easingFunction;
  81450. /**
  81451. * @hidden Internal use only
  81452. */
  81453. _runtimeAnimations: RuntimeAnimation[];
  81454. /**
  81455. * The set of event that will be linked to this animation
  81456. */
  81457. private _events;
  81458. /**
  81459. * Stores an array of target property paths
  81460. */
  81461. targetPropertyPath: string[];
  81462. /**
  81463. * Stores the blending speed of the animation
  81464. */
  81465. blendingSpeed: number;
  81466. /**
  81467. * Stores the animation ranges for the animation
  81468. */
  81469. private _ranges;
  81470. /**
  81471. * @hidden Internal use
  81472. */
  81473. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81474. /**
  81475. * Sets up an animation
  81476. * @param property The property to animate
  81477. * @param animationType The animation type to apply
  81478. * @param framePerSecond The frames per second of the animation
  81479. * @param easingFunction The easing function used in the animation
  81480. * @returns The created animation
  81481. */
  81482. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81483. /**
  81484. * Create and start an animation on a node
  81485. * @param name defines the name of the global animation that will be run on all nodes
  81486. * @param node defines the root node where the animation will take place
  81487. * @param targetProperty defines property to animate
  81488. * @param framePerSecond defines the number of frame per second yo use
  81489. * @param totalFrame defines the number of frames in total
  81490. * @param from defines the initial value
  81491. * @param to defines the final value
  81492. * @param loopMode defines which loop mode you want to use (off by default)
  81493. * @param easingFunction defines the easing function to use (linear by default)
  81494. * @param onAnimationEnd defines the callback to call when animation end
  81495. * @returns the animatable created for this animation
  81496. */
  81497. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81498. /**
  81499. * Create and start an animation on a node and its descendants
  81500. * @param name defines the name of the global animation that will be run on all nodes
  81501. * @param node defines the root node where the animation will take place
  81502. * @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
  81503. * @param targetProperty defines property to animate
  81504. * @param framePerSecond defines the number of frame per second to use
  81505. * @param totalFrame defines the number of frames in total
  81506. * @param from defines the initial value
  81507. * @param to defines the final value
  81508. * @param loopMode defines which loop mode you want to use (off by default)
  81509. * @param easingFunction defines the easing function to use (linear by default)
  81510. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81511. * @returns the list of animatables created for all nodes
  81512. * @example https://www.babylonjs-playground.com/#MH0VLI
  81513. */
  81514. 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[]>;
  81515. /**
  81516. * Creates a new animation, merges it with the existing animations and starts it
  81517. * @param name Name of the animation
  81518. * @param node Node which contains the scene that begins the animations
  81519. * @param targetProperty Specifies which property to animate
  81520. * @param framePerSecond The frames per second of the animation
  81521. * @param totalFrame The total number of frames
  81522. * @param from The frame at the beginning of the animation
  81523. * @param to The frame at the end of the animation
  81524. * @param loopMode Specifies the loop mode of the animation
  81525. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81526. * @param onAnimationEnd Callback to run once the animation is complete
  81527. * @returns Nullable animation
  81528. */
  81529. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81530. /**
  81531. * Transition property of an host to the target Value
  81532. * @param property The property to transition
  81533. * @param targetValue The target Value of the property
  81534. * @param host The object where the property to animate belongs
  81535. * @param scene Scene used to run the animation
  81536. * @param frameRate Framerate (in frame/s) to use
  81537. * @param transition The transition type we want to use
  81538. * @param duration The duration of the animation, in milliseconds
  81539. * @param onAnimationEnd Callback trigger at the end of the animation
  81540. * @returns Nullable animation
  81541. */
  81542. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81543. /**
  81544. * Return the array of runtime animations currently using this animation
  81545. */
  81546. readonly runtimeAnimations: RuntimeAnimation[];
  81547. /**
  81548. * Specifies if any of the runtime animations are currently running
  81549. */
  81550. readonly hasRunningRuntimeAnimations: boolean;
  81551. /**
  81552. * Initializes the animation
  81553. * @param name Name of the animation
  81554. * @param targetProperty Property to animate
  81555. * @param framePerSecond The frames per second of the animation
  81556. * @param dataType The data type of the animation
  81557. * @param loopMode The loop mode of the animation
  81558. * @param enableBlendings Specifies if blending should be enabled
  81559. */
  81560. constructor(
  81561. /**Name of the animation */
  81562. name: string,
  81563. /**Property to animate */
  81564. targetProperty: string,
  81565. /**The frames per second of the animation */
  81566. framePerSecond: number,
  81567. /**The data type of the animation */
  81568. dataType: number,
  81569. /**The loop mode of the animation */
  81570. loopMode?: number | undefined,
  81571. /**Specifies if blending should be enabled */
  81572. enableBlending?: boolean | undefined);
  81573. /**
  81574. * Converts the animation to a string
  81575. * @param fullDetails support for multiple levels of logging within scene loading
  81576. * @returns String form of the animation
  81577. */
  81578. toString(fullDetails?: boolean): string;
  81579. /**
  81580. * Add an event to this animation
  81581. * @param event Event to add
  81582. */
  81583. addEvent(event: AnimationEvent): void;
  81584. /**
  81585. * Remove all events found at the given frame
  81586. * @param frame The frame to remove events from
  81587. */
  81588. removeEvents(frame: number): void;
  81589. /**
  81590. * Retrieves all the events from the animation
  81591. * @returns Events from the animation
  81592. */
  81593. getEvents(): AnimationEvent[];
  81594. /**
  81595. * Creates an animation range
  81596. * @param name Name of the animation range
  81597. * @param from Starting frame of the animation range
  81598. * @param to Ending frame of the animation
  81599. */
  81600. createRange(name: string, from: number, to: number): void;
  81601. /**
  81602. * Deletes an animation range by name
  81603. * @param name Name of the animation range to delete
  81604. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81605. */
  81606. deleteRange(name: string, deleteFrames?: boolean): void;
  81607. /**
  81608. * Gets the animation range by name, or null if not defined
  81609. * @param name Name of the animation range
  81610. * @returns Nullable animation range
  81611. */
  81612. getRange(name: string): Nullable<AnimationRange>;
  81613. /**
  81614. * Gets the key frames from the animation
  81615. * @returns The key frames of the animation
  81616. */
  81617. getKeys(): Array<IAnimationKey>;
  81618. /**
  81619. * Gets the highest frame rate of the animation
  81620. * @returns Highest frame rate of the animation
  81621. */
  81622. getHighestFrame(): number;
  81623. /**
  81624. * Gets the easing function of the animation
  81625. * @returns Easing function of the animation
  81626. */
  81627. getEasingFunction(): IEasingFunction;
  81628. /**
  81629. * Sets the easing function of the animation
  81630. * @param easingFunction A custom mathematical formula for animation
  81631. */
  81632. setEasingFunction(easingFunction: EasingFunction): void;
  81633. /**
  81634. * Interpolates a scalar linearly
  81635. * @param startValue Start value of the animation curve
  81636. * @param endValue End value of the animation curve
  81637. * @param gradient Scalar amount to interpolate
  81638. * @returns Interpolated scalar value
  81639. */
  81640. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81641. /**
  81642. * Interpolates a scalar cubically
  81643. * @param startValue Start value of the animation curve
  81644. * @param outTangent End tangent of the animation
  81645. * @param endValue End value of the animation curve
  81646. * @param inTangent Start tangent of the animation curve
  81647. * @param gradient Scalar amount to interpolate
  81648. * @returns Interpolated scalar value
  81649. */
  81650. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81651. /**
  81652. * Interpolates a quaternion using a spherical linear interpolation
  81653. * @param startValue Start value of the animation curve
  81654. * @param endValue End value of the animation curve
  81655. * @param gradient Scalar amount to interpolate
  81656. * @returns Interpolated quaternion value
  81657. */
  81658. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81659. /**
  81660. * Interpolates a quaternion cubically
  81661. * @param startValue Start value of the animation curve
  81662. * @param outTangent End tangent of the animation curve
  81663. * @param endValue End value of the animation curve
  81664. * @param inTangent Start tangent of the animation curve
  81665. * @param gradient Scalar amount to interpolate
  81666. * @returns Interpolated quaternion value
  81667. */
  81668. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81669. /**
  81670. * Interpolates a Vector3 linearl
  81671. * @param startValue Start value of the animation curve
  81672. * @param endValue End value of the animation curve
  81673. * @param gradient Scalar amount to interpolate
  81674. * @returns Interpolated scalar value
  81675. */
  81676. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81677. /**
  81678. * Interpolates a Vector3 cubically
  81679. * @param startValue Start value of the animation curve
  81680. * @param outTangent End tangent of the animation
  81681. * @param endValue End value of the animation curve
  81682. * @param inTangent Start tangent of the animation curve
  81683. * @param gradient Scalar amount to interpolate
  81684. * @returns InterpolatedVector3 value
  81685. */
  81686. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81687. /**
  81688. * Interpolates a Vector2 linearly
  81689. * @param startValue Start value of the animation curve
  81690. * @param endValue End value of the animation curve
  81691. * @param gradient Scalar amount to interpolate
  81692. * @returns Interpolated Vector2 value
  81693. */
  81694. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81695. /**
  81696. * Interpolates a Vector2 cubically
  81697. * @param startValue Start value of the animation curve
  81698. * @param outTangent End tangent of the animation
  81699. * @param endValue End value of the animation curve
  81700. * @param inTangent Start tangent of the animation curve
  81701. * @param gradient Scalar amount to interpolate
  81702. * @returns Interpolated Vector2 value
  81703. */
  81704. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81705. /**
  81706. * Interpolates a size linearly
  81707. * @param startValue Start value of the animation curve
  81708. * @param endValue End value of the animation curve
  81709. * @param gradient Scalar amount to interpolate
  81710. * @returns Interpolated Size value
  81711. */
  81712. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81713. /**
  81714. * Interpolates a Color3 linearly
  81715. * @param startValue Start value of the animation curve
  81716. * @param endValue End value of the animation curve
  81717. * @param gradient Scalar amount to interpolate
  81718. * @returns Interpolated Color3 value
  81719. */
  81720. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81721. /**
  81722. * @hidden Internal use only
  81723. */
  81724. _getKeyValue(value: any): any;
  81725. /**
  81726. * @hidden Internal use only
  81727. */
  81728. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81729. /**
  81730. * Defines the function to use to interpolate matrices
  81731. * @param startValue defines the start matrix
  81732. * @param endValue defines the end matrix
  81733. * @param gradient defines the gradient between both matrices
  81734. * @param result defines an optional target matrix where to store the interpolation
  81735. * @returns the interpolated matrix
  81736. */
  81737. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81738. /**
  81739. * Makes a copy of the animation
  81740. * @returns Cloned animation
  81741. */
  81742. clone(): Animation;
  81743. /**
  81744. * Sets the key frames of the animation
  81745. * @param values The animation key frames to set
  81746. */
  81747. setKeys(values: Array<IAnimationKey>): void;
  81748. /**
  81749. * Serializes the animation to an object
  81750. * @returns Serialized object
  81751. */
  81752. serialize(): any;
  81753. /**
  81754. * Float animation type
  81755. */
  81756. private static _ANIMATIONTYPE_FLOAT;
  81757. /**
  81758. * Vector3 animation type
  81759. */
  81760. private static _ANIMATIONTYPE_VECTOR3;
  81761. /**
  81762. * Quaternion animation type
  81763. */
  81764. private static _ANIMATIONTYPE_QUATERNION;
  81765. /**
  81766. * Matrix animation type
  81767. */
  81768. private static _ANIMATIONTYPE_MATRIX;
  81769. /**
  81770. * Color3 animation type
  81771. */
  81772. private static _ANIMATIONTYPE_COLOR3;
  81773. /**
  81774. * Vector2 animation type
  81775. */
  81776. private static _ANIMATIONTYPE_VECTOR2;
  81777. /**
  81778. * Size animation type
  81779. */
  81780. private static _ANIMATIONTYPE_SIZE;
  81781. /**
  81782. * Relative Loop Mode
  81783. */
  81784. private static _ANIMATIONLOOPMODE_RELATIVE;
  81785. /**
  81786. * Cycle Loop Mode
  81787. */
  81788. private static _ANIMATIONLOOPMODE_CYCLE;
  81789. /**
  81790. * Constant Loop Mode
  81791. */
  81792. private static _ANIMATIONLOOPMODE_CONSTANT;
  81793. /**
  81794. * Get the float animation type
  81795. */
  81796. static readonly ANIMATIONTYPE_FLOAT: number;
  81797. /**
  81798. * Get the Vector3 animation type
  81799. */
  81800. static readonly ANIMATIONTYPE_VECTOR3: number;
  81801. /**
  81802. * Get the Vector2 animation type
  81803. */
  81804. static readonly ANIMATIONTYPE_VECTOR2: number;
  81805. /**
  81806. * Get the Size animation type
  81807. */
  81808. static readonly ANIMATIONTYPE_SIZE: number;
  81809. /**
  81810. * Get the Quaternion animation type
  81811. */
  81812. static readonly ANIMATIONTYPE_QUATERNION: number;
  81813. /**
  81814. * Get the Matrix animation type
  81815. */
  81816. static readonly ANIMATIONTYPE_MATRIX: number;
  81817. /**
  81818. * Get the Color3 animation type
  81819. */
  81820. static readonly ANIMATIONTYPE_COLOR3: number;
  81821. /**
  81822. * Get the Relative Loop Mode
  81823. */
  81824. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81825. /**
  81826. * Get the Cycle Loop Mode
  81827. */
  81828. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81829. /**
  81830. * Get the Constant Loop Mode
  81831. */
  81832. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81833. /** @hidden */
  81834. static _UniversalLerp(left: any, right: any, amount: number): any;
  81835. /**
  81836. * Parses an animation object and creates an animation
  81837. * @param parsedAnimation Parsed animation object
  81838. * @returns Animation object
  81839. */
  81840. static Parse(parsedAnimation: any): Animation;
  81841. /**
  81842. * Appends the serialized animations from the source animations
  81843. * @param source Source containing the animations
  81844. * @param destination Target to store the animations
  81845. */
  81846. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81847. }
  81848. }
  81849. declare module BABYLON {
  81850. /**
  81851. * Base class of all the textures in babylon.
  81852. * It groups all the common properties the materials, post process, lights... might need
  81853. * in order to make a correct use of the texture.
  81854. */
  81855. export class BaseTexture implements IAnimatable {
  81856. /**
  81857. * Default anisotropic filtering level for the application.
  81858. * It is set to 4 as a good tradeoff between perf and quality.
  81859. */
  81860. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81861. /**
  81862. * Gets or sets the unique id of the texture
  81863. */
  81864. uniqueId: number;
  81865. /**
  81866. * Define the name of the texture.
  81867. */
  81868. name: string;
  81869. /**
  81870. * Gets or sets an object used to store user defined information.
  81871. */
  81872. metadata: any;
  81873. /**
  81874. * For internal use only. Please do not use.
  81875. */
  81876. reservedDataStore: any;
  81877. private _hasAlpha;
  81878. /**
  81879. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81880. */
  81881. hasAlpha: boolean;
  81882. /**
  81883. * Defines if the alpha value should be determined via the rgb values.
  81884. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81885. */
  81886. getAlphaFromRGB: boolean;
  81887. /**
  81888. * Intensity or strength of the texture.
  81889. * It is commonly used by materials to fine tune the intensity of the texture
  81890. */
  81891. level: number;
  81892. /**
  81893. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81894. * This is part of the texture as textures usually maps to one uv set.
  81895. */
  81896. coordinatesIndex: number;
  81897. private _coordinatesMode;
  81898. /**
  81899. * How a texture is mapped.
  81900. *
  81901. * | Value | Type | Description |
  81902. * | ----- | ----------------------------------- | ----------- |
  81903. * | 0 | EXPLICIT_MODE | |
  81904. * | 1 | SPHERICAL_MODE | |
  81905. * | 2 | PLANAR_MODE | |
  81906. * | 3 | CUBIC_MODE | |
  81907. * | 4 | PROJECTION_MODE | |
  81908. * | 5 | SKYBOX_MODE | |
  81909. * | 6 | INVCUBIC_MODE | |
  81910. * | 7 | EQUIRECTANGULAR_MODE | |
  81911. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81912. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81913. */
  81914. coordinatesMode: number;
  81915. /**
  81916. * | Value | Type | Description |
  81917. * | ----- | ------------------ | ----------- |
  81918. * | 0 | CLAMP_ADDRESSMODE | |
  81919. * | 1 | WRAP_ADDRESSMODE | |
  81920. * | 2 | MIRROR_ADDRESSMODE | |
  81921. */
  81922. wrapU: number;
  81923. /**
  81924. * | Value | Type | Description |
  81925. * | ----- | ------------------ | ----------- |
  81926. * | 0 | CLAMP_ADDRESSMODE | |
  81927. * | 1 | WRAP_ADDRESSMODE | |
  81928. * | 2 | MIRROR_ADDRESSMODE | |
  81929. */
  81930. wrapV: number;
  81931. /**
  81932. * | Value | Type | Description |
  81933. * | ----- | ------------------ | ----------- |
  81934. * | 0 | CLAMP_ADDRESSMODE | |
  81935. * | 1 | WRAP_ADDRESSMODE | |
  81936. * | 2 | MIRROR_ADDRESSMODE | |
  81937. */
  81938. wrapR: number;
  81939. /**
  81940. * With compliant hardware and browser (supporting anisotropic filtering)
  81941. * this defines the level of anisotropic filtering in the texture.
  81942. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81943. */
  81944. anisotropicFilteringLevel: number;
  81945. /**
  81946. * Define if the texture is a cube texture or if false a 2d texture.
  81947. */
  81948. isCube: boolean;
  81949. /**
  81950. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81951. */
  81952. is3D: boolean;
  81953. /**
  81954. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81955. * HDR texture are usually stored in linear space.
  81956. * This only impacts the PBR and Background materials
  81957. */
  81958. gammaSpace: boolean;
  81959. /**
  81960. * Gets whether or not the texture contains RGBD data.
  81961. */
  81962. readonly isRGBD: boolean;
  81963. /**
  81964. * Is Z inverted in the texture (useful in a cube texture).
  81965. */
  81966. invertZ: boolean;
  81967. /**
  81968. * Are mip maps generated for this texture or not.
  81969. */
  81970. readonly noMipmap: boolean;
  81971. /**
  81972. * @hidden
  81973. */
  81974. lodLevelInAlpha: boolean;
  81975. /**
  81976. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81977. */
  81978. lodGenerationOffset: number;
  81979. /**
  81980. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81981. */
  81982. lodGenerationScale: number;
  81983. /**
  81984. * Define if the texture is a render target.
  81985. */
  81986. isRenderTarget: boolean;
  81987. /**
  81988. * Define the unique id of the texture in the scene.
  81989. */
  81990. readonly uid: string;
  81991. /**
  81992. * Return a string representation of the texture.
  81993. * @returns the texture as a string
  81994. */
  81995. toString(): string;
  81996. /**
  81997. * Get the class name of the texture.
  81998. * @returns "BaseTexture"
  81999. */
  82000. getClassName(): string;
  82001. /**
  82002. * Define the list of animation attached to the texture.
  82003. */
  82004. animations: Animation[];
  82005. /**
  82006. * An event triggered when the texture is disposed.
  82007. */
  82008. onDisposeObservable: Observable<BaseTexture>;
  82009. private _onDisposeObserver;
  82010. /**
  82011. * Callback triggered when the texture has been disposed.
  82012. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82013. */
  82014. onDispose: () => void;
  82015. /**
  82016. * Define the current state of the loading sequence when in delayed load mode.
  82017. */
  82018. delayLoadState: number;
  82019. private _scene;
  82020. /** @hidden */
  82021. _texture: Nullable<InternalTexture>;
  82022. private _uid;
  82023. /**
  82024. * Define if the texture is preventinga material to render or not.
  82025. * If not and the texture is not ready, the engine will use a default black texture instead.
  82026. */
  82027. readonly isBlocking: boolean;
  82028. /**
  82029. * Instantiates a new BaseTexture.
  82030. * Base class of all the textures in babylon.
  82031. * It groups all the common properties the materials, post process, lights... might need
  82032. * in order to make a correct use of the texture.
  82033. * @param scene Define the scene the texture blongs to
  82034. */
  82035. constructor(scene: Nullable<Scene>);
  82036. /**
  82037. * Get the scene the texture belongs to.
  82038. * @returns the scene or null if undefined
  82039. */
  82040. getScene(): Nullable<Scene>;
  82041. /**
  82042. * Get the texture transform matrix used to offset tile the texture for istance.
  82043. * @returns the transformation matrix
  82044. */
  82045. getTextureMatrix(): Matrix;
  82046. /**
  82047. * Get the texture reflection matrix used to rotate/transform the reflection.
  82048. * @returns the reflection matrix
  82049. */
  82050. getReflectionTextureMatrix(): Matrix;
  82051. /**
  82052. * Get the underlying lower level texture from Babylon.
  82053. * @returns the insternal texture
  82054. */
  82055. getInternalTexture(): Nullable<InternalTexture>;
  82056. /**
  82057. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82058. * @returns true if ready or not blocking
  82059. */
  82060. isReadyOrNotBlocking(): boolean;
  82061. /**
  82062. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82063. * @returns true if fully ready
  82064. */
  82065. isReady(): boolean;
  82066. private _cachedSize;
  82067. /**
  82068. * Get the size of the texture.
  82069. * @returns the texture size.
  82070. */
  82071. getSize(): ISize;
  82072. /**
  82073. * Get the base size of the texture.
  82074. * It can be different from the size if the texture has been resized for POT for instance
  82075. * @returns the base size
  82076. */
  82077. getBaseSize(): ISize;
  82078. /**
  82079. * Update the sampling mode of the texture.
  82080. * Default is Trilinear mode.
  82081. *
  82082. * | Value | Type | Description |
  82083. * | ----- | ------------------ | ----------- |
  82084. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82085. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82086. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82087. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82088. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82089. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82090. * | 7 | NEAREST_LINEAR | |
  82091. * | 8 | NEAREST_NEAREST | |
  82092. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82093. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82094. * | 11 | LINEAR_LINEAR | |
  82095. * | 12 | LINEAR_NEAREST | |
  82096. *
  82097. * > _mag_: magnification filter (close to the viewer)
  82098. * > _min_: minification filter (far from the viewer)
  82099. * > _mip_: filter used between mip map levels
  82100. *@param samplingMode Define the new sampling mode of the texture
  82101. */
  82102. updateSamplingMode(samplingMode: number): void;
  82103. /**
  82104. * Scales the texture if is `canRescale()`
  82105. * @param ratio the resize factor we want to use to rescale
  82106. */
  82107. scale(ratio: number): void;
  82108. /**
  82109. * Get if the texture can rescale.
  82110. */
  82111. readonly canRescale: boolean;
  82112. /** @hidden */
  82113. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  82114. /** @hidden */
  82115. _rebuild(): void;
  82116. /**
  82117. * Triggers the load sequence in delayed load mode.
  82118. */
  82119. delayLoad(): void;
  82120. /**
  82121. * Clones the texture.
  82122. * @returns the cloned texture
  82123. */
  82124. clone(): Nullable<BaseTexture>;
  82125. /**
  82126. * Get the texture underlying type (INT, FLOAT...)
  82127. */
  82128. readonly textureType: number;
  82129. /**
  82130. * Get the texture underlying format (RGB, RGBA...)
  82131. */
  82132. readonly textureFormat: number;
  82133. /**
  82134. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82135. * This will returns an RGBA array buffer containing either in values (0-255) or
  82136. * float values (0-1) depending of the underlying buffer type.
  82137. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82138. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82139. * @param buffer defines a user defined buffer to fill with data (can be null)
  82140. * @returns The Array buffer containing the pixels data.
  82141. */
  82142. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82143. /**
  82144. * Release and destroy the underlying lower level texture aka internalTexture.
  82145. */
  82146. releaseInternalTexture(): void;
  82147. /**
  82148. * Get the polynomial representation of the texture data.
  82149. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82150. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82151. */
  82152. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82153. /** @hidden */
  82154. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82155. /** @hidden */
  82156. readonly _lodTextureMid: Nullable<BaseTexture>;
  82157. /** @hidden */
  82158. readonly _lodTextureLow: Nullable<BaseTexture>;
  82159. /**
  82160. * Dispose the texture and release its associated resources.
  82161. */
  82162. dispose(): void;
  82163. /**
  82164. * Serialize the texture into a JSON representation that can be parsed later on.
  82165. * @returns the JSON representation of the texture
  82166. */
  82167. serialize(): any;
  82168. /**
  82169. * Helper function to be called back once a list of texture contains only ready textures.
  82170. * @param textures Define the list of textures to wait for
  82171. * @param callback Define the callback triggered once the entire list will be ready
  82172. */
  82173. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82174. }
  82175. }
  82176. declare module BABYLON {
  82177. /**
  82178. * Uniform buffer objects.
  82179. *
  82180. * Handles blocks of uniform on the GPU.
  82181. *
  82182. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82183. *
  82184. * For more information, please refer to :
  82185. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82186. */
  82187. export class UniformBuffer {
  82188. private _engine;
  82189. private _buffer;
  82190. private _data;
  82191. private _bufferData;
  82192. private _dynamic?;
  82193. private _uniformLocations;
  82194. private _uniformSizes;
  82195. private _uniformLocationPointer;
  82196. private _needSync;
  82197. private _noUBO;
  82198. private _currentEffect;
  82199. private static _MAX_UNIFORM_SIZE;
  82200. private static _tempBuffer;
  82201. /**
  82202. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82203. * This is dynamic to allow compat with webgl 1 and 2.
  82204. * You will need to pass the name of the uniform as well as the value.
  82205. */
  82206. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82207. /**
  82208. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82209. * This is dynamic to allow compat with webgl 1 and 2.
  82210. * You will need to pass the name of the uniform as well as the value.
  82211. */
  82212. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82213. /**
  82214. * Lambda to Update a single float in a uniform buffer.
  82215. * This is dynamic to allow compat with webgl 1 and 2.
  82216. * You will need to pass the name of the uniform as well as the value.
  82217. */
  82218. updateFloat: (name: string, x: number) => void;
  82219. /**
  82220. * Lambda to Update a vec2 of float in a uniform buffer.
  82221. * This is dynamic to allow compat with webgl 1 and 2.
  82222. * You will need to pass the name of the uniform as well as the value.
  82223. */
  82224. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82225. /**
  82226. * Lambda to Update a vec3 of float in a uniform buffer.
  82227. * This is dynamic to allow compat with webgl 1 and 2.
  82228. * You will need to pass the name of the uniform as well as the value.
  82229. */
  82230. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82231. /**
  82232. * Lambda to Update a vec4 of float in a uniform buffer.
  82233. * This is dynamic to allow compat with webgl 1 and 2.
  82234. * You will need to pass the name of the uniform as well as the value.
  82235. */
  82236. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82237. /**
  82238. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82239. * This is dynamic to allow compat with webgl 1 and 2.
  82240. * You will need to pass the name of the uniform as well as the value.
  82241. */
  82242. updateMatrix: (name: string, mat: Matrix) => void;
  82243. /**
  82244. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82245. * This is dynamic to allow compat with webgl 1 and 2.
  82246. * You will need to pass the name of the uniform as well as the value.
  82247. */
  82248. updateVector3: (name: string, vector: Vector3) => void;
  82249. /**
  82250. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82251. * This is dynamic to allow compat with webgl 1 and 2.
  82252. * You will need to pass the name of the uniform as well as the value.
  82253. */
  82254. updateVector4: (name: string, vector: Vector4) => void;
  82255. /**
  82256. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82257. * This is dynamic to allow compat with webgl 1 and 2.
  82258. * You will need to pass the name of the uniform as well as the value.
  82259. */
  82260. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82261. /**
  82262. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82263. * This is dynamic to allow compat with webgl 1 and 2.
  82264. * You will need to pass the name of the uniform as well as the value.
  82265. */
  82266. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82267. /**
  82268. * Instantiates a new Uniform buffer objects.
  82269. *
  82270. * Handles blocks of uniform on the GPU.
  82271. *
  82272. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82273. *
  82274. * For more information, please refer to :
  82275. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82276. * @param engine Define the engine the buffer is associated with
  82277. * @param data Define the data contained in the buffer
  82278. * @param dynamic Define if the buffer is updatable
  82279. */
  82280. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82281. /**
  82282. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82283. * or just falling back on setUniformXXX calls.
  82284. */
  82285. readonly useUbo: boolean;
  82286. /**
  82287. * Indicates if the WebGL underlying uniform buffer is in sync
  82288. * with the javascript cache data.
  82289. */
  82290. readonly isSync: boolean;
  82291. /**
  82292. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82293. * Also, a dynamic UniformBuffer will disable cache verification and always
  82294. * update the underlying WebGL uniform buffer to the GPU.
  82295. * @returns if Dynamic, otherwise false
  82296. */
  82297. isDynamic(): boolean;
  82298. /**
  82299. * The data cache on JS side.
  82300. * @returns the underlying data as a float array
  82301. */
  82302. getData(): Float32Array;
  82303. /**
  82304. * The underlying WebGL Uniform buffer.
  82305. * @returns the webgl buffer
  82306. */
  82307. getBuffer(): Nullable<WebGLBuffer>;
  82308. /**
  82309. * std140 layout specifies how to align data within an UBO structure.
  82310. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82311. * for specs.
  82312. */
  82313. private _fillAlignment;
  82314. /**
  82315. * Adds an uniform in the buffer.
  82316. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82317. * for the layout to be correct !
  82318. * @param name Name of the uniform, as used in the uniform block in the shader.
  82319. * @param size Data size, or data directly.
  82320. */
  82321. addUniform(name: string, size: number | number[]): void;
  82322. /**
  82323. * Adds a Matrix 4x4 to the uniform buffer.
  82324. * @param name Name of the uniform, as used in the uniform block in the shader.
  82325. * @param mat A 4x4 matrix.
  82326. */
  82327. addMatrix(name: string, mat: Matrix): void;
  82328. /**
  82329. * Adds a vec2 to the uniform buffer.
  82330. * @param name Name of the uniform, as used in the uniform block in the shader.
  82331. * @param x Define the x component value of the vec2
  82332. * @param y Define the y component value of the vec2
  82333. */
  82334. addFloat2(name: string, x: number, y: number): void;
  82335. /**
  82336. * Adds a vec3 to the uniform buffer.
  82337. * @param name Name of the uniform, as used in the uniform block in the shader.
  82338. * @param x Define the x component value of the vec3
  82339. * @param y Define the y component value of the vec3
  82340. * @param z Define the z component value of the vec3
  82341. */
  82342. addFloat3(name: string, x: number, y: number, z: number): void;
  82343. /**
  82344. * Adds a vec3 to the uniform buffer.
  82345. * @param name Name of the uniform, as used in the uniform block in the shader.
  82346. * @param color Define the vec3 from a Color
  82347. */
  82348. addColor3(name: string, color: Color3): void;
  82349. /**
  82350. * Adds a vec4 to the uniform buffer.
  82351. * @param name Name of the uniform, as used in the uniform block in the shader.
  82352. * @param color Define the rgb components from a Color
  82353. * @param alpha Define the a component of the vec4
  82354. */
  82355. addColor4(name: string, color: Color3, alpha: number): void;
  82356. /**
  82357. * Adds a vec3 to the uniform buffer.
  82358. * @param name Name of the uniform, as used in the uniform block in the shader.
  82359. * @param vector Define the vec3 components from a Vector
  82360. */
  82361. addVector3(name: string, vector: Vector3): void;
  82362. /**
  82363. * Adds a Matrix 3x3 to the uniform buffer.
  82364. * @param name Name of the uniform, as used in the uniform block in the shader.
  82365. */
  82366. addMatrix3x3(name: string): void;
  82367. /**
  82368. * Adds a Matrix 2x2 to the uniform buffer.
  82369. * @param name Name of the uniform, as used in the uniform block in the shader.
  82370. */
  82371. addMatrix2x2(name: string): void;
  82372. /**
  82373. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82374. */
  82375. create(): void;
  82376. /** @hidden */
  82377. _rebuild(): void;
  82378. /**
  82379. * Updates the WebGL Uniform Buffer on the GPU.
  82380. * If the `dynamic` flag is set to true, no cache comparison is done.
  82381. * Otherwise, the buffer will be updated only if the cache differs.
  82382. */
  82383. update(): void;
  82384. /**
  82385. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82387. * @param data Define the flattened data
  82388. * @param size Define the size of the data.
  82389. */
  82390. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82391. private _updateMatrix3x3ForUniform;
  82392. private _updateMatrix3x3ForEffect;
  82393. private _updateMatrix2x2ForEffect;
  82394. private _updateMatrix2x2ForUniform;
  82395. private _updateFloatForEffect;
  82396. private _updateFloatForUniform;
  82397. private _updateFloat2ForEffect;
  82398. private _updateFloat2ForUniform;
  82399. private _updateFloat3ForEffect;
  82400. private _updateFloat3ForUniform;
  82401. private _updateFloat4ForEffect;
  82402. private _updateFloat4ForUniform;
  82403. private _updateMatrixForEffect;
  82404. private _updateMatrixForUniform;
  82405. private _updateVector3ForEffect;
  82406. private _updateVector3ForUniform;
  82407. private _updateVector4ForEffect;
  82408. private _updateVector4ForUniform;
  82409. private _updateColor3ForEffect;
  82410. private _updateColor3ForUniform;
  82411. private _updateColor4ForEffect;
  82412. private _updateColor4ForUniform;
  82413. /**
  82414. * Sets a sampler uniform on the effect.
  82415. * @param name Define the name of the sampler.
  82416. * @param texture Define the texture to set in the sampler
  82417. */
  82418. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82419. /**
  82420. * Directly updates the value of the uniform in the cache AND on the GPU.
  82421. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82422. * @param data Define the flattened data
  82423. */
  82424. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82425. /**
  82426. * Binds this uniform buffer to an effect.
  82427. * @param effect Define the effect to bind the buffer to
  82428. * @param name Name of the uniform block in the shader.
  82429. */
  82430. bindToEffect(effect: Effect, name: string): void;
  82431. /**
  82432. * Disposes the uniform buffer.
  82433. */
  82434. dispose(): void;
  82435. }
  82436. }
  82437. declare module BABYLON {
  82438. /**
  82439. * This represents the required contract to create a new type of texture loader.
  82440. */
  82441. export interface IInternalTextureLoader {
  82442. /**
  82443. * Defines wether the loader supports cascade loading the different faces.
  82444. */
  82445. supportCascades: boolean;
  82446. /**
  82447. * This returns if the loader support the current file information.
  82448. * @param extension defines the file extension of the file being loaded
  82449. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82450. * @param fallback defines the fallback internal texture if any
  82451. * @param isBase64 defines whether the texture is encoded as a base64
  82452. * @param isBuffer defines whether the texture data are stored as a buffer
  82453. * @returns true if the loader can load the specified file
  82454. */
  82455. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82456. /**
  82457. * Transform the url before loading if required.
  82458. * @param rootUrl the url of the texture
  82459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82460. * @returns the transformed texture
  82461. */
  82462. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82463. /**
  82464. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82465. * @param rootUrl the url of the texture
  82466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82467. * @returns the fallback texture
  82468. */
  82469. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82470. /**
  82471. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82472. * @param data contains the texture data
  82473. * @param texture defines the BabylonJS internal texture
  82474. * @param createPolynomials will be true if polynomials have been requested
  82475. * @param onLoad defines the callback to trigger once the texture is ready
  82476. * @param onError defines the callback to trigger in case of error
  82477. */
  82478. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82479. /**
  82480. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82481. * @param data contains the texture data
  82482. * @param texture defines the BabylonJS internal texture
  82483. * @param callback defines the method to call once ready to upload
  82484. */
  82485. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82486. }
  82487. }
  82488. declare module BABYLON {
  82489. /**
  82490. * Creation options of the multi render target texture.
  82491. */
  82492. export interface IMultiRenderTargetOptions {
  82493. /**
  82494. * Define if the texture needs to create mip maps after render.
  82495. */
  82496. generateMipMaps?: boolean;
  82497. /**
  82498. * Define the types of all the draw buffers we want to create
  82499. */
  82500. types?: number[];
  82501. /**
  82502. * Define the sampling modes of all the draw buffers we want to create
  82503. */
  82504. samplingModes?: number[];
  82505. /**
  82506. * Define if a depth buffer is required
  82507. */
  82508. generateDepthBuffer?: boolean;
  82509. /**
  82510. * Define if a stencil buffer is required
  82511. */
  82512. generateStencilBuffer?: boolean;
  82513. /**
  82514. * Define if a depth texture is required instead of a depth buffer
  82515. */
  82516. generateDepthTexture?: boolean;
  82517. /**
  82518. * Define the number of desired draw buffers
  82519. */
  82520. textureCount?: number;
  82521. /**
  82522. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82523. */
  82524. doNotChangeAspectRatio?: boolean;
  82525. /**
  82526. * Define the default type of the buffers we are creating
  82527. */
  82528. defaultType?: number;
  82529. }
  82530. /**
  82531. * A multi render target, like a render target provides the ability to render to a texture.
  82532. * Unlike the render target, it can render to several draw buffers in one draw.
  82533. * This is specially interesting in deferred rendering or for any effects requiring more than
  82534. * just one color from a single pass.
  82535. */
  82536. export class MultiRenderTarget extends RenderTargetTexture {
  82537. private _internalTextures;
  82538. private _textures;
  82539. private _multiRenderTargetOptions;
  82540. /**
  82541. * Get if draw buffers are currently supported by the used hardware and browser.
  82542. */
  82543. readonly isSupported: boolean;
  82544. /**
  82545. * Get the list of textures generated by the multi render target.
  82546. */
  82547. readonly textures: Texture[];
  82548. /**
  82549. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82550. */
  82551. readonly depthTexture: Texture;
  82552. /**
  82553. * Set the wrapping mode on U of all the textures we are rendering to.
  82554. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82555. */
  82556. wrapU: number;
  82557. /**
  82558. * Set the wrapping mode on V of all the textures we are rendering to.
  82559. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82560. */
  82561. wrapV: number;
  82562. /**
  82563. * Instantiate a new multi render target texture.
  82564. * A multi render target, like a render target provides the ability to render to a texture.
  82565. * Unlike the render target, it can render to several draw buffers in one draw.
  82566. * This is specially interesting in deferred rendering or for any effects requiring more than
  82567. * just one color from a single pass.
  82568. * @param name Define the name of the texture
  82569. * @param size Define the size of the buffers to render to
  82570. * @param count Define the number of target we are rendering into
  82571. * @param scene Define the scene the texture belongs to
  82572. * @param options Define the options used to create the multi render target
  82573. */
  82574. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82575. /** @hidden */
  82576. _rebuild(): void;
  82577. private _createInternalTextures;
  82578. private _createTextures;
  82579. /**
  82580. * Define the number of samples used if MSAA is enabled.
  82581. */
  82582. samples: number;
  82583. /**
  82584. * Resize all the textures in the multi render target.
  82585. * Be carrefull as it will recreate all the data in the new texture.
  82586. * @param size Define the new size
  82587. */
  82588. resize(size: any): void;
  82589. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82590. /**
  82591. * Dispose the render targets and their associated resources
  82592. */
  82593. dispose(): void;
  82594. /**
  82595. * Release all the underlying texture used as draw buffers.
  82596. */
  82597. releaseInternalTextures(): void;
  82598. }
  82599. }
  82600. declare module BABYLON {
  82601. /**
  82602. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82604. */
  82605. export class Analyser {
  82606. /**
  82607. * Gets or sets the smoothing
  82608. * @ignorenaming
  82609. */
  82610. SMOOTHING: number;
  82611. /**
  82612. * Gets or sets the FFT table size
  82613. * @ignorenaming
  82614. */
  82615. FFT_SIZE: number;
  82616. /**
  82617. * Gets or sets the bar graph amplitude
  82618. * @ignorenaming
  82619. */
  82620. BARGRAPHAMPLITUDE: number;
  82621. /**
  82622. * Gets or sets the position of the debug canvas
  82623. * @ignorenaming
  82624. */
  82625. DEBUGCANVASPOS: {
  82626. x: number;
  82627. y: number;
  82628. };
  82629. /**
  82630. * Gets or sets the debug canvas size
  82631. * @ignorenaming
  82632. */
  82633. DEBUGCANVASSIZE: {
  82634. width: number;
  82635. height: number;
  82636. };
  82637. private _byteFreqs;
  82638. private _byteTime;
  82639. private _floatFreqs;
  82640. private _webAudioAnalyser;
  82641. private _debugCanvas;
  82642. private _debugCanvasContext;
  82643. private _scene;
  82644. private _registerFunc;
  82645. private _audioEngine;
  82646. /**
  82647. * Creates a new analyser
  82648. * @param scene defines hosting scene
  82649. */
  82650. constructor(scene: Scene);
  82651. /**
  82652. * Get the number of data values you will have to play with for the visualization
  82653. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82654. * @returns a number
  82655. */
  82656. getFrequencyBinCount(): number;
  82657. /**
  82658. * Gets the current frequency data as a byte array
  82659. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82660. * @returns a Uint8Array
  82661. */
  82662. getByteFrequencyData(): Uint8Array;
  82663. /**
  82664. * Gets the current waveform as a byte array
  82665. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82666. * @returns a Uint8Array
  82667. */
  82668. getByteTimeDomainData(): Uint8Array;
  82669. /**
  82670. * Gets the current frequency data as a float array
  82671. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82672. * @returns a Float32Array
  82673. */
  82674. getFloatFrequencyData(): Float32Array;
  82675. /**
  82676. * Renders the debug canvas
  82677. */
  82678. drawDebugCanvas(): void;
  82679. /**
  82680. * Stops rendering the debug canvas and removes it
  82681. */
  82682. stopDebugCanvas(): void;
  82683. /**
  82684. * Connects two audio nodes
  82685. * @param inputAudioNode defines first node to connect
  82686. * @param outputAudioNode defines second node to connect
  82687. */
  82688. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82689. /**
  82690. * Releases all associated resources
  82691. */
  82692. dispose(): void;
  82693. }
  82694. }
  82695. declare module BABYLON {
  82696. /**
  82697. * This represents an audio engine and it is responsible
  82698. * to play, synchronize and analyse sounds throughout the application.
  82699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82700. */
  82701. export interface IAudioEngine extends IDisposable {
  82702. /**
  82703. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82704. */
  82705. readonly canUseWebAudio: boolean;
  82706. /**
  82707. * Gets the current AudioContext if available.
  82708. */
  82709. readonly audioContext: Nullable<AudioContext>;
  82710. /**
  82711. * The master gain node defines the global audio volume of your audio engine.
  82712. */
  82713. readonly masterGain: GainNode;
  82714. /**
  82715. * Gets whether or not mp3 are supported by your browser.
  82716. */
  82717. readonly isMP3supported: boolean;
  82718. /**
  82719. * Gets whether or not ogg are supported by your browser.
  82720. */
  82721. readonly isOGGsupported: boolean;
  82722. /**
  82723. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82724. * @ignoreNaming
  82725. */
  82726. WarnedWebAudioUnsupported: boolean;
  82727. /**
  82728. * Defines if the audio engine relies on a custom unlocked button.
  82729. * In this case, the embedded button will not be displayed.
  82730. */
  82731. useCustomUnlockedButton: boolean;
  82732. /**
  82733. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82734. */
  82735. readonly unlocked: boolean;
  82736. /**
  82737. * Event raised when audio has been unlocked on the browser.
  82738. */
  82739. onAudioUnlockedObservable: Observable<AudioEngine>;
  82740. /**
  82741. * Event raised when audio has been locked on the browser.
  82742. */
  82743. onAudioLockedObservable: Observable<AudioEngine>;
  82744. /**
  82745. * Flags the audio engine in Locked state.
  82746. * This happens due to new browser policies preventing audio to autoplay.
  82747. */
  82748. lock(): void;
  82749. /**
  82750. * Unlocks the audio engine once a user action has been done on the dom.
  82751. * This is helpful to resume play once browser policies have been satisfied.
  82752. */
  82753. unlock(): void;
  82754. }
  82755. /**
  82756. * This represents the default audio engine used in babylon.
  82757. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82759. */
  82760. export class AudioEngine implements IAudioEngine {
  82761. private _audioContext;
  82762. private _audioContextInitialized;
  82763. private _muteButton;
  82764. private _hostElement;
  82765. /**
  82766. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82767. */
  82768. canUseWebAudio: boolean;
  82769. /**
  82770. * The master gain node defines the global audio volume of your audio engine.
  82771. */
  82772. masterGain: GainNode;
  82773. /**
  82774. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82775. * @ignoreNaming
  82776. */
  82777. WarnedWebAudioUnsupported: boolean;
  82778. /**
  82779. * Gets whether or not mp3 are supported by your browser.
  82780. */
  82781. isMP3supported: boolean;
  82782. /**
  82783. * Gets whether or not ogg are supported by your browser.
  82784. */
  82785. isOGGsupported: boolean;
  82786. /**
  82787. * Gets whether audio has been unlocked on the device.
  82788. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82789. * a user interaction has happened.
  82790. */
  82791. unlocked: boolean;
  82792. /**
  82793. * Defines if the audio engine relies on a custom unlocked button.
  82794. * In this case, the embedded button will not be displayed.
  82795. */
  82796. useCustomUnlockedButton: boolean;
  82797. /**
  82798. * Event raised when audio has been unlocked on the browser.
  82799. */
  82800. onAudioUnlockedObservable: Observable<AudioEngine>;
  82801. /**
  82802. * Event raised when audio has been locked on the browser.
  82803. */
  82804. onAudioLockedObservable: Observable<AudioEngine>;
  82805. /**
  82806. * Gets the current AudioContext if available.
  82807. */
  82808. readonly audioContext: Nullable<AudioContext>;
  82809. private _connectedAnalyser;
  82810. /**
  82811. * Instantiates a new audio engine.
  82812. *
  82813. * There should be only one per page as some browsers restrict the number
  82814. * of audio contexts you can create.
  82815. * @param hostElement defines the host element where to display the mute icon if necessary
  82816. */
  82817. constructor(hostElement?: Nullable<HTMLElement>);
  82818. /**
  82819. * Flags the audio engine in Locked state.
  82820. * This happens due to new browser policies preventing audio to autoplay.
  82821. */
  82822. lock(): void;
  82823. /**
  82824. * Unlocks the audio engine once a user action has been done on the dom.
  82825. * This is helpful to resume play once browser policies have been satisfied.
  82826. */
  82827. unlock(): void;
  82828. private _resumeAudioContext;
  82829. private _initializeAudioContext;
  82830. private _tryToRun;
  82831. private _triggerRunningState;
  82832. private _triggerSuspendedState;
  82833. private _displayMuteButton;
  82834. private _moveButtonToTopLeft;
  82835. private _onResize;
  82836. private _hideMuteButton;
  82837. /**
  82838. * Destroy and release the resources associated with the audio ccontext.
  82839. */
  82840. dispose(): void;
  82841. /**
  82842. * Gets the global volume sets on the master gain.
  82843. * @returns the global volume if set or -1 otherwise
  82844. */
  82845. getGlobalVolume(): number;
  82846. /**
  82847. * Sets the global volume of your experience (sets on the master gain).
  82848. * @param newVolume Defines the new global volume of the application
  82849. */
  82850. setGlobalVolume(newVolume: number): void;
  82851. /**
  82852. * Connect the audio engine to an audio analyser allowing some amazing
  82853. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82855. * @param analyser The analyser to connect to the engine
  82856. */
  82857. connectToAnalyser(analyser: Analyser): void;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /**
  82862. * Interface used to present a loading screen while loading a scene
  82863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82864. */
  82865. export interface ILoadingScreen {
  82866. /**
  82867. * Function called to display the loading screen
  82868. */
  82869. displayLoadingUI: () => void;
  82870. /**
  82871. * Function called to hide the loading screen
  82872. */
  82873. hideLoadingUI: () => void;
  82874. /**
  82875. * Gets or sets the color to use for the background
  82876. */
  82877. loadingUIBackgroundColor: string;
  82878. /**
  82879. * Gets or sets the text to display while loading
  82880. */
  82881. loadingUIText: string;
  82882. }
  82883. /**
  82884. * Class used for the default loading screen
  82885. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82886. */
  82887. export class DefaultLoadingScreen implements ILoadingScreen {
  82888. private _renderingCanvas;
  82889. private _loadingText;
  82890. private _loadingDivBackgroundColor;
  82891. private _loadingDiv;
  82892. private _loadingTextDiv;
  82893. /**
  82894. * Creates a new default loading screen
  82895. * @param _renderingCanvas defines the canvas used to render the scene
  82896. * @param _loadingText defines the default text to display
  82897. * @param _loadingDivBackgroundColor defines the default background color
  82898. */
  82899. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82900. /**
  82901. * Function called to display the loading screen
  82902. */
  82903. displayLoadingUI(): void;
  82904. /**
  82905. * Function called to hide the loading screen
  82906. */
  82907. hideLoadingUI(): void;
  82908. /**
  82909. * Gets or sets the text to display while loading
  82910. */
  82911. loadingUIText: string;
  82912. /**
  82913. * Gets or sets the color to use for the background
  82914. */
  82915. loadingUIBackgroundColor: string;
  82916. private _resizeLoadingUI;
  82917. }
  82918. }
  82919. declare module BABYLON {
  82920. /**
  82921. * Settings for finer control over video usage
  82922. */
  82923. export interface VideoTextureSettings {
  82924. /**
  82925. * Applies `autoplay` to video, if specified
  82926. */
  82927. autoPlay?: boolean;
  82928. /**
  82929. * Applies `loop` to video, if specified
  82930. */
  82931. loop?: boolean;
  82932. /**
  82933. * Automatically updates internal texture from video at every frame in the render loop
  82934. */
  82935. autoUpdateTexture: boolean;
  82936. /**
  82937. * Image src displayed during the video loading or until the user interacts with the video.
  82938. */
  82939. poster?: string;
  82940. }
  82941. /**
  82942. * If you want to display a video in your scene, this is the special texture for that.
  82943. * This special texture works similar to other textures, with the exception of a few parameters.
  82944. * @see https://doc.babylonjs.com/how_to/video_texture
  82945. */
  82946. export class VideoTexture extends Texture {
  82947. /**
  82948. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82949. */
  82950. readonly autoUpdateTexture: boolean;
  82951. /**
  82952. * The video instance used by the texture internally
  82953. */
  82954. readonly video: HTMLVideoElement;
  82955. private _onUserActionRequestedObservable;
  82956. /**
  82957. * Event triggerd when a dom action is required by the user to play the video.
  82958. * This happens due to recent changes in browser policies preventing video to auto start.
  82959. */
  82960. readonly onUserActionRequestedObservable: Observable<Texture>;
  82961. private _generateMipMaps;
  82962. private _engine;
  82963. private _stillImageCaptured;
  82964. private _displayingPosterTexture;
  82965. private _settings;
  82966. private _createInternalTextureOnEvent;
  82967. /**
  82968. * Creates a video texture.
  82969. * If you want to display a video in your scene, this is the special texture for that.
  82970. * This special texture works similar to other textures, with the exception of a few parameters.
  82971. * @see https://doc.babylonjs.com/how_to/video_texture
  82972. * @param name optional name, will detect from video source, if not defined
  82973. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82974. * @param scene is obviously the current scene.
  82975. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82976. * @param invertY is false by default but can be used to invert video on Y axis
  82977. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82978. * @param settings allows finer control over video usage
  82979. */
  82980. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82981. private _getName;
  82982. private _getVideo;
  82983. private _createInternalTexture;
  82984. private reset;
  82985. /**
  82986. * @hidden Internal method to initiate `update`.
  82987. */
  82988. _rebuild(): void;
  82989. /**
  82990. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82991. */
  82992. update(): void;
  82993. /**
  82994. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82995. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82996. */
  82997. updateTexture(isVisible: boolean): void;
  82998. protected _updateInternalTexture: () => void;
  82999. /**
  83000. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83001. * @param url New url.
  83002. */
  83003. updateURL(url: string): void;
  83004. /**
  83005. * Dispose the texture and release its associated resources.
  83006. */
  83007. dispose(): void;
  83008. /**
  83009. * Creates a video texture straight from your WebCam video feed.
  83010. * @param scene Define the scene the texture should be created in
  83011. * @param onReady Define a callback to triggered once the texture will be ready
  83012. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83013. */
  83014. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83015. minWidth: number;
  83016. maxWidth: number;
  83017. minHeight: number;
  83018. maxHeight: number;
  83019. deviceId: string;
  83020. }): void;
  83021. }
  83022. }
  83023. declare module BABYLON {
  83024. /**
  83025. * Interface for attribute information associated with buffer instanciation
  83026. */
  83027. export class InstancingAttributeInfo {
  83028. /**
  83029. * Index/offset of the attribute in the vertex shader
  83030. */
  83031. index: number;
  83032. /**
  83033. * size of the attribute, 1, 2, 3 or 4
  83034. */
  83035. attributeSize: number;
  83036. /**
  83037. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83038. * default is FLOAT
  83039. */
  83040. attribyteType: number;
  83041. /**
  83042. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83043. */
  83044. normalized: boolean;
  83045. /**
  83046. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83047. */
  83048. offset: number;
  83049. /**
  83050. * Name of the GLSL attribute, for debugging purpose only
  83051. */
  83052. attributeName: string;
  83053. }
  83054. /**
  83055. * Define options used to create a depth texture
  83056. */
  83057. export class DepthTextureCreationOptions {
  83058. /** Specifies whether or not a stencil should be allocated in the texture */
  83059. generateStencil?: boolean;
  83060. /** Specifies whether or not bilinear filtering is enable on the texture */
  83061. bilinearFiltering?: boolean;
  83062. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83063. comparisonFunction?: number;
  83064. /** Specifies if the created texture is a cube texture */
  83065. isCube?: boolean;
  83066. }
  83067. /**
  83068. * Class used to describe the capabilities of the engine relatively to the current browser
  83069. */
  83070. export class EngineCapabilities {
  83071. /** Maximum textures units per fragment shader */
  83072. maxTexturesImageUnits: number;
  83073. /** Maximum texture units per vertex shader */
  83074. maxVertexTextureImageUnits: number;
  83075. /** Maximum textures units in the entire pipeline */
  83076. maxCombinedTexturesImageUnits: number;
  83077. /** Maximum texture size */
  83078. maxTextureSize: number;
  83079. /** Maximum cube texture size */
  83080. maxCubemapTextureSize: number;
  83081. /** Maximum render texture size */
  83082. maxRenderTextureSize: number;
  83083. /** Maximum number of vertex attributes */
  83084. maxVertexAttribs: number;
  83085. /** Maximum number of varyings */
  83086. maxVaryingVectors: number;
  83087. /** Maximum number of uniforms per vertex shader */
  83088. maxVertexUniformVectors: number;
  83089. /** Maximum number of uniforms per fragment shader */
  83090. maxFragmentUniformVectors: number;
  83091. /** Defines if standard derivates (dx/dy) are supported */
  83092. standardDerivatives: boolean;
  83093. /** Defines if s3tc texture compression is supported */
  83094. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83095. /** Defines if pvrtc texture compression is supported */
  83096. pvrtc: any;
  83097. /** Defines if etc1 texture compression is supported */
  83098. etc1: any;
  83099. /** Defines if etc2 texture compression is supported */
  83100. etc2: any;
  83101. /** Defines if astc texture compression is supported */
  83102. astc: any;
  83103. /** Defines if float textures are supported */
  83104. textureFloat: boolean;
  83105. /** Defines if vertex array objects are supported */
  83106. vertexArrayObject: boolean;
  83107. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83108. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83109. /** Gets the maximum level of anisotropy supported */
  83110. maxAnisotropy: number;
  83111. /** Defines if instancing is supported */
  83112. instancedArrays: boolean;
  83113. /** Defines if 32 bits indices are supported */
  83114. uintIndices: boolean;
  83115. /** Defines if high precision shaders are supported */
  83116. highPrecisionShaderSupported: boolean;
  83117. /** Defines if depth reading in the fragment shader is supported */
  83118. fragmentDepthSupported: boolean;
  83119. /** Defines if float texture linear filtering is supported*/
  83120. textureFloatLinearFiltering: boolean;
  83121. /** Defines if rendering to float textures is supported */
  83122. textureFloatRender: boolean;
  83123. /** Defines if half float textures are supported*/
  83124. textureHalfFloat: boolean;
  83125. /** Defines if half float texture linear filtering is supported*/
  83126. textureHalfFloatLinearFiltering: boolean;
  83127. /** Defines if rendering to half float textures is supported */
  83128. textureHalfFloatRender: boolean;
  83129. /** Defines if textureLOD shader command is supported */
  83130. textureLOD: boolean;
  83131. /** Defines if draw buffers extension is supported */
  83132. drawBuffersExtension: boolean;
  83133. /** Defines if depth textures are supported */
  83134. depthTextureExtension: boolean;
  83135. /** Defines if float color buffer are supported */
  83136. colorBufferFloat: boolean;
  83137. /** Gets disjoint timer query extension (null if not supported) */
  83138. timerQuery: EXT_disjoint_timer_query;
  83139. /** Defines if timestamp can be used with timer query */
  83140. canUseTimestampForTimerQuery: boolean;
  83141. /** Function used to let the system compiles shaders in background */
  83142. parallelShaderCompile: {
  83143. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83144. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83145. COMPLETION_STATUS_KHR: number;
  83146. };
  83147. }
  83148. /** Interface defining initialization parameters for Engine class */
  83149. export interface EngineOptions extends WebGLContextAttributes {
  83150. /**
  83151. * Defines if the engine should no exceed a specified device ratio
  83152. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83153. */
  83154. limitDeviceRatio?: number;
  83155. /**
  83156. * Defines if webvr should be enabled automatically
  83157. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83158. */
  83159. autoEnableWebVR?: boolean;
  83160. /**
  83161. * Defines if webgl2 should be turned off even if supported
  83162. * @see http://doc.babylonjs.com/features/webgl2
  83163. */
  83164. disableWebGL2Support?: boolean;
  83165. /**
  83166. * Defines if webaudio should be initialized as well
  83167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83168. */
  83169. audioEngine?: boolean;
  83170. /**
  83171. * Defines if animations should run using a deterministic lock step
  83172. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83173. */
  83174. deterministicLockstep?: boolean;
  83175. /** Defines the maximum steps to use with deterministic lock step mode */
  83176. lockstepMaxSteps?: number;
  83177. /**
  83178. * Defines that engine should ignore context lost events
  83179. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83180. */
  83181. doNotHandleContextLost?: boolean;
  83182. /**
  83183. * Defines that engine should ignore modifying touch action attribute and style
  83184. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83185. */
  83186. doNotHandleTouchAction?: boolean;
  83187. }
  83188. /**
  83189. * Defines the interface used by display changed events
  83190. */
  83191. export interface IDisplayChangedEventArgs {
  83192. /** Gets the vrDisplay object (if any) */
  83193. vrDisplay: Nullable<any>;
  83194. /** Gets a boolean indicating if webVR is supported */
  83195. vrSupported: boolean;
  83196. }
  83197. /**
  83198. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83199. */
  83200. export class Engine {
  83201. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83202. static ExceptionList: ({
  83203. key: string;
  83204. capture: string;
  83205. captureConstraint: number;
  83206. targets: string[];
  83207. } | {
  83208. key: string;
  83209. capture: null;
  83210. captureConstraint: null;
  83211. targets: string[];
  83212. })[];
  83213. /** Gets the list of created engines */
  83214. static readonly Instances: Engine[];
  83215. /**
  83216. * Gets the latest created engine
  83217. */
  83218. static readonly LastCreatedEngine: Nullable<Engine>;
  83219. /**
  83220. * Gets the latest created scene
  83221. */
  83222. static readonly LastCreatedScene: Nullable<Scene>;
  83223. /**
  83224. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83225. * @param flag defines which part of the materials must be marked as dirty
  83226. * @param predicate defines a predicate used to filter which materials should be affected
  83227. */
  83228. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83229. /**
  83230. * Hidden
  83231. */
  83232. static _TextureLoaders: IInternalTextureLoader[];
  83233. /** Defines that alpha blending is disabled */
  83234. static readonly ALPHA_DISABLE: number;
  83235. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83236. static readonly ALPHA_ADD: number;
  83237. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83238. static readonly ALPHA_COMBINE: number;
  83239. /** Defines that alpha blending to DEST - SRC * DEST */
  83240. static readonly ALPHA_SUBTRACT: number;
  83241. /** Defines that alpha blending to SRC * DEST */
  83242. static readonly ALPHA_MULTIPLY: number;
  83243. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83244. static readonly ALPHA_MAXIMIZED: number;
  83245. /** Defines that alpha blending to SRC + DEST */
  83246. static readonly ALPHA_ONEONE: number;
  83247. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83248. static readonly ALPHA_PREMULTIPLIED: number;
  83249. /**
  83250. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83251. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83252. */
  83253. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83254. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83255. static readonly ALPHA_INTERPOLATE: number;
  83256. /**
  83257. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83258. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83259. */
  83260. static readonly ALPHA_SCREENMODE: number;
  83261. /** Defines that the ressource is not delayed*/
  83262. static readonly DELAYLOADSTATE_NONE: number;
  83263. /** Defines that the ressource was successfully delay loaded */
  83264. static readonly DELAYLOADSTATE_LOADED: number;
  83265. /** Defines that the ressource is currently delay loading */
  83266. static readonly DELAYLOADSTATE_LOADING: number;
  83267. /** Defines that the ressource is delayed and has not started loading */
  83268. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83269. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83270. static readonly NEVER: number;
  83271. /** 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 */
  83272. static readonly ALWAYS: number;
  83273. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83274. static readonly LESS: number;
  83275. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83276. static readonly EQUAL: number;
  83277. /** 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 */
  83278. static readonly LEQUAL: number;
  83279. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83280. static readonly GREATER: number;
  83281. /** 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 */
  83282. static readonly GEQUAL: number;
  83283. /** 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 */
  83284. static readonly NOTEQUAL: number;
  83285. /** Passed to stencilOperation to specify that stencil value must be kept */
  83286. static readonly KEEP: number;
  83287. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83288. static readonly REPLACE: number;
  83289. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83290. static readonly INCR: number;
  83291. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83292. static readonly DECR: number;
  83293. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83294. static readonly INVERT: number;
  83295. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83296. static readonly INCR_WRAP: number;
  83297. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83298. static readonly DECR_WRAP: number;
  83299. /** Texture is not repeating outside of 0..1 UVs */
  83300. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83301. /** Texture is repeating outside of 0..1 UVs */
  83302. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83303. /** Texture is repeating and mirrored */
  83304. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83305. /** ALPHA */
  83306. static readonly TEXTUREFORMAT_ALPHA: number;
  83307. /** LUMINANCE */
  83308. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83309. /** LUMINANCE_ALPHA */
  83310. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83311. /** RGB */
  83312. static readonly TEXTUREFORMAT_RGB: number;
  83313. /** RGBA */
  83314. static readonly TEXTUREFORMAT_RGBA: number;
  83315. /** RED */
  83316. static readonly TEXTUREFORMAT_RED: number;
  83317. /** RED (2nd reference) */
  83318. static readonly TEXTUREFORMAT_R: number;
  83319. /** RG */
  83320. static readonly TEXTUREFORMAT_RG: number;
  83321. /** RED_INTEGER */
  83322. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83323. /** RED_INTEGER (2nd reference) */
  83324. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83325. /** RG_INTEGER */
  83326. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83327. /** RGB_INTEGER */
  83328. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83329. /** RGBA_INTEGER */
  83330. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83331. /** UNSIGNED_BYTE */
  83332. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83333. /** UNSIGNED_BYTE (2nd reference) */
  83334. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83335. /** FLOAT */
  83336. static readonly TEXTURETYPE_FLOAT: number;
  83337. /** HALF_FLOAT */
  83338. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83339. /** BYTE */
  83340. static readonly TEXTURETYPE_BYTE: number;
  83341. /** SHORT */
  83342. static readonly TEXTURETYPE_SHORT: number;
  83343. /** UNSIGNED_SHORT */
  83344. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83345. /** INT */
  83346. static readonly TEXTURETYPE_INT: number;
  83347. /** UNSIGNED_INT */
  83348. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83349. /** UNSIGNED_SHORT_4_4_4_4 */
  83350. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83351. /** UNSIGNED_SHORT_5_5_5_1 */
  83352. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83353. /** UNSIGNED_SHORT_5_6_5 */
  83354. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83355. /** UNSIGNED_INT_2_10_10_10_REV */
  83356. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83357. /** UNSIGNED_INT_24_8 */
  83358. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83359. /** UNSIGNED_INT_10F_11F_11F_REV */
  83360. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83361. /** UNSIGNED_INT_5_9_9_9_REV */
  83362. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83363. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83364. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83365. /** nearest is mag = nearest and min = nearest and mip = linear */
  83366. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83367. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83368. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83369. /** Trilinear is mag = linear and min = linear and mip = linear */
  83370. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83371. /** nearest is mag = nearest and min = nearest and mip = linear */
  83372. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83373. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83374. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83375. /** Trilinear is mag = linear and min = linear and mip = linear */
  83376. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83377. /** mag = nearest and min = nearest and mip = nearest */
  83378. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83379. /** mag = nearest and min = linear and mip = nearest */
  83380. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83381. /** mag = nearest and min = linear and mip = linear */
  83382. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83383. /** mag = nearest and min = linear and mip = none */
  83384. static readonly TEXTURE_NEAREST_LINEAR: number;
  83385. /** mag = nearest and min = nearest and mip = none */
  83386. static readonly TEXTURE_NEAREST_NEAREST: number;
  83387. /** mag = linear and min = nearest and mip = nearest */
  83388. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83389. /** mag = linear and min = nearest and mip = linear */
  83390. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83391. /** mag = linear and min = linear and mip = none */
  83392. static readonly TEXTURE_LINEAR_LINEAR: number;
  83393. /** mag = linear and min = nearest and mip = none */
  83394. static readonly TEXTURE_LINEAR_NEAREST: number;
  83395. /** Explicit coordinates mode */
  83396. static readonly TEXTURE_EXPLICIT_MODE: number;
  83397. /** Spherical coordinates mode */
  83398. static readonly TEXTURE_SPHERICAL_MODE: number;
  83399. /** Planar coordinates mode */
  83400. static readonly TEXTURE_PLANAR_MODE: number;
  83401. /** Cubic coordinates mode */
  83402. static readonly TEXTURE_CUBIC_MODE: number;
  83403. /** Projection coordinates mode */
  83404. static readonly TEXTURE_PROJECTION_MODE: number;
  83405. /** Skybox coordinates mode */
  83406. static readonly TEXTURE_SKYBOX_MODE: number;
  83407. /** Inverse Cubic coordinates mode */
  83408. static readonly TEXTURE_INVCUBIC_MODE: number;
  83409. /** Equirectangular coordinates mode */
  83410. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83411. /** Equirectangular Fixed coordinates mode */
  83412. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83413. /** Equirectangular Fixed Mirrored coordinates mode */
  83414. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83415. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83416. static readonly SCALEMODE_FLOOR: number;
  83417. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83418. static readonly SCALEMODE_NEAREST: number;
  83419. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83420. static readonly SCALEMODE_CEILING: number;
  83421. /**
  83422. * Returns the current version of the framework
  83423. */
  83424. static readonly Version: string;
  83425. /**
  83426. * Returns a string describing the current engine
  83427. */
  83428. readonly description: string;
  83429. /**
  83430. * Gets or sets the epsilon value used by collision engine
  83431. */
  83432. static CollisionsEpsilon: number;
  83433. /**
  83434. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83435. */
  83436. static ShadersRepository: string;
  83437. /**
  83438. * Method called to create the default loading screen.
  83439. * This can be overriden in your own app.
  83440. * @param canvas The rendering canvas element
  83441. * @returns The loading screen
  83442. */
  83443. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83444. /**
  83445. * Method called to create the default rescale post process on each engine.
  83446. */
  83447. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83448. /**
  83449. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83450. */
  83451. forcePOTTextures: boolean;
  83452. /**
  83453. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83454. */
  83455. isFullscreen: boolean;
  83456. /**
  83457. * Gets a boolean indicating if the pointer is currently locked
  83458. */
  83459. isPointerLock: boolean;
  83460. /**
  83461. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83462. */
  83463. cullBackFaces: boolean;
  83464. /**
  83465. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83466. */
  83467. renderEvenInBackground: boolean;
  83468. /**
  83469. * Gets or sets a boolean indicating that cache can be kept between frames
  83470. */
  83471. preventCacheWipeBetweenFrames: boolean;
  83472. /**
  83473. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83474. **/
  83475. enableOfflineSupport: boolean;
  83476. /**
  83477. * 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)
  83478. **/
  83479. disableManifestCheck: boolean;
  83480. /**
  83481. * Gets the list of created scenes
  83482. */
  83483. scenes: Scene[];
  83484. /**
  83485. * Event raised when a new scene is created
  83486. */
  83487. onNewSceneAddedObservable: Observable<Scene>;
  83488. /**
  83489. * Gets the list of created postprocesses
  83490. */
  83491. postProcesses: PostProcess[];
  83492. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83493. validateShaderPrograms: boolean;
  83494. /**
  83495. * Observable event triggered each time the rendering canvas is resized
  83496. */
  83497. onResizeObservable: Observable<Engine>;
  83498. /**
  83499. * Observable event triggered each time the canvas loses focus
  83500. */
  83501. onCanvasBlurObservable: Observable<Engine>;
  83502. /**
  83503. * Observable event triggered each time the canvas gains focus
  83504. */
  83505. onCanvasFocusObservable: Observable<Engine>;
  83506. /**
  83507. * Observable event triggered each time the canvas receives pointerout event
  83508. */
  83509. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83510. /**
  83511. * Observable event triggered before each texture is initialized
  83512. */
  83513. onBeforeTextureInitObservable: Observable<Texture>;
  83514. private _vrDisplay;
  83515. private _vrSupported;
  83516. private _oldSize;
  83517. private _oldHardwareScaleFactor;
  83518. private _vrExclusivePointerMode;
  83519. private _webVRInitPromise;
  83520. /**
  83521. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83522. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83523. */
  83524. readonly isInVRExclusivePointerMode: boolean;
  83525. /**
  83526. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83527. */
  83528. disableUniformBuffers: boolean;
  83529. /** @hidden */
  83530. _uniformBuffers: UniformBuffer[];
  83531. /**
  83532. * Gets a boolean indicating that the engine supports uniform buffers
  83533. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83534. */
  83535. readonly supportsUniformBuffers: boolean;
  83536. /**
  83537. * Observable raised when the engine begins a new frame
  83538. */
  83539. onBeginFrameObservable: Observable<Engine>;
  83540. /**
  83541. * If set, will be used to request the next animation frame for the render loop
  83542. */
  83543. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83544. /**
  83545. * Observable raised when the engine ends the current frame
  83546. */
  83547. onEndFrameObservable: Observable<Engine>;
  83548. /**
  83549. * Observable raised when the engine is about to compile a shader
  83550. */
  83551. onBeforeShaderCompilationObservable: Observable<Engine>;
  83552. /**
  83553. * Observable raised when the engine has jsut compiled a shader
  83554. */
  83555. onAfterShaderCompilationObservable: Observable<Engine>;
  83556. /** @hidden */
  83557. _gl: WebGLRenderingContext;
  83558. private _renderingCanvas;
  83559. private _windowIsBackground;
  83560. private _webGLVersion;
  83561. /**
  83562. * Gets a boolean indicating that only power of 2 textures are supported
  83563. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83564. */
  83565. readonly needPOTTextures: boolean;
  83566. /** @hidden */
  83567. _badOS: boolean;
  83568. /** @hidden */
  83569. _badDesktopOS: boolean;
  83570. /**
  83571. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83572. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83573. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83574. */
  83575. disableTextureBindingOptimization: boolean;
  83576. /**
  83577. * Gets the audio engine
  83578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83579. * @ignorenaming
  83580. */
  83581. static audioEngine: IAudioEngine;
  83582. /**
  83583. * Default AudioEngine factory responsible of creating the Audio Engine.
  83584. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83585. */
  83586. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83587. /**
  83588. * Default offline support factory responsible of creating a tool used to store data locally.
  83589. * By default, this will create a Database object if the workload has been embedded.
  83590. */
  83591. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83592. private _onFocus;
  83593. private _onBlur;
  83594. private _onCanvasPointerOut;
  83595. private _onCanvasBlur;
  83596. private _onCanvasFocus;
  83597. private _onFullscreenChange;
  83598. private _onPointerLockChange;
  83599. private _onVRDisplayPointerRestricted;
  83600. private _onVRDisplayPointerUnrestricted;
  83601. private _onVrDisplayConnect;
  83602. private _onVrDisplayDisconnect;
  83603. private _onVrDisplayPresentChange;
  83604. /**
  83605. * Observable signaled when VR display mode changes
  83606. */
  83607. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83608. /**
  83609. * Observable signaled when VR request present is complete
  83610. */
  83611. onVRRequestPresentComplete: Observable<boolean>;
  83612. /**
  83613. * Observable signaled when VR request present starts
  83614. */
  83615. onVRRequestPresentStart: Observable<Engine>;
  83616. private _hardwareScalingLevel;
  83617. /** @hidden */
  83618. protected _caps: EngineCapabilities;
  83619. private _pointerLockRequested;
  83620. private _isStencilEnable;
  83621. private _colorWrite;
  83622. private _loadingScreen;
  83623. /** @hidden */
  83624. _drawCalls: PerfCounter;
  83625. /** @hidden */
  83626. _textureCollisions: PerfCounter;
  83627. private _glVersion;
  83628. private _glRenderer;
  83629. private _glVendor;
  83630. private _videoTextureSupported;
  83631. private _renderingQueueLaunched;
  83632. private _activeRenderLoops;
  83633. private _deterministicLockstep;
  83634. private _lockstepMaxSteps;
  83635. /**
  83636. * Observable signaled when a context lost event is raised
  83637. */
  83638. onContextLostObservable: Observable<Engine>;
  83639. /**
  83640. * Observable signaled when a context restored event is raised
  83641. */
  83642. onContextRestoredObservable: Observable<Engine>;
  83643. private _onContextLost;
  83644. private _onContextRestored;
  83645. private _contextWasLost;
  83646. private _doNotHandleContextLost;
  83647. /**
  83648. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83650. */
  83651. doNotHandleContextLost: boolean;
  83652. private _performanceMonitor;
  83653. private _fps;
  83654. private _deltaTime;
  83655. /**
  83656. * Turn this value on if you want to pause FPS computation when in background
  83657. */
  83658. disablePerformanceMonitorInBackground: boolean;
  83659. /**
  83660. * Gets the performance monitor attached to this engine
  83661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83662. */
  83663. readonly performanceMonitor: PerformanceMonitor;
  83664. /** @hidden */
  83665. protected _depthCullingState: _DepthCullingState;
  83666. /** @hidden */
  83667. protected _stencilState: _StencilState;
  83668. /** @hidden */
  83669. protected _alphaState: _AlphaState;
  83670. /** @hidden */
  83671. protected _alphaMode: number;
  83672. protected _internalTexturesCache: InternalTexture[];
  83673. /** @hidden */
  83674. protected _activeChannel: number;
  83675. private _currentTextureChannel;
  83676. /** @hidden */
  83677. protected _boundTexturesCache: {
  83678. [key: string]: Nullable<InternalTexture>;
  83679. };
  83680. /** @hidden */
  83681. protected _currentEffect: Nullable<Effect>;
  83682. /** @hidden */
  83683. protected _currentProgram: Nullable<WebGLProgram>;
  83684. private _compiledEffects;
  83685. private _vertexAttribArraysEnabled;
  83686. /** @hidden */
  83687. protected _cachedViewport: Nullable<Viewport>;
  83688. private _cachedVertexArrayObject;
  83689. /** @hidden */
  83690. protected _cachedVertexBuffers: any;
  83691. /** @hidden */
  83692. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83693. /** @hidden */
  83694. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83695. /** @hidden */
  83696. protected _currentRenderTarget: Nullable<InternalTexture>;
  83697. private _uintIndicesCurrentlySet;
  83698. private _currentBoundBuffer;
  83699. /** @hidden */
  83700. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83701. private _currentBufferPointers;
  83702. private _currentInstanceLocations;
  83703. private _currentInstanceBuffers;
  83704. private _textureUnits;
  83705. private _firstBoundInternalTextureTracker;
  83706. private _lastBoundInternalTextureTracker;
  83707. private _workingCanvas;
  83708. private _workingContext;
  83709. private _rescalePostProcess;
  83710. private _dummyFramebuffer;
  83711. private _externalData;
  83712. private _bindedRenderFunction;
  83713. private _vaoRecordInProgress;
  83714. private _mustWipeVertexAttributes;
  83715. private _emptyTexture;
  83716. private _emptyCubeTexture;
  83717. private _emptyTexture3D;
  83718. /** @hidden */
  83719. _frameHandler: number;
  83720. private _nextFreeTextureSlots;
  83721. private _maxSimultaneousTextures;
  83722. private _activeRequests;
  83723. private _texturesSupported;
  83724. private _textureFormatInUse;
  83725. /**
  83726. * Gets the list of texture formats supported
  83727. */
  83728. readonly texturesSupported: Array<string>;
  83729. /**
  83730. * Gets the list of texture formats in use
  83731. */
  83732. readonly textureFormatInUse: Nullable<string>;
  83733. /**
  83734. * Gets the current viewport
  83735. */
  83736. readonly currentViewport: Nullable<Viewport>;
  83737. /**
  83738. * Gets the default empty texture
  83739. */
  83740. readonly emptyTexture: InternalTexture;
  83741. /**
  83742. * Gets the default empty 3D texture
  83743. */
  83744. readonly emptyTexture3D: InternalTexture;
  83745. /**
  83746. * Gets the default empty cube texture
  83747. */
  83748. readonly emptyCubeTexture: InternalTexture;
  83749. /**
  83750. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83751. */
  83752. readonly premultipliedAlpha: boolean;
  83753. /**
  83754. * Creates a new engine
  83755. * @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
  83756. * @param antialias defines enable antialiasing (default: false)
  83757. * @param options defines further options to be sent to the getContext() function
  83758. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83759. */
  83760. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83761. private _disableTouchAction;
  83762. private _rebuildInternalTextures;
  83763. private _rebuildEffects;
  83764. /**
  83765. * Gets a boolean indicating if all created effects are ready
  83766. * @returns true if all effects are ready
  83767. */
  83768. areAllEffectsReady(): boolean;
  83769. private _rebuildBuffers;
  83770. private _initGLContext;
  83771. /**
  83772. * Gets version of the current webGL context
  83773. */
  83774. readonly webGLVersion: number;
  83775. /**
  83776. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83777. */
  83778. readonly isStencilEnable: boolean;
  83779. private _prepareWorkingCanvas;
  83780. /**
  83781. * Reset the texture cache to empty state
  83782. */
  83783. resetTextureCache(): void;
  83784. /**
  83785. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83787. * @returns true if engine is in deterministic lock step mode
  83788. */
  83789. isDeterministicLockStep(): boolean;
  83790. /**
  83791. * Gets the max steps when engine is running in deterministic lock step
  83792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83793. * @returns the max steps
  83794. */
  83795. getLockstepMaxSteps(): number;
  83796. /**
  83797. * Gets an object containing information about the current webGL context
  83798. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83799. */
  83800. getGlInfo(): {
  83801. vendor: string;
  83802. renderer: string;
  83803. version: string;
  83804. };
  83805. /**
  83806. * Gets current aspect ratio
  83807. * @param camera defines the camera to use to get the aspect ratio
  83808. * @param useScreen defines if screen size must be used (or the current render target if any)
  83809. * @returns a number defining the aspect ratio
  83810. */
  83811. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83812. /**
  83813. * Gets current screen aspect ratio
  83814. * @returns a number defining the aspect ratio
  83815. */
  83816. getScreenAspectRatio(): number;
  83817. /**
  83818. * Gets the current render width
  83819. * @param useScreen defines if screen size must be used (or the current render target if any)
  83820. * @returns a number defining the current render width
  83821. */
  83822. getRenderWidth(useScreen?: boolean): number;
  83823. /**
  83824. * Gets the current render height
  83825. * @param useScreen defines if screen size must be used (or the current render target if any)
  83826. * @returns a number defining the current render height
  83827. */
  83828. getRenderHeight(useScreen?: boolean): number;
  83829. /**
  83830. * Gets the HTML canvas attached with the current webGL context
  83831. * @returns a HTML canvas
  83832. */
  83833. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83834. /**
  83835. * Gets the client rect of the HTML canvas attached with the current webGL context
  83836. * @returns a client rectanglee
  83837. */
  83838. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83839. /**
  83840. * Defines the hardware scaling level.
  83841. * By default the hardware scaling level is computed from the window device ratio.
  83842. * 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.
  83843. * @param level defines the level to use
  83844. */
  83845. setHardwareScalingLevel(level: number): void;
  83846. /**
  83847. * Gets the current hardware scaling level.
  83848. * By default the hardware scaling level is computed from the window device ratio.
  83849. * 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.
  83850. * @returns a number indicating the current hardware scaling level
  83851. */
  83852. getHardwareScalingLevel(): number;
  83853. /**
  83854. * Gets the list of loaded textures
  83855. * @returns an array containing all loaded textures
  83856. */
  83857. getLoadedTexturesCache(): InternalTexture[];
  83858. /**
  83859. * Gets the object containing all engine capabilities
  83860. * @returns the EngineCapabilities object
  83861. */
  83862. getCaps(): EngineCapabilities;
  83863. /**
  83864. * Gets the current depth function
  83865. * @returns a number defining the depth function
  83866. */
  83867. getDepthFunction(): Nullable<number>;
  83868. /**
  83869. * Sets the current depth function
  83870. * @param depthFunc defines the function to use
  83871. */
  83872. setDepthFunction(depthFunc: number): void;
  83873. /**
  83874. * Sets the current depth function to GREATER
  83875. */
  83876. setDepthFunctionToGreater(): void;
  83877. /**
  83878. * Sets the current depth function to GEQUAL
  83879. */
  83880. setDepthFunctionToGreaterOrEqual(): void;
  83881. /**
  83882. * Sets the current depth function to LESS
  83883. */
  83884. setDepthFunctionToLess(): void;
  83885. /**
  83886. * Sets the current depth function to LEQUAL
  83887. */
  83888. setDepthFunctionToLessOrEqual(): void;
  83889. /**
  83890. * Gets a boolean indicating if stencil buffer is enabled
  83891. * @returns the current stencil buffer state
  83892. */
  83893. getStencilBuffer(): boolean;
  83894. /**
  83895. * Enable or disable the stencil buffer
  83896. * @param enable defines if the stencil buffer must be enabled or disabled
  83897. */
  83898. setStencilBuffer(enable: boolean): void;
  83899. /**
  83900. * Gets the current stencil mask
  83901. * @returns a number defining the new stencil mask to use
  83902. */
  83903. getStencilMask(): number;
  83904. /**
  83905. * Sets the current stencil mask
  83906. * @param mask defines the new stencil mask to use
  83907. */
  83908. setStencilMask(mask: number): void;
  83909. /**
  83910. * Gets the current stencil function
  83911. * @returns a number defining the stencil function to use
  83912. */
  83913. getStencilFunction(): number;
  83914. /**
  83915. * Gets the current stencil reference value
  83916. * @returns a number defining the stencil reference value to use
  83917. */
  83918. getStencilFunctionReference(): number;
  83919. /**
  83920. * Gets the current stencil mask
  83921. * @returns a number defining the stencil mask to use
  83922. */
  83923. getStencilFunctionMask(): number;
  83924. /**
  83925. * Sets the current stencil function
  83926. * @param stencilFunc defines the new stencil function to use
  83927. */
  83928. setStencilFunction(stencilFunc: number): void;
  83929. /**
  83930. * Sets the current stencil reference
  83931. * @param reference defines the new stencil reference to use
  83932. */
  83933. setStencilFunctionReference(reference: number): void;
  83934. /**
  83935. * Sets the current stencil mask
  83936. * @param mask defines the new stencil mask to use
  83937. */
  83938. setStencilFunctionMask(mask: number): void;
  83939. /**
  83940. * Gets the current stencil operation when stencil fails
  83941. * @returns a number defining stencil operation to use when stencil fails
  83942. */
  83943. getStencilOperationFail(): number;
  83944. /**
  83945. * Gets the current stencil operation when depth fails
  83946. * @returns a number defining stencil operation to use when depth fails
  83947. */
  83948. getStencilOperationDepthFail(): number;
  83949. /**
  83950. * Gets the current stencil operation when stencil passes
  83951. * @returns a number defining stencil operation to use when stencil passes
  83952. */
  83953. getStencilOperationPass(): number;
  83954. /**
  83955. * Sets the stencil operation to use when stencil fails
  83956. * @param operation defines the stencil operation to use when stencil fails
  83957. */
  83958. setStencilOperationFail(operation: number): void;
  83959. /**
  83960. * Sets the stencil operation to use when depth fails
  83961. * @param operation defines the stencil operation to use when depth fails
  83962. */
  83963. setStencilOperationDepthFail(operation: number): void;
  83964. /**
  83965. * Sets the stencil operation to use when stencil passes
  83966. * @param operation defines the stencil operation to use when stencil passes
  83967. */
  83968. setStencilOperationPass(operation: number): void;
  83969. /**
  83970. * Sets a boolean indicating if the dithering state is enabled or disabled
  83971. * @param value defines the dithering state
  83972. */
  83973. setDitheringState(value: boolean): void;
  83974. /**
  83975. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83976. * @param value defines the rasterizer state
  83977. */
  83978. setRasterizerState(value: boolean): void;
  83979. /**
  83980. * stop executing a render loop function and remove it from the execution array
  83981. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83982. */
  83983. stopRenderLoop(renderFunction?: () => void): void;
  83984. /** @hidden */
  83985. _renderLoop(): void;
  83986. /**
  83987. * Register and execute a render loop. The engine can have more than one render function
  83988. * @param renderFunction defines the function to continuously execute
  83989. */
  83990. runRenderLoop(renderFunction: () => void): void;
  83991. /**
  83992. * Toggle full screen mode
  83993. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83994. */
  83995. switchFullscreen(requestPointerLock: boolean): void;
  83996. /**
  83997. * Clear the current render buffer or the current render target (if any is set up)
  83998. * @param color defines the color to use
  83999. * @param backBuffer defines if the back buffer must be cleared
  84000. * @param depth defines if the depth buffer must be cleared
  84001. * @param stencil defines if the stencil buffer must be cleared
  84002. */
  84003. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84004. /**
  84005. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84006. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84007. * @param y defines the y-coordinate of the corner of the clear rectangle
  84008. * @param width defines the width of the clear rectangle
  84009. * @param height defines the height of the clear rectangle
  84010. * @param clearColor defines the clear color
  84011. */
  84012. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84013. /**
  84014. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84015. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84016. * @param y defines the y-coordinate of the corner of the clear rectangle
  84017. * @param width defines the width of the clear rectangle
  84018. * @param height defines the height of the clear rectangle
  84019. */
  84020. enableScissor(x: number, y: number, width: number, height: number): void;
  84021. /**
  84022. * Disable previously set scissor test rectangle
  84023. */
  84024. disableScissor(): void;
  84025. private _viewportCached;
  84026. /** @hidden */
  84027. _viewport(x: number, y: number, width: number, height: number): void;
  84028. /**
  84029. * Set the WebGL's viewport
  84030. * @param viewport defines the viewport element to be used
  84031. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84032. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84033. */
  84034. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84035. /**
  84036. * Directly set the WebGL Viewport
  84037. * @param x defines the x coordinate of the viewport (in screen space)
  84038. * @param y defines the y coordinate of the viewport (in screen space)
  84039. * @param width defines the width of the viewport (in screen space)
  84040. * @param height defines the height of the viewport (in screen space)
  84041. * @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
  84042. */
  84043. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84044. /**
  84045. * Begin a new frame
  84046. */
  84047. beginFrame(): void;
  84048. /**
  84049. * Enf the current frame
  84050. */
  84051. endFrame(): void;
  84052. /**
  84053. * Resize the view according to the canvas' size
  84054. */
  84055. resize(): void;
  84056. /**
  84057. * Force a specific size of the canvas
  84058. * @param width defines the new canvas' width
  84059. * @param height defines the new canvas' height
  84060. */
  84061. setSize(width: number, height: number): void;
  84062. /**
  84063. * Gets a boolean indicating if a webVR device was detected
  84064. * @returns true if a webVR device was detected
  84065. */
  84066. isVRDevicePresent(): boolean;
  84067. /**
  84068. * Gets the current webVR device
  84069. * @returns the current webVR device (or null)
  84070. */
  84071. getVRDevice(): any;
  84072. /**
  84073. * Initializes a webVR display and starts listening to display change events
  84074. * The onVRDisplayChangedObservable will be notified upon these changes
  84075. * @returns The onVRDisplayChangedObservable
  84076. */
  84077. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84078. /**
  84079. * Initializes a webVR display and starts listening to display change events
  84080. * The onVRDisplayChangedObservable will be notified upon these changes
  84081. * @returns A promise containing a VRDisplay and if vr is supported
  84082. */
  84083. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84084. /**
  84085. * Call this function to switch to webVR mode
  84086. * Will do nothing if webVR is not supported or if there is no webVR device
  84087. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84088. */
  84089. enableVR(): void;
  84090. /**
  84091. * Call this function to leave webVR mode
  84092. * Will do nothing if webVR is not supported or if there is no webVR device
  84093. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84094. */
  84095. disableVR(): void;
  84096. private _onVRFullScreenTriggered;
  84097. private _getVRDisplaysAsync;
  84098. /**
  84099. * Binds the frame buffer to the specified texture.
  84100. * @param texture The texture to render to or null for the default canvas
  84101. * @param faceIndex The face of the texture to render to in case of cube texture
  84102. * @param requiredWidth The width of the target to render to
  84103. * @param requiredHeight The height of the target to render to
  84104. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84105. * @param depthStencilTexture The depth stencil texture to use to render
  84106. * @param lodLevel defines le lod level to bind to the frame buffer
  84107. */
  84108. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84109. private bindUnboundFramebuffer;
  84110. /**
  84111. * Unbind the current render target texture from the webGL context
  84112. * @param texture defines the render target texture to unbind
  84113. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84114. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84115. */
  84116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84117. /**
  84118. * Unbind a list of render target textures from the webGL context
  84119. * This is used only when drawBuffer extension or webGL2 are active
  84120. * @param textures defines the render target textures to unbind
  84121. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84122. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84123. */
  84124. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84125. /**
  84126. * Force the mipmap generation for the given render target texture
  84127. * @param texture defines the render target texture to use
  84128. */
  84129. generateMipMapsForCubemap(texture: InternalTexture): void;
  84130. /**
  84131. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84132. */
  84133. flushFramebuffer(): void;
  84134. /**
  84135. * Unbind the current render target and bind the default framebuffer
  84136. */
  84137. restoreDefaultFramebuffer(): void;
  84138. /**
  84139. * Create an uniform buffer
  84140. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84141. * @param elements defines the content of the uniform buffer
  84142. * @returns the webGL uniform buffer
  84143. */
  84144. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84145. /**
  84146. * Create a dynamic uniform buffer
  84147. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84148. * @param elements defines the content of the uniform buffer
  84149. * @returns the webGL uniform buffer
  84150. */
  84151. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84152. /**
  84153. * Update an existing uniform buffer
  84154. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84155. * @param uniformBuffer defines the target uniform buffer
  84156. * @param elements defines the content to update
  84157. * @param offset defines the offset in the uniform buffer where update should start
  84158. * @param count defines the size of the data to update
  84159. */
  84160. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84161. private _resetVertexBufferBinding;
  84162. /**
  84163. * Creates a vertex buffer
  84164. * @param data the data for the vertex buffer
  84165. * @returns the new WebGL static buffer
  84166. */
  84167. createVertexBuffer(data: DataArray): WebGLBuffer;
  84168. /**
  84169. * Creates a dynamic vertex buffer
  84170. * @param data the data for the dynamic vertex buffer
  84171. * @returns the new WebGL dynamic buffer
  84172. */
  84173. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84174. /**
  84175. * Update a dynamic index buffer
  84176. * @param indexBuffer defines the target index buffer
  84177. * @param indices defines the data to update
  84178. * @param offset defines the offset in the target index buffer where update should start
  84179. */
  84180. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84181. /**
  84182. * Updates a dynamic vertex buffer.
  84183. * @param vertexBuffer the vertex buffer to update
  84184. * @param data the data used to update the vertex buffer
  84185. * @param byteOffset the byte offset of the data
  84186. * @param byteLength the byte length of the data
  84187. */
  84188. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84189. private _resetIndexBufferBinding;
  84190. /**
  84191. * Creates a new index buffer
  84192. * @param indices defines the content of the index buffer
  84193. * @param updatable defines if the index buffer must be updatable
  84194. * @returns a new webGL buffer
  84195. */
  84196. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84197. /**
  84198. * Bind a webGL buffer to the webGL context
  84199. * @param buffer defines the buffer to bind
  84200. */
  84201. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84202. /**
  84203. * Bind an uniform buffer to the current webGL context
  84204. * @param buffer defines the buffer to bind
  84205. */
  84206. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84207. /**
  84208. * Bind a buffer to the current webGL context at a given location
  84209. * @param buffer defines the buffer to bind
  84210. * @param location defines the index where to bind the buffer
  84211. */
  84212. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84213. /**
  84214. * Bind a specific block at a given index in a specific shader program
  84215. * @param shaderProgram defines the shader program
  84216. * @param blockName defines the block name
  84217. * @param index defines the index where to bind the block
  84218. */
  84219. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84220. private bindIndexBuffer;
  84221. private bindBuffer;
  84222. /**
  84223. * update the bound buffer with the given data
  84224. * @param data defines the data to update
  84225. */
  84226. updateArrayBuffer(data: Float32Array): void;
  84227. private _vertexAttribPointer;
  84228. private _bindIndexBufferWithCache;
  84229. private _bindVertexBuffersAttributes;
  84230. /**
  84231. * Records a vertex array object
  84232. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84233. * @param vertexBuffers defines the list of vertex buffers to store
  84234. * @param indexBuffer defines the index buffer to store
  84235. * @param effect defines the effect to store
  84236. * @returns the new vertex array object
  84237. */
  84238. recordVertexArrayObject(vertexBuffers: {
  84239. [key: string]: VertexBuffer;
  84240. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84241. /**
  84242. * Bind a specific vertex array object
  84243. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84244. * @param vertexArrayObject defines the vertex array object to bind
  84245. * @param indexBuffer defines the index buffer to bind
  84246. */
  84247. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84248. /**
  84249. * Bind webGl buffers directly to the webGL context
  84250. * @param vertexBuffer defines the vertex buffer to bind
  84251. * @param indexBuffer defines the index buffer to bind
  84252. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84253. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84254. * @param effect defines the effect associated with the vertex buffer
  84255. */
  84256. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84257. private _unbindVertexArrayObject;
  84258. /**
  84259. * Bind a list of vertex buffers to the webGL context
  84260. * @param vertexBuffers defines the list of vertex buffers to bind
  84261. * @param indexBuffer defines the index buffer to bind
  84262. * @param effect defines the effect associated with the vertex buffers
  84263. */
  84264. bindBuffers(vertexBuffers: {
  84265. [key: string]: Nullable<VertexBuffer>;
  84266. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84267. /**
  84268. * Unbind all instance attributes
  84269. */
  84270. unbindInstanceAttributes(): void;
  84271. /**
  84272. * Release and free the memory of a vertex array object
  84273. * @param vao defines the vertex array object to delete
  84274. */
  84275. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84276. /** @hidden */
  84277. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84278. /**
  84279. * Creates a webGL buffer to use with instanciation
  84280. * @param capacity defines the size of the buffer
  84281. * @returns the webGL buffer
  84282. */
  84283. createInstancesBuffer(capacity: number): WebGLBuffer;
  84284. /**
  84285. * Delete a webGL buffer used with instanciation
  84286. * @param buffer defines the webGL buffer to delete
  84287. */
  84288. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84289. /**
  84290. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84291. * @param instancesBuffer defines the webGL buffer to update and bind
  84292. * @param data defines the data to store in the buffer
  84293. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84294. */
  84295. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84296. /**
  84297. * Apply all cached states (depth, culling, stencil and alpha)
  84298. */
  84299. applyStates(): void;
  84300. /**
  84301. * Send a draw order
  84302. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84303. * @param indexStart defines the starting index
  84304. * @param indexCount defines the number of index to draw
  84305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84306. */
  84307. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84308. /**
  84309. * Draw a list of points
  84310. * @param verticesStart defines the index of first vertex to draw
  84311. * @param verticesCount defines the count of vertices to draw
  84312. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84313. */
  84314. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84315. /**
  84316. * Draw a list of unindexed primitives
  84317. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84318. * @param verticesStart defines the index of first vertex to draw
  84319. * @param verticesCount defines the count of vertices to draw
  84320. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84321. */
  84322. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84323. /**
  84324. * Draw a list of indexed primitives
  84325. * @param fillMode defines the primitive to use
  84326. * @param indexStart defines the starting index
  84327. * @param indexCount defines the number of index to draw
  84328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84329. */
  84330. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84331. /**
  84332. * Draw a list of unindexed primitives
  84333. * @param fillMode defines the primitive to use
  84334. * @param verticesStart defines the index of first vertex to draw
  84335. * @param verticesCount defines the count of vertices to draw
  84336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84337. */
  84338. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84339. private _drawMode;
  84340. /** @hidden */
  84341. _releaseEffect(effect: Effect): void;
  84342. /** @hidden */
  84343. _deleteProgram(program: WebGLProgram): void;
  84344. /**
  84345. * Create a new effect (used to store vertex/fragment shaders)
  84346. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84347. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84348. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84349. * @param samplers defines an array of string used to represent textures
  84350. * @param defines defines the string containing the defines to use to compile the shaders
  84351. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84352. * @param onCompiled defines a function to call when the effect creation is successful
  84353. * @param onError defines a function to call when the effect creation has failed
  84354. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84355. * @returns the new Effect
  84356. */
  84357. 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;
  84358. private _compileShader;
  84359. private _compileRawShader;
  84360. /**
  84361. * Directly creates a webGL program
  84362. * @param vertexCode defines the vertex shader code to use
  84363. * @param fragmentCode defines the fragment shader code to use
  84364. * @param context defines the webGL context to use (if not set, the current one will be used)
  84365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84366. * @returns the new webGL program
  84367. */
  84368. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84369. /**
  84370. * Creates a webGL program
  84371. * @param vertexCode defines the vertex shader code to use
  84372. * @param fragmentCode defines the fragment shader code to use
  84373. * @param defines defines the string containing the defines to use to compile the shaders
  84374. * @param context defines the webGL context to use (if not set, the current one will be used)
  84375. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84376. * @returns the new webGL program
  84377. */
  84378. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84379. private _createShaderProgram;
  84380. private _finalizeProgram;
  84381. /** @hidden */
  84382. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84383. /** @hidden */
  84384. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84385. /**
  84386. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84387. * @param shaderProgram defines the webGL program to use
  84388. * @param uniformsNames defines the list of uniform names
  84389. * @returns an array of webGL uniform locations
  84390. */
  84391. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84392. /**
  84393. * Gets the lsit of active attributes for a given webGL program
  84394. * @param shaderProgram defines the webGL program to use
  84395. * @param attributesNames defines the list of attribute names to get
  84396. * @returns an array of indices indicating the offset of each attribute
  84397. */
  84398. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84399. /**
  84400. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84401. * @param effect defines the effect to activate
  84402. */
  84403. enableEffect(effect: Nullable<Effect>): void;
  84404. /**
  84405. * Set the value of an uniform to an array of int32
  84406. * @param uniform defines the webGL uniform location where to store the value
  84407. * @param array defines the array of int32 to store
  84408. */
  84409. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84410. /**
  84411. * Set the value of an uniform to an array of int32 (stored as vec2)
  84412. * @param uniform defines the webGL uniform location where to store the value
  84413. * @param array defines the array of int32 to store
  84414. */
  84415. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84416. /**
  84417. * Set the value of an uniform to an array of int32 (stored as vec3)
  84418. * @param uniform defines the webGL uniform location where to store the value
  84419. * @param array defines the array of int32 to store
  84420. */
  84421. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84422. /**
  84423. * Set the value of an uniform to an array of int32 (stored as vec4)
  84424. * @param uniform defines the webGL uniform location where to store the value
  84425. * @param array defines the array of int32 to store
  84426. */
  84427. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84428. /**
  84429. * Set the value of an uniform to an array of float32
  84430. * @param uniform defines the webGL uniform location where to store the value
  84431. * @param array defines the array of float32 to store
  84432. */
  84433. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84434. /**
  84435. * Set the value of an uniform to an array of float32 (stored as vec2)
  84436. * @param uniform defines the webGL uniform location where to store the value
  84437. * @param array defines the array of float32 to store
  84438. */
  84439. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84440. /**
  84441. * Set the value of an uniform to an array of float32 (stored as vec3)
  84442. * @param uniform defines the webGL uniform location where to store the value
  84443. * @param array defines the array of float32 to store
  84444. */
  84445. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84446. /**
  84447. * Set the value of an uniform to an array of float32 (stored as vec4)
  84448. * @param uniform defines the webGL uniform location where to store the value
  84449. * @param array defines the array of float32 to store
  84450. */
  84451. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84452. /**
  84453. * Set the value of an uniform to an array of number
  84454. * @param uniform defines the webGL uniform location where to store the value
  84455. * @param array defines the array of number to store
  84456. */
  84457. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84458. /**
  84459. * Set the value of an uniform to an array of number (stored as vec2)
  84460. * @param uniform defines the webGL uniform location where to store the value
  84461. * @param array defines the array of number to store
  84462. */
  84463. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84464. /**
  84465. * Set the value of an uniform to an array of number (stored as vec3)
  84466. * @param uniform defines the webGL uniform location where to store the value
  84467. * @param array defines the array of number to store
  84468. */
  84469. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84470. /**
  84471. * Set the value of an uniform to an array of number (stored as vec4)
  84472. * @param uniform defines the webGL uniform location where to store the value
  84473. * @param array defines the array of number to store
  84474. */
  84475. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84476. /**
  84477. * Set the value of an uniform to an array of float32 (stored as matrices)
  84478. * @param uniform defines the webGL uniform location where to store the value
  84479. * @param matrices defines the array of float32 to store
  84480. */
  84481. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84482. /**
  84483. * Set the value of an uniform to a matrix
  84484. * @param uniform defines the webGL uniform location where to store the value
  84485. * @param matrix defines the matrix to store
  84486. */
  84487. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84488. /**
  84489. * Set the value of an uniform to a matrix (3x3)
  84490. * @param uniform defines the webGL uniform location where to store the value
  84491. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84492. */
  84493. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84494. /**
  84495. * Set the value of an uniform to a matrix (2x2)
  84496. * @param uniform defines the webGL uniform location where to store the value
  84497. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84498. */
  84499. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84500. /**
  84501. * Set the value of an uniform to a number (int)
  84502. * @param uniform defines the webGL uniform location where to store the value
  84503. * @param value defines the int number to store
  84504. */
  84505. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84506. /**
  84507. * Set the value of an uniform to a number (float)
  84508. * @param uniform defines the webGL uniform location where to store the value
  84509. * @param value defines the float number to store
  84510. */
  84511. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84512. /**
  84513. * Set the value of an uniform to a vec2
  84514. * @param uniform defines the webGL uniform location where to store the value
  84515. * @param x defines the 1st component of the value
  84516. * @param y defines the 2nd component of the value
  84517. */
  84518. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84519. /**
  84520. * Set the value of an uniform to a vec3
  84521. * @param uniform defines the webGL uniform location where to store the value
  84522. * @param x defines the 1st component of the value
  84523. * @param y defines the 2nd component of the value
  84524. * @param z defines the 3rd component of the value
  84525. */
  84526. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84527. /**
  84528. * Set the value of an uniform to a boolean
  84529. * @param uniform defines the webGL uniform location where to store the value
  84530. * @param bool defines the boolean to store
  84531. */
  84532. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84533. /**
  84534. * Set the value of an uniform to a vec4
  84535. * @param uniform defines the webGL uniform location where to store the value
  84536. * @param x defines the 1st component of the value
  84537. * @param y defines the 2nd component of the value
  84538. * @param z defines the 3rd component of the value
  84539. * @param w defines the 4th component of the value
  84540. */
  84541. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84542. /**
  84543. * Set the value of an uniform to a Color3
  84544. * @param uniform defines the webGL uniform location where to store the value
  84545. * @param color3 defines the color to store
  84546. */
  84547. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84548. /**
  84549. * Set the value of an uniform to a Color3 and an alpha value
  84550. * @param uniform defines the webGL uniform location where to store the value
  84551. * @param color3 defines the color to store
  84552. * @param alpha defines the alpha component to store
  84553. */
  84554. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84555. /**
  84556. * Sets a Color4 on a uniform variable
  84557. * @param uniform defines the uniform location
  84558. * @param color4 defines the value to be set
  84559. */
  84560. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84561. /**
  84562. * Set various states to the webGL context
  84563. * @param culling defines backface culling state
  84564. * @param zOffset defines the value to apply to zOffset (0 by default)
  84565. * @param force defines if states must be applied even if cache is up to date
  84566. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84567. */
  84568. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84569. /**
  84570. * Set the z offset to apply to current rendering
  84571. * @param value defines the offset to apply
  84572. */
  84573. setZOffset(value: number): void;
  84574. /**
  84575. * Gets the current value of the zOffset
  84576. * @returns the current zOffset state
  84577. */
  84578. getZOffset(): number;
  84579. /**
  84580. * Enable or disable depth buffering
  84581. * @param enable defines the state to set
  84582. */
  84583. setDepthBuffer(enable: boolean): void;
  84584. /**
  84585. * Gets a boolean indicating if depth writing is enabled
  84586. * @returns the current depth writing state
  84587. */
  84588. getDepthWrite(): boolean;
  84589. /**
  84590. * Enable or disable depth writing
  84591. * @param enable defines the state to set
  84592. */
  84593. setDepthWrite(enable: boolean): void;
  84594. /**
  84595. * Enable or disable color writing
  84596. * @param enable defines the state to set
  84597. */
  84598. setColorWrite(enable: boolean): void;
  84599. /**
  84600. * Gets a boolean indicating if color writing is enabled
  84601. * @returns the current color writing state
  84602. */
  84603. getColorWrite(): boolean;
  84604. /**
  84605. * Sets alpha constants used by some alpha blending modes
  84606. * @param r defines the red component
  84607. * @param g defines the green component
  84608. * @param b defines the blue component
  84609. * @param a defines the alpha component
  84610. */
  84611. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84612. /**
  84613. * Sets the current alpha mode
  84614. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84615. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84617. */
  84618. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84619. /**
  84620. * Gets the current alpha mode
  84621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84622. * @returns the current alpha mode
  84623. */
  84624. getAlphaMode(): number;
  84625. /**
  84626. * Clears the list of texture accessible through engine.
  84627. * This can help preventing texture load conflict due to name collision.
  84628. */
  84629. clearInternalTexturesCache(): void;
  84630. /**
  84631. * Force the entire cache to be cleared
  84632. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84633. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84634. */
  84635. wipeCaches(bruteForce?: boolean): void;
  84636. /**
  84637. * Set the compressed texture format to use, based on the formats you have, and the formats
  84638. * supported by the hardware / browser.
  84639. *
  84640. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84641. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84642. * to API arguments needed to compressed textures. This puts the burden on the container
  84643. * generator to house the arcane code for determining these for current & future formats.
  84644. *
  84645. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84646. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84647. *
  84648. * Note: The result of this call is not taken into account when a texture is base64.
  84649. *
  84650. * @param formatsAvailable defines the list of those format families you have created
  84651. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84652. *
  84653. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84654. * @returns The extension selected.
  84655. */
  84656. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84657. private _getSamplingParameters;
  84658. private _partialLoadImg;
  84659. private _cascadeLoadImgs;
  84660. /** @hidden */
  84661. _createTexture(): WebGLTexture;
  84662. /**
  84663. * Usually called from Texture.ts.
  84664. * Passed information to create a WebGLTexture
  84665. * @param urlArg defines a value which contains one of the following:
  84666. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84667. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84668. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84670. * @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)
  84671. * @param scene needed for loading to the correct scene
  84672. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84673. * @param onLoad optional callback to be called upon successful completion
  84674. * @param onError optional callback to be called upon failure
  84675. * @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
  84676. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84677. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84678. * @param forcedExtension defines the extension to use to pick the right loader
  84679. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84680. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84681. */
  84682. 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;
  84683. private _rescaleTexture;
  84684. /**
  84685. * Update a raw texture
  84686. * @param texture defines the texture to update
  84687. * @param data defines the data to store in the texture
  84688. * @param format defines the format of the data
  84689. * @param invertY defines if data must be stored with Y axis inverted
  84690. * @param compression defines the compression used (null by default)
  84691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84692. */
  84693. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84694. /**
  84695. * Creates a raw texture
  84696. * @param data defines the data to store in the texture
  84697. * @param width defines the width of the texture
  84698. * @param height defines the height of the texture
  84699. * @param format defines the format of the data
  84700. * @param generateMipMaps defines if the engine should generate the mip levels
  84701. * @param invertY defines if data must be stored with Y axis inverted
  84702. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84703. * @param compression defines the compression used (null by default)
  84704. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84705. * @returns the raw texture inside an InternalTexture
  84706. */
  84707. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84708. private _unpackFlipYCached;
  84709. /**
  84710. * In case you are sharing the context with other applications, it might
  84711. * be interested to not cache the unpack flip y state to ensure a consistent
  84712. * value would be set.
  84713. */
  84714. enableUnpackFlipYCached: boolean;
  84715. /** @hidden */
  84716. _unpackFlipY(value: boolean): void;
  84717. /** @hidden */
  84718. _getUnpackAlignement(): number;
  84719. /**
  84720. * Creates a dynamic texture
  84721. * @param width defines the width of the texture
  84722. * @param height defines the height of the texture
  84723. * @param generateMipMaps defines if the engine should generate the mip levels
  84724. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84725. * @returns the dynamic texture inside an InternalTexture
  84726. */
  84727. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84728. /**
  84729. * Update the sampling mode of a given texture
  84730. * @param samplingMode defines the required sampling mode
  84731. * @param texture defines the texture to update
  84732. */
  84733. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84734. /**
  84735. * Update the content of a dynamic texture
  84736. * @param texture defines the texture to update
  84737. * @param canvas defines the canvas containing the source
  84738. * @param invertY defines if data must be stored with Y axis inverted
  84739. * @param premulAlpha defines if alpha is stored as premultiplied
  84740. * @param format defines the format of the data
  84741. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84742. */
  84743. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84744. /**
  84745. * Update a video texture
  84746. * @param texture defines the texture to update
  84747. * @param video defines the video element to use
  84748. * @param invertY defines if data must be stored with Y axis inverted
  84749. */
  84750. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84751. /**
  84752. * Updates a depth texture Comparison Mode and Function.
  84753. * If the comparison Function is equal to 0, the mode will be set to none.
  84754. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84755. * @param texture The texture to set the comparison function for
  84756. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84757. */
  84758. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84759. private _setupDepthStencilTexture;
  84760. /**
  84761. * Creates a depth stencil texture.
  84762. * This is only available in WebGL 2 or with the depth texture extension available.
  84763. * @param size The size of face edge in the texture.
  84764. * @param options The options defining the texture.
  84765. * @returns The texture
  84766. */
  84767. createDepthStencilTexture(size: number | {
  84768. width: number;
  84769. height: number;
  84770. }, options: DepthTextureCreationOptions): InternalTexture;
  84771. /**
  84772. * Creates a depth stencil texture.
  84773. * This is only available in WebGL 2 or with the depth texture extension available.
  84774. * @param size The size of face edge in the texture.
  84775. * @param options The options defining the texture.
  84776. * @returns The texture
  84777. */
  84778. private _createDepthStencilTexture;
  84779. /**
  84780. * Creates a depth stencil cube texture.
  84781. * This is only available in WebGL 2.
  84782. * @param size The size of face edge in the cube texture.
  84783. * @param options The options defining the cube texture.
  84784. * @returns The cube texture
  84785. */
  84786. private _createDepthStencilCubeTexture;
  84787. /**
  84788. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84789. * @param renderTarget The render target to set the frame buffer for
  84790. */
  84791. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84792. /**
  84793. * Creates a new render target texture
  84794. * @param size defines the size of the texture
  84795. * @param options defines the options used to create the texture
  84796. * @returns a new render target texture stored in an InternalTexture
  84797. */
  84798. createRenderTargetTexture(size: number | {
  84799. width: number;
  84800. height: number;
  84801. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84802. /**
  84803. * Create a multi render target texture
  84804. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84805. * @param size defines the size of the texture
  84806. * @param options defines the creation options
  84807. * @returns the cube texture as an InternalTexture
  84808. */
  84809. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84810. private _setupFramebufferDepthAttachments;
  84811. /**
  84812. * Updates the sample count of a render target texture
  84813. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84814. * @param texture defines the texture to update
  84815. * @param samples defines the sample count to set
  84816. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84817. */
  84818. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84819. /**
  84820. * Update the sample count for a given multiple render target texture
  84821. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84822. * @param textures defines the textures to update
  84823. * @param samples defines the sample count to set
  84824. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84825. */
  84826. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84827. /** @hidden */
  84828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84829. /** @hidden */
  84830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84831. /** @hidden */
  84832. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84833. /** @hidden */
  84834. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84835. /**
  84836. * Creates a new render target cube texture
  84837. * @param size defines the size of the texture
  84838. * @param options defines the options used to create the texture
  84839. * @returns a new render target cube texture stored in an InternalTexture
  84840. */
  84841. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84842. /**
  84843. * Creates a cube texture
  84844. * @param rootUrl defines the url where the files to load is located
  84845. * @param scene defines the current scene
  84846. * @param files defines the list of files to load (1 per face)
  84847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84848. * @param onLoad defines an optional callback raised when the texture is loaded
  84849. * @param onError defines an optional callback raised if there is an issue to load the texture
  84850. * @param format defines the format of the data
  84851. * @param forcedExtension defines the extension to use to pick the right loader
  84852. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84855. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84856. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84857. * @returns the cube texture as an InternalTexture
  84858. */
  84859. 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;
  84860. /**
  84861. * @hidden
  84862. */
  84863. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84864. /**
  84865. * Update a raw cube texture
  84866. * @param texture defines the texture to udpdate
  84867. * @param data defines the data to store
  84868. * @param format defines the data format
  84869. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84870. * @param invertY defines if data must be stored with Y axis inverted
  84871. * @param compression defines the compression used (null by default)
  84872. * @param level defines which level of the texture to update
  84873. */
  84874. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84875. /**
  84876. * Creates a new raw cube texture
  84877. * @param data defines the array of data to use to create each face
  84878. * @param size defines the size of the textures
  84879. * @param format defines the format of the data
  84880. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84881. * @param generateMipMaps defines if the engine should generate the mip levels
  84882. * @param invertY defines if data must be stored with Y axis inverted
  84883. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84884. * @param compression defines the compression used (null by default)
  84885. * @returns the cube texture as an InternalTexture
  84886. */
  84887. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84888. /**
  84889. * Creates a new raw cube texture from a specified url
  84890. * @param url defines the url where the data is located
  84891. * @param scene defines the current scene
  84892. * @param size defines the size of the textures
  84893. * @param format defines the format of the data
  84894. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84895. * @param noMipmap defines if the engine should avoid generating the mip levels
  84896. * @param callback defines a callback used to extract texture data from loaded data
  84897. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84898. * @param onLoad defines a callback called when texture is loaded
  84899. * @param onError defines a callback called if there is an error
  84900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84901. * @param invertY defines if data must be stored with Y axis inverted
  84902. * @returns the cube texture as an InternalTexture
  84903. */
  84904. 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;
  84905. /**
  84906. * Update a raw 3D texture
  84907. * @param texture defines the texture to update
  84908. * @param data defines the data to store
  84909. * @param format defines the data format
  84910. * @param invertY defines if data must be stored with Y axis inverted
  84911. * @param compression defines the used compression (can be null)
  84912. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84913. */
  84914. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84915. /**
  84916. * Creates a new raw 3D texture
  84917. * @param data defines the data used to create the texture
  84918. * @param width defines the width of the texture
  84919. * @param height defines the height of the texture
  84920. * @param depth defines the depth of the texture
  84921. * @param format defines the format of the texture
  84922. * @param generateMipMaps defines if the engine must generate mip levels
  84923. * @param invertY defines if data must be stored with Y axis inverted
  84924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84925. * @param compression defines the compressed used (can be null)
  84926. * @param textureType defines the compressed used (can be null)
  84927. * @returns a new raw 3D texture (stored in an InternalTexture)
  84928. */
  84929. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84930. private _prepareWebGLTextureContinuation;
  84931. private _prepareWebGLTexture;
  84932. private _convertRGBtoRGBATextureData;
  84933. /** @hidden */
  84934. _releaseFramebufferObjects(texture: InternalTexture): void;
  84935. /** @hidden */
  84936. _releaseTexture(texture: InternalTexture): void;
  84937. private setProgram;
  84938. private _boundUniforms;
  84939. /**
  84940. * Binds an effect to the webGL context
  84941. * @param effect defines the effect to bind
  84942. */
  84943. bindSamplers(effect: Effect): void;
  84944. private _moveBoundTextureOnTop;
  84945. private _getCorrectTextureChannel;
  84946. private _linkTrackers;
  84947. private _removeDesignatedSlot;
  84948. private _activateCurrentTexture;
  84949. /** @hidden */
  84950. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84951. /** @hidden */
  84952. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84953. /**
  84954. * Sets a texture to the webGL context from a postprocess
  84955. * @param channel defines the channel to use
  84956. * @param postProcess defines the source postprocess
  84957. */
  84958. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84959. /**
  84960. * Binds the output of the passed in post process to the texture channel specified
  84961. * @param channel The channel the texture should be bound to
  84962. * @param postProcess The post process which's output should be bound
  84963. */
  84964. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84965. /**
  84966. * Unbind all textures from the webGL context
  84967. */
  84968. unbindAllTextures(): void;
  84969. /**
  84970. * Sets a texture to the according uniform.
  84971. * @param channel The texture channel
  84972. * @param uniform The uniform to set
  84973. * @param texture The texture to apply
  84974. */
  84975. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84976. /**
  84977. * Sets a depth stencil texture from a render target to the according uniform.
  84978. * @param channel The texture channel
  84979. * @param uniform The uniform to set
  84980. * @param texture The render target texture containing the depth stencil texture to apply
  84981. */
  84982. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84983. private _bindSamplerUniformToChannel;
  84984. private _getTextureWrapMode;
  84985. private _setTexture;
  84986. /**
  84987. * Sets an array of texture to the webGL context
  84988. * @param channel defines the channel where the texture array must be set
  84989. * @param uniform defines the associated uniform location
  84990. * @param textures defines the array of textures to bind
  84991. */
  84992. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84993. /** @hidden */
  84994. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84995. private _setTextureParameterFloat;
  84996. private _setTextureParameterInteger;
  84997. /**
  84998. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84999. * @param x defines the x coordinate of the rectangle where pixels must be read
  85000. * @param y defines the y coordinate of the rectangle where pixels must be read
  85001. * @param width defines the width of the rectangle where pixels must be read
  85002. * @param height defines the height of the rectangle where pixels must be read
  85003. * @returns a Uint8Array containing RGBA colors
  85004. */
  85005. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85006. /**
  85007. * Add an externaly attached data from its key.
  85008. * This method call will fail and return false, if such key already exists.
  85009. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85010. * @param key the unique key that identifies the data
  85011. * @param data the data object to associate to the key for this Engine instance
  85012. * @return true if no such key were already present and the data was added successfully, false otherwise
  85013. */
  85014. addExternalData<T>(key: string, data: T): boolean;
  85015. /**
  85016. * Get an externaly attached data from its key
  85017. * @param key the unique key that identifies the data
  85018. * @return the associated data, if present (can be null), or undefined if not present
  85019. */
  85020. getExternalData<T>(key: string): T;
  85021. /**
  85022. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85023. * @param key the unique key that identifies the data
  85024. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85025. * @return the associated data, can be null if the factory returned null.
  85026. */
  85027. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85028. /**
  85029. * Remove an externaly attached data from the Engine instance
  85030. * @param key the unique key that identifies the data
  85031. * @return true if the data was successfully removed, false if it doesn't exist
  85032. */
  85033. removeExternalData(key: string): boolean;
  85034. /**
  85035. * Unbind all vertex attributes from the webGL context
  85036. */
  85037. unbindAllAttributes(): void;
  85038. /**
  85039. * 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
  85040. */
  85041. releaseEffects(): void;
  85042. /**
  85043. * Dispose and release all associated resources
  85044. */
  85045. dispose(): void;
  85046. /**
  85047. * Display the loading screen
  85048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85049. */
  85050. displayLoadingUI(): void;
  85051. /**
  85052. * Hide the loading screen
  85053. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85054. */
  85055. hideLoadingUI(): void;
  85056. /**
  85057. * Gets the current loading screen object
  85058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85059. */
  85060. /**
  85061. * Sets the current loading screen object
  85062. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85063. */
  85064. loadingScreen: ILoadingScreen;
  85065. /**
  85066. * Sets the current loading screen text
  85067. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85068. */
  85069. loadingUIText: string;
  85070. /**
  85071. * Sets the current loading screen background color
  85072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85073. */
  85074. loadingUIBackgroundColor: string;
  85075. /**
  85076. * Attach a new callback raised when context lost event is fired
  85077. * @param callback defines the callback to call
  85078. */
  85079. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85080. /**
  85081. * Attach a new callback raised when context restored event is fired
  85082. * @param callback defines the callback to call
  85083. */
  85084. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85085. /**
  85086. * Gets the source code of the vertex shader associated with a specific webGL program
  85087. * @param program defines the program to use
  85088. * @returns a string containing the source code of the vertex shader associated with the program
  85089. */
  85090. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85091. /**
  85092. * Gets the source code of the fragment shader associated with a specific webGL program
  85093. * @param program defines the program to use
  85094. * @returns a string containing the source code of the fragment shader associated with the program
  85095. */
  85096. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85097. /**
  85098. * Get the current error code of the webGL context
  85099. * @returns the error code
  85100. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85101. */
  85102. getError(): number;
  85103. /**
  85104. * Gets the current framerate
  85105. * @returns a number representing the framerate
  85106. */
  85107. getFps(): number;
  85108. /**
  85109. * Gets the time spent between current and previous frame
  85110. * @returns a number representing the delta time in ms
  85111. */
  85112. getDeltaTime(): number;
  85113. private _measureFps;
  85114. /** @hidden */
  85115. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85116. private _canRenderToFloatFramebuffer;
  85117. private _canRenderToHalfFloatFramebuffer;
  85118. private _canRenderToFramebuffer;
  85119. /** @hidden */
  85120. _getWebGLTextureType(type: number): number;
  85121. private _getInternalFormat;
  85122. /** @hidden */
  85123. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85124. /** @hidden */
  85125. _getRGBAMultiSampleBufferFormat(type: number): number;
  85126. /** @hidden */
  85127. _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;
  85128. /** @hidden */
  85129. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85130. private _partialLoadFile;
  85131. private _cascadeLoadFiles;
  85132. /**
  85133. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85134. * @returns true if the engine can be created
  85135. * @ignorenaming
  85136. */
  85137. static isSupported(): boolean;
  85138. }
  85139. }
  85140. declare module BABYLON {
  85141. /**
  85142. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85143. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85144. */
  85145. export class EffectFallbacks {
  85146. private _defines;
  85147. private _currentRank;
  85148. private _maxRank;
  85149. private _mesh;
  85150. /**
  85151. * Removes the fallback from the bound mesh.
  85152. */
  85153. unBindMesh(): void;
  85154. /**
  85155. * Adds a fallback on the specified property.
  85156. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85157. * @param define The name of the define in the shader
  85158. */
  85159. addFallback(rank: number, define: string): void;
  85160. /**
  85161. * Sets the mesh to use CPU skinning when needing to fallback.
  85162. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85163. * @param mesh The mesh to use the fallbacks.
  85164. */
  85165. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85166. /**
  85167. * Checks to see if more fallbacks are still availible.
  85168. */
  85169. readonly isMoreFallbacks: boolean;
  85170. /**
  85171. * Removes the defines that shoould be removed when falling back.
  85172. * @param currentDefines defines the current define statements for the shader.
  85173. * @param effect defines the current effect we try to compile
  85174. * @returns The resulting defines with defines of the current rank removed.
  85175. */
  85176. reduce(currentDefines: string, effect: Effect): string;
  85177. }
  85178. /**
  85179. * Options to be used when creating an effect.
  85180. */
  85181. export class EffectCreationOptions {
  85182. /**
  85183. * Atrributes that will be used in the shader.
  85184. */
  85185. attributes: string[];
  85186. /**
  85187. * Uniform varible names that will be set in the shader.
  85188. */
  85189. uniformsNames: string[];
  85190. /**
  85191. * Uniform buffer varible names that will be set in the shader.
  85192. */
  85193. uniformBuffersNames: string[];
  85194. /**
  85195. * Sampler texture variable names that will be set in the shader.
  85196. */
  85197. samplers: string[];
  85198. /**
  85199. * Define statements that will be set in the shader.
  85200. */
  85201. defines: any;
  85202. /**
  85203. * Possible fallbacks for this effect to improve performance when needed.
  85204. */
  85205. fallbacks: Nullable<EffectFallbacks>;
  85206. /**
  85207. * Callback that will be called when the shader is compiled.
  85208. */
  85209. onCompiled: Nullable<(effect: Effect) => void>;
  85210. /**
  85211. * Callback that will be called if an error occurs during shader compilation.
  85212. */
  85213. onError: Nullable<(effect: Effect, errors: string) => void>;
  85214. /**
  85215. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85216. */
  85217. indexParameters: any;
  85218. /**
  85219. * Max number of lights that can be used in the shader.
  85220. */
  85221. maxSimultaneousLights: number;
  85222. /**
  85223. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85224. */
  85225. transformFeedbackVaryings: Nullable<string[]>;
  85226. }
  85227. /**
  85228. * Effect containing vertex and fragment shader that can be executed on an object.
  85229. */
  85230. export class Effect {
  85231. /**
  85232. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85233. */
  85234. static ShadersRepository: string;
  85235. /**
  85236. * Name of the effect.
  85237. */
  85238. name: any;
  85239. /**
  85240. * String container all the define statements that should be set on the shader.
  85241. */
  85242. defines: string;
  85243. /**
  85244. * Callback that will be called when the shader is compiled.
  85245. */
  85246. onCompiled: Nullable<(effect: Effect) => void>;
  85247. /**
  85248. * Callback that will be called if an error occurs during shader compilation.
  85249. */
  85250. onError: Nullable<(effect: Effect, errors: string) => void>;
  85251. /**
  85252. * Callback that will be called when effect is bound.
  85253. */
  85254. onBind: Nullable<(effect: Effect) => void>;
  85255. /**
  85256. * Unique ID of the effect.
  85257. */
  85258. uniqueId: number;
  85259. /**
  85260. * Observable that will be called when the shader is compiled.
  85261. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85262. */
  85263. onCompileObservable: Observable<Effect>;
  85264. /**
  85265. * Observable that will be called if an error occurs during shader compilation.
  85266. */
  85267. onErrorObservable: Observable<Effect>;
  85268. /** @hidden */
  85269. _onBindObservable: Nullable<Observable<Effect>>;
  85270. /**
  85271. * Observable that will be called when effect is bound.
  85272. */
  85273. readonly onBindObservable: Observable<Effect>;
  85274. /** @hidden */
  85275. _bonesComputationForcedToCPU: boolean;
  85276. private static _uniqueIdSeed;
  85277. private _engine;
  85278. private _uniformBuffersNames;
  85279. private _uniformsNames;
  85280. private _samplers;
  85281. private _isReady;
  85282. private _compilationError;
  85283. private _attributesNames;
  85284. private _attributes;
  85285. private _uniforms;
  85286. /**
  85287. * Key for the effect.
  85288. * @hidden
  85289. */
  85290. _key: string;
  85291. private _indexParameters;
  85292. private _fallbacks;
  85293. private _vertexSourceCode;
  85294. private _fragmentSourceCode;
  85295. private _vertexSourceCodeOverride;
  85296. private _fragmentSourceCodeOverride;
  85297. private _transformFeedbackVaryings;
  85298. /**
  85299. * Compiled shader to webGL program.
  85300. * @hidden
  85301. */
  85302. _program: WebGLProgram;
  85303. private _valueCache;
  85304. private static _baseCache;
  85305. /**
  85306. * Instantiates an effect.
  85307. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85308. * @param baseName Name of the effect.
  85309. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85310. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85311. * @param samplers List of sampler variables that will be passed to the shader.
  85312. * @param engine Engine to be used to render the effect
  85313. * @param defines Define statements to be added to the shader.
  85314. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85315. * @param onCompiled Callback that will be called when the shader is compiled.
  85316. * @param onError Callback that will be called if an error occurs during shader compilation.
  85317. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85318. */
  85319. 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);
  85320. /**
  85321. * Unique key for this effect
  85322. */
  85323. readonly key: string;
  85324. /**
  85325. * If the effect has been compiled and prepared.
  85326. * @returns if the effect is compiled and prepared.
  85327. */
  85328. isReady(): boolean;
  85329. /**
  85330. * The engine the effect was initialized with.
  85331. * @returns the engine.
  85332. */
  85333. getEngine(): Engine;
  85334. /**
  85335. * The compiled webGL program for the effect
  85336. * @returns the webGL program.
  85337. */
  85338. getProgram(): WebGLProgram;
  85339. /**
  85340. * The set of names of attribute variables for the shader.
  85341. * @returns An array of attribute names.
  85342. */
  85343. getAttributesNames(): string[];
  85344. /**
  85345. * Returns the attribute at the given index.
  85346. * @param index The index of the attribute.
  85347. * @returns The location of the attribute.
  85348. */
  85349. getAttributeLocation(index: number): number;
  85350. /**
  85351. * Returns the attribute based on the name of the variable.
  85352. * @param name of the attribute to look up.
  85353. * @returns the attribute location.
  85354. */
  85355. getAttributeLocationByName(name: string): number;
  85356. /**
  85357. * The number of attributes.
  85358. * @returns the numnber of attributes.
  85359. */
  85360. getAttributesCount(): number;
  85361. /**
  85362. * Gets the index of a uniform variable.
  85363. * @param uniformName of the uniform to look up.
  85364. * @returns the index.
  85365. */
  85366. getUniformIndex(uniformName: string): number;
  85367. /**
  85368. * Returns the attribute based on the name of the variable.
  85369. * @param uniformName of the uniform to look up.
  85370. * @returns the location of the uniform.
  85371. */
  85372. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85373. /**
  85374. * Returns an array of sampler variable names
  85375. * @returns The array of sampler variable neames.
  85376. */
  85377. getSamplers(): string[];
  85378. /**
  85379. * The error from the last compilation.
  85380. * @returns the error string.
  85381. */
  85382. getCompilationError(): string;
  85383. /**
  85384. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85385. * @param func The callback to be used.
  85386. */
  85387. executeWhenCompiled(func: (effect: Effect) => void): void;
  85388. private _checkIsReady;
  85389. /** @hidden */
  85390. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85391. /** @hidden */
  85392. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85393. /** @hidden */
  85394. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85395. private _processShaderConversion;
  85396. private _processIncludes;
  85397. private _processPrecision;
  85398. /**
  85399. * Recompiles the webGL program
  85400. * @param vertexSourceCode The source code for the vertex shader.
  85401. * @param fragmentSourceCode The source code for the fragment shader.
  85402. * @param onCompiled Callback called when completed.
  85403. * @param onError Callback called on error.
  85404. * @hidden
  85405. */
  85406. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85407. /**
  85408. * Gets the uniform locations of the the specified variable names
  85409. * @param names THe names of the variables to lookup.
  85410. * @returns Array of locations in the same order as variable names.
  85411. */
  85412. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85413. /**
  85414. * Prepares the effect
  85415. * @hidden
  85416. */
  85417. _prepareEffect(): void;
  85418. /**
  85419. * Checks if the effect is supported. (Must be called after compilation)
  85420. */
  85421. readonly isSupported: boolean;
  85422. /**
  85423. * Binds a texture to the engine to be used as output of the shader.
  85424. * @param channel Name of the output variable.
  85425. * @param texture Texture to bind.
  85426. * @hidden
  85427. */
  85428. _bindTexture(channel: string, texture: InternalTexture): void;
  85429. /**
  85430. * Sets a texture on the engine to be used in the shader.
  85431. * @param channel Name of the sampler variable.
  85432. * @param texture Texture to set.
  85433. */
  85434. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85435. /**
  85436. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85437. * @param channel Name of the sampler variable.
  85438. * @param texture Texture to set.
  85439. */
  85440. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85441. /**
  85442. * Sets an array of textures on the engine to be used in the shader.
  85443. * @param channel Name of the variable.
  85444. * @param textures Textures to set.
  85445. */
  85446. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85447. /**
  85448. * 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)
  85449. * @param channel Name of the sampler variable.
  85450. * @param postProcess Post process to get the input texture from.
  85451. */
  85452. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85453. /**
  85454. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85455. * 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)
  85456. * @param channel Name of the sampler variable.
  85457. * @param postProcess Post process to get the output texture from.
  85458. */
  85459. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85460. /** @hidden */
  85461. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85462. /** @hidden */
  85463. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85464. /** @hidden */
  85465. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85466. /** @hidden */
  85467. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85468. /**
  85469. * Binds a buffer to a uniform.
  85470. * @param buffer Buffer to bind.
  85471. * @param name Name of the uniform variable to bind to.
  85472. */
  85473. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85474. /**
  85475. * Binds block to a uniform.
  85476. * @param blockName Name of the block to bind.
  85477. * @param index Index to bind.
  85478. */
  85479. bindUniformBlock(blockName: string, index: number): void;
  85480. /**
  85481. * Sets an interger value on a uniform variable.
  85482. * @param uniformName Name of the variable.
  85483. * @param value Value to be set.
  85484. * @returns this effect.
  85485. */
  85486. setInt(uniformName: string, value: number): Effect;
  85487. /**
  85488. * Sets an int array on a uniform variable.
  85489. * @param uniformName Name of the variable.
  85490. * @param array array to be set.
  85491. * @returns this effect.
  85492. */
  85493. setIntArray(uniformName: string, array: Int32Array): Effect;
  85494. /**
  85495. * 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)
  85496. * @param uniformName Name of the variable.
  85497. * @param array array to be set.
  85498. * @returns this effect.
  85499. */
  85500. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85501. /**
  85502. * 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)
  85503. * @param uniformName Name of the variable.
  85504. * @param array array to be set.
  85505. * @returns this effect.
  85506. */
  85507. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85508. /**
  85509. * 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)
  85510. * @param uniformName Name of the variable.
  85511. * @param array array to be set.
  85512. * @returns this effect.
  85513. */
  85514. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85515. /**
  85516. * Sets an float array on a uniform variable.
  85517. * @param uniformName Name of the variable.
  85518. * @param array array to be set.
  85519. * @returns this effect.
  85520. */
  85521. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85522. /**
  85523. * 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)
  85524. * @param uniformName Name of the variable.
  85525. * @param array array to be set.
  85526. * @returns this effect.
  85527. */
  85528. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85529. /**
  85530. * 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)
  85531. * @param uniformName Name of the variable.
  85532. * @param array array to be set.
  85533. * @returns this effect.
  85534. */
  85535. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85536. /**
  85537. * 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)
  85538. * @param uniformName Name of the variable.
  85539. * @param array array to be set.
  85540. * @returns this effect.
  85541. */
  85542. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85543. /**
  85544. * Sets an array on a uniform variable.
  85545. * @param uniformName Name of the variable.
  85546. * @param array array to be set.
  85547. * @returns this effect.
  85548. */
  85549. setArray(uniformName: string, array: number[]): Effect;
  85550. /**
  85551. * 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)
  85552. * @param uniformName Name of the variable.
  85553. * @param array array to be set.
  85554. * @returns this effect.
  85555. */
  85556. setArray2(uniformName: string, array: number[]): Effect;
  85557. /**
  85558. * 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)
  85559. * @param uniformName Name of the variable.
  85560. * @param array array to be set.
  85561. * @returns this effect.
  85562. */
  85563. setArray3(uniformName: string, array: number[]): Effect;
  85564. /**
  85565. * 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)
  85566. * @param uniformName Name of the variable.
  85567. * @param array array to be set.
  85568. * @returns this effect.
  85569. */
  85570. setArray4(uniformName: string, array: number[]): Effect;
  85571. /**
  85572. * Sets matrices on a uniform variable.
  85573. * @param uniformName Name of the variable.
  85574. * @param matrices matrices to be set.
  85575. * @returns this effect.
  85576. */
  85577. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85578. /**
  85579. * Sets matrix on a uniform variable.
  85580. * @param uniformName Name of the variable.
  85581. * @param matrix matrix to be set.
  85582. * @returns this effect.
  85583. */
  85584. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85585. /**
  85586. * 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)
  85587. * @param uniformName Name of the variable.
  85588. * @param matrix matrix to be set.
  85589. * @returns this effect.
  85590. */
  85591. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85592. /**
  85593. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85594. * @param uniformName Name of the variable.
  85595. * @param matrix matrix to be set.
  85596. * @returns this effect.
  85597. */
  85598. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85599. /**
  85600. * Sets a float on a uniform variable.
  85601. * @param uniformName Name of the variable.
  85602. * @param value value to be set.
  85603. * @returns this effect.
  85604. */
  85605. setFloat(uniformName: string, value: number): Effect;
  85606. /**
  85607. * Sets a boolean on a uniform variable.
  85608. * @param uniformName Name of the variable.
  85609. * @param bool value to be set.
  85610. * @returns this effect.
  85611. */
  85612. setBool(uniformName: string, bool: boolean): Effect;
  85613. /**
  85614. * Sets a Vector2 on a uniform variable.
  85615. * @param uniformName Name of the variable.
  85616. * @param vector2 vector2 to be set.
  85617. * @returns this effect.
  85618. */
  85619. setVector2(uniformName: string, vector2: Vector2): Effect;
  85620. /**
  85621. * Sets a float2 on a uniform variable.
  85622. * @param uniformName Name of the variable.
  85623. * @param x First float in float2.
  85624. * @param y Second float in float2.
  85625. * @returns this effect.
  85626. */
  85627. setFloat2(uniformName: string, x: number, y: number): Effect;
  85628. /**
  85629. * Sets a Vector3 on a uniform variable.
  85630. * @param uniformName Name of the variable.
  85631. * @param vector3 Value to be set.
  85632. * @returns this effect.
  85633. */
  85634. setVector3(uniformName: string, vector3: Vector3): Effect;
  85635. /**
  85636. * Sets a float3 on a uniform variable.
  85637. * @param uniformName Name of the variable.
  85638. * @param x First float in float3.
  85639. * @param y Second float in float3.
  85640. * @param z Third float in float3.
  85641. * @returns this effect.
  85642. */
  85643. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85644. /**
  85645. * Sets a Vector4 on a uniform variable.
  85646. * @param uniformName Name of the variable.
  85647. * @param vector4 Value to be set.
  85648. * @returns this effect.
  85649. */
  85650. setVector4(uniformName: string, vector4: Vector4): Effect;
  85651. /**
  85652. * Sets a float4 on a uniform variable.
  85653. * @param uniformName Name of the variable.
  85654. * @param x First float in float4.
  85655. * @param y Second float in float4.
  85656. * @param z Third float in float4.
  85657. * @param w Fourth float in float4.
  85658. * @returns this effect.
  85659. */
  85660. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85661. /**
  85662. * Sets a Color3 on a uniform variable.
  85663. * @param uniformName Name of the variable.
  85664. * @param color3 Value to be set.
  85665. * @returns this effect.
  85666. */
  85667. setColor3(uniformName: string, color3: Color3): Effect;
  85668. /**
  85669. * Sets a Color4 on a uniform variable.
  85670. * @param uniformName Name of the variable.
  85671. * @param color3 Value to be set.
  85672. * @param alpha Alpha value to be set.
  85673. * @returns this effect.
  85674. */
  85675. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85676. /**
  85677. * Sets a Color4 on a uniform variable
  85678. * @param uniformName defines the name of the variable
  85679. * @param color4 defines the value to be set
  85680. * @returns this effect.
  85681. */
  85682. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85683. /**
  85684. * This function will add a new shader to the shader store
  85685. * @param name the name of the shader
  85686. * @param pixelShader optional pixel shader content
  85687. * @param vertexShader optional vertex shader content
  85688. */
  85689. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85690. /**
  85691. * Store of each shader (The can be looked up using effect.key)
  85692. */
  85693. static ShadersStore: {
  85694. [key: string]: string;
  85695. };
  85696. /**
  85697. * Store of each included file for a shader (The can be looked up using effect.key)
  85698. */
  85699. static IncludesShadersStore: {
  85700. [key: string]: string;
  85701. };
  85702. /**
  85703. * Resets the cache of effects.
  85704. */
  85705. static ResetCache(): void;
  85706. }
  85707. }
  85708. declare module BABYLON {
  85709. /**
  85710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85712. * 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;
  85713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85714. */
  85715. export class ColorCurves {
  85716. private _dirty;
  85717. private _tempColor;
  85718. private _globalCurve;
  85719. private _highlightsCurve;
  85720. private _midtonesCurve;
  85721. private _shadowsCurve;
  85722. private _positiveCurve;
  85723. private _negativeCurve;
  85724. private _globalHue;
  85725. private _globalDensity;
  85726. private _globalSaturation;
  85727. private _globalExposure;
  85728. /**
  85729. * Gets the global Hue value.
  85730. * 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).
  85731. */
  85732. /**
  85733. * Sets the global Hue value.
  85734. * 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).
  85735. */
  85736. globalHue: number;
  85737. /**
  85738. * Gets the global Density value.
  85739. * 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.
  85740. * Values less than zero provide a filter of opposite hue.
  85741. */
  85742. /**
  85743. * Sets the global Density value.
  85744. * 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.
  85745. * Values less than zero provide a filter of opposite hue.
  85746. */
  85747. globalDensity: number;
  85748. /**
  85749. * Gets the global Saturation value.
  85750. * 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.
  85751. */
  85752. /**
  85753. * Sets the global Saturation value.
  85754. * 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.
  85755. */
  85756. globalSaturation: number;
  85757. /**
  85758. * Gets the global Exposure value.
  85759. * 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.
  85760. */
  85761. /**
  85762. * Sets the global Exposure value.
  85763. * 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.
  85764. */
  85765. globalExposure: number;
  85766. private _highlightsHue;
  85767. private _highlightsDensity;
  85768. private _highlightsSaturation;
  85769. private _highlightsExposure;
  85770. /**
  85771. * Gets the highlights Hue value.
  85772. * 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).
  85773. */
  85774. /**
  85775. * Sets the highlights Hue value.
  85776. * 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).
  85777. */
  85778. highlightsHue: number;
  85779. /**
  85780. * Gets the highlights Density value.
  85781. * 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.
  85782. * Values less than zero provide a filter of opposite hue.
  85783. */
  85784. /**
  85785. * Sets the highlights Density value.
  85786. * 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.
  85787. * Values less than zero provide a filter of opposite hue.
  85788. */
  85789. highlightsDensity: number;
  85790. /**
  85791. * Gets the highlights Saturation value.
  85792. * 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.
  85793. */
  85794. /**
  85795. * Sets the highlights Saturation value.
  85796. * 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.
  85797. */
  85798. highlightsSaturation: number;
  85799. /**
  85800. * Gets the highlights Exposure value.
  85801. * 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.
  85802. */
  85803. /**
  85804. * Sets the highlights Exposure value.
  85805. * 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.
  85806. */
  85807. highlightsExposure: number;
  85808. private _midtonesHue;
  85809. private _midtonesDensity;
  85810. private _midtonesSaturation;
  85811. private _midtonesExposure;
  85812. /**
  85813. * Gets the midtones Hue value.
  85814. * 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).
  85815. */
  85816. /**
  85817. * Sets the midtones Hue value.
  85818. * 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).
  85819. */
  85820. midtonesHue: number;
  85821. /**
  85822. * Gets the midtones Density value.
  85823. * 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.
  85824. * Values less than zero provide a filter of opposite hue.
  85825. */
  85826. /**
  85827. * Sets the midtones Density value.
  85828. * 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.
  85829. * Values less than zero provide a filter of opposite hue.
  85830. */
  85831. midtonesDensity: number;
  85832. /**
  85833. * Gets the midtones Saturation value.
  85834. * 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.
  85835. */
  85836. /**
  85837. * Sets the midtones Saturation value.
  85838. * 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.
  85839. */
  85840. midtonesSaturation: number;
  85841. /**
  85842. * Gets the midtones Exposure value.
  85843. * 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.
  85844. */
  85845. /**
  85846. * Sets the midtones Exposure value.
  85847. * 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.
  85848. */
  85849. midtonesExposure: number;
  85850. private _shadowsHue;
  85851. private _shadowsDensity;
  85852. private _shadowsSaturation;
  85853. private _shadowsExposure;
  85854. /**
  85855. * Gets the shadows Hue value.
  85856. * 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).
  85857. */
  85858. /**
  85859. * Sets the shadows Hue value.
  85860. * 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).
  85861. */
  85862. shadowsHue: number;
  85863. /**
  85864. * Gets the shadows Density value.
  85865. * 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.
  85866. * Values less than zero provide a filter of opposite hue.
  85867. */
  85868. /**
  85869. * Sets the shadows Density value.
  85870. * 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.
  85871. * Values less than zero provide a filter of opposite hue.
  85872. */
  85873. shadowsDensity: number;
  85874. /**
  85875. * Gets the shadows Saturation value.
  85876. * 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.
  85877. */
  85878. /**
  85879. * Sets the shadows Saturation value.
  85880. * 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.
  85881. */
  85882. shadowsSaturation: number;
  85883. /**
  85884. * Gets the shadows Exposure value.
  85885. * 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.
  85886. */
  85887. /**
  85888. * Sets the shadows Exposure value.
  85889. * 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.
  85890. */
  85891. shadowsExposure: number;
  85892. /**
  85893. * Returns the class name
  85894. * @returns The class name
  85895. */
  85896. getClassName(): string;
  85897. /**
  85898. * Binds the color curves to the shader.
  85899. * @param colorCurves The color curve to bind
  85900. * @param effect The effect to bind to
  85901. * @param positiveUniform The positive uniform shader parameter
  85902. * @param neutralUniform The neutral uniform shader parameter
  85903. * @param negativeUniform The negative uniform shader parameter
  85904. */
  85905. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85906. /**
  85907. * Prepare the list of uniforms associated with the ColorCurves effects.
  85908. * @param uniformsList The list of uniforms used in the effect
  85909. */
  85910. static PrepareUniforms(uniformsList: string[]): void;
  85911. /**
  85912. * Returns color grading data based on a hue, density, saturation and exposure value.
  85913. * @param filterHue The hue of the color filter.
  85914. * @param filterDensity The density of the color filter.
  85915. * @param saturation The saturation.
  85916. * @param exposure The exposure.
  85917. * @param result The result data container.
  85918. */
  85919. private getColorGradingDataToRef;
  85920. /**
  85921. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85922. * @param value The input slider value in range [-100,100].
  85923. * @returns Adjusted value.
  85924. */
  85925. private static applyColorGradingSliderNonlinear;
  85926. /**
  85927. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85928. * @param hue The hue (H) input.
  85929. * @param saturation The saturation (S) input.
  85930. * @param brightness The brightness (B) input.
  85931. * @result An RGBA color represented as Vector4.
  85932. */
  85933. private static fromHSBToRef;
  85934. /**
  85935. * Returns a value clamped between min and max
  85936. * @param value The value to clamp
  85937. * @param min The minimum of value
  85938. * @param max The maximum of value
  85939. * @returns The clamped value.
  85940. */
  85941. private static clamp;
  85942. /**
  85943. * Clones the current color curve instance.
  85944. * @return The cloned curves
  85945. */
  85946. clone(): ColorCurves;
  85947. /**
  85948. * Serializes the current color curve instance to a json representation.
  85949. * @return a JSON representation
  85950. */
  85951. serialize(): any;
  85952. /**
  85953. * Parses the color curve from a json representation.
  85954. * @param source the JSON source to parse
  85955. * @return The parsed curves
  85956. */
  85957. static Parse(source: any): ColorCurves;
  85958. }
  85959. }
  85960. declare module BABYLON {
  85961. /**
  85962. * Interface to follow in your material defines to integrate easily the
  85963. * Image proccessing functions.
  85964. * @hidden
  85965. */
  85966. export interface IImageProcessingConfigurationDefines {
  85967. IMAGEPROCESSING: boolean;
  85968. VIGNETTE: boolean;
  85969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85970. VIGNETTEBLENDMODEOPAQUE: boolean;
  85971. TONEMAPPING: boolean;
  85972. TONEMAPPING_ACES: boolean;
  85973. CONTRAST: boolean;
  85974. EXPOSURE: boolean;
  85975. COLORCURVES: boolean;
  85976. COLORGRADING: boolean;
  85977. COLORGRADING3D: boolean;
  85978. SAMPLER3DGREENDEPTH: boolean;
  85979. SAMPLER3DBGRMAP: boolean;
  85980. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85981. }
  85982. /**
  85983. * @hidden
  85984. */
  85985. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85986. IMAGEPROCESSING: boolean;
  85987. VIGNETTE: boolean;
  85988. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85989. VIGNETTEBLENDMODEOPAQUE: boolean;
  85990. TONEMAPPING: boolean;
  85991. TONEMAPPING_ACES: boolean;
  85992. CONTRAST: boolean;
  85993. COLORCURVES: boolean;
  85994. COLORGRADING: boolean;
  85995. COLORGRADING3D: boolean;
  85996. SAMPLER3DGREENDEPTH: boolean;
  85997. SAMPLER3DBGRMAP: boolean;
  85998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85999. EXPOSURE: boolean;
  86000. constructor();
  86001. }
  86002. /**
  86003. * This groups together the common properties used for image processing either in direct forward pass
  86004. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86005. * or not.
  86006. */
  86007. export class ImageProcessingConfiguration {
  86008. /**
  86009. * Default tone mapping applied in BabylonJS.
  86010. */
  86011. static readonly TONEMAPPING_STANDARD: number;
  86012. /**
  86013. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86014. * to other engines rendering to increase portability.
  86015. */
  86016. static readonly TONEMAPPING_ACES: number;
  86017. /**
  86018. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86019. */
  86020. colorCurves: Nullable<ColorCurves>;
  86021. private _colorCurvesEnabled;
  86022. /**
  86023. * Gets wether the color curves effect is enabled.
  86024. */
  86025. /**
  86026. * Sets wether the color curves effect is enabled.
  86027. */
  86028. colorCurvesEnabled: boolean;
  86029. private _colorGradingTexture;
  86030. /**
  86031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86032. */
  86033. /**
  86034. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86035. */
  86036. colorGradingTexture: Nullable<BaseTexture>;
  86037. private _colorGradingEnabled;
  86038. /**
  86039. * Gets wether the color grading effect is enabled.
  86040. */
  86041. /**
  86042. * Sets wether the color grading effect is enabled.
  86043. */
  86044. colorGradingEnabled: boolean;
  86045. private _colorGradingWithGreenDepth;
  86046. /**
  86047. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86048. */
  86049. /**
  86050. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86051. */
  86052. colorGradingWithGreenDepth: boolean;
  86053. private _colorGradingBGR;
  86054. /**
  86055. * Gets wether the color grading texture contains BGR values.
  86056. */
  86057. /**
  86058. * Sets wether the color grading texture contains BGR values.
  86059. */
  86060. colorGradingBGR: boolean;
  86061. /** @hidden */
  86062. _exposure: number;
  86063. /**
  86064. * Gets the Exposure used in the effect.
  86065. */
  86066. /**
  86067. * Sets the Exposure used in the effect.
  86068. */
  86069. exposure: number;
  86070. private _toneMappingEnabled;
  86071. /**
  86072. * Gets wether the tone mapping effect is enabled.
  86073. */
  86074. /**
  86075. * Sets wether the tone mapping effect is enabled.
  86076. */
  86077. toneMappingEnabled: boolean;
  86078. private _toneMappingType;
  86079. /**
  86080. * Gets the type of tone mapping effect.
  86081. */
  86082. /**
  86083. * Sets the type of tone mapping effect used in BabylonJS.
  86084. */
  86085. toneMappingType: number;
  86086. protected _contrast: number;
  86087. /**
  86088. * Gets the contrast used in the effect.
  86089. */
  86090. /**
  86091. * Sets the contrast used in the effect.
  86092. */
  86093. contrast: number;
  86094. /**
  86095. * Vignette stretch size.
  86096. */
  86097. vignetteStretch: number;
  86098. /**
  86099. * Vignette centre X Offset.
  86100. */
  86101. vignetteCentreX: number;
  86102. /**
  86103. * Vignette centre Y Offset.
  86104. */
  86105. vignetteCentreY: number;
  86106. /**
  86107. * Vignette weight or intensity of the vignette effect.
  86108. */
  86109. vignetteWeight: number;
  86110. /**
  86111. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86112. * if vignetteEnabled is set to true.
  86113. */
  86114. vignetteColor: Color4;
  86115. /**
  86116. * Camera field of view used by the Vignette effect.
  86117. */
  86118. vignetteCameraFov: number;
  86119. private _vignetteBlendMode;
  86120. /**
  86121. * Gets the vignette blend mode allowing different kind of effect.
  86122. */
  86123. /**
  86124. * Sets the vignette blend mode allowing different kind of effect.
  86125. */
  86126. vignetteBlendMode: number;
  86127. private _vignetteEnabled;
  86128. /**
  86129. * Gets wether the vignette effect is enabled.
  86130. */
  86131. /**
  86132. * Sets wether the vignette effect is enabled.
  86133. */
  86134. vignetteEnabled: boolean;
  86135. private _applyByPostProcess;
  86136. /**
  86137. * Gets wether the image processing is applied through a post process or not.
  86138. */
  86139. /**
  86140. * Sets wether the image processing is applied through a post process or not.
  86141. */
  86142. applyByPostProcess: boolean;
  86143. private _isEnabled;
  86144. /**
  86145. * Gets wether the image processing is enabled or not.
  86146. */
  86147. /**
  86148. * Sets wether the image processing is enabled or not.
  86149. */
  86150. isEnabled: boolean;
  86151. /**
  86152. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86153. */
  86154. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86155. /**
  86156. * Method called each time the image processing information changes requires to recompile the effect.
  86157. */
  86158. protected _updateParameters(): void;
  86159. /**
  86160. * Gets the current class name.
  86161. * @return "ImageProcessingConfiguration"
  86162. */
  86163. getClassName(): string;
  86164. /**
  86165. * Prepare the list of uniforms associated with the Image Processing effects.
  86166. * @param uniforms The list of uniforms used in the effect
  86167. * @param defines the list of defines currently in use
  86168. */
  86169. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86170. /**
  86171. * Prepare the list of samplers associated with the Image Processing effects.
  86172. * @param samplersList The list of uniforms used in the effect
  86173. * @param defines the list of defines currently in use
  86174. */
  86175. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86176. /**
  86177. * Prepare the list of defines associated to the shader.
  86178. * @param defines the list of defines to complete
  86179. * @param forPostProcess Define if we are currently in post process mode or not
  86180. */
  86181. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86182. /**
  86183. * Returns true if all the image processing information are ready.
  86184. * @returns True if ready, otherwise, false
  86185. */
  86186. isReady(): boolean;
  86187. /**
  86188. * Binds the image processing to the shader.
  86189. * @param effect The effect to bind to
  86190. * @param aspectRatio Define the current aspect ratio of the effect
  86191. */
  86192. bind(effect: Effect, aspectRatio?: number): void;
  86193. /**
  86194. * Clones the current image processing instance.
  86195. * @return The cloned image processing
  86196. */
  86197. clone(): ImageProcessingConfiguration;
  86198. /**
  86199. * Serializes the current image processing instance to a json representation.
  86200. * @return a JSON representation
  86201. */
  86202. serialize(): any;
  86203. /**
  86204. * Parses the image processing from a json representation.
  86205. * @param source the JSON source to parse
  86206. * @return The parsed image processing
  86207. */
  86208. static Parse(source: any): ImageProcessingConfiguration;
  86209. private static _VIGNETTEMODE_MULTIPLY;
  86210. private static _VIGNETTEMODE_OPAQUE;
  86211. /**
  86212. * Used to apply the vignette as a mix with the pixel color.
  86213. */
  86214. static readonly VIGNETTEMODE_MULTIPLY: number;
  86215. /**
  86216. * Used to apply the vignette as a replacement of the pixel color.
  86217. */
  86218. static readonly VIGNETTEMODE_OPAQUE: number;
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /**
  86223. * This represents all the required information to add a fresnel effect on a material:
  86224. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86225. */
  86226. export class FresnelParameters {
  86227. private _isEnabled;
  86228. /**
  86229. * Define if the fresnel effect is enable or not.
  86230. */
  86231. isEnabled: boolean;
  86232. /**
  86233. * Define the color used on edges (grazing angle)
  86234. */
  86235. leftColor: Color3;
  86236. /**
  86237. * Define the color used on center
  86238. */
  86239. rightColor: Color3;
  86240. /**
  86241. * Define bias applied to computed fresnel term
  86242. */
  86243. bias: number;
  86244. /**
  86245. * Defined the power exponent applied to fresnel term
  86246. */
  86247. power: number;
  86248. /**
  86249. * Clones the current fresnel and its valuues
  86250. * @returns a clone fresnel configuration
  86251. */
  86252. clone(): FresnelParameters;
  86253. /**
  86254. * Serializes the current fresnel parameters to a JSON representation.
  86255. * @return the JSON serialization
  86256. */
  86257. serialize(): any;
  86258. /**
  86259. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86260. * @param parsedFresnelParameters Define the JSON representation
  86261. * @returns the parsed parameters
  86262. */
  86263. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86264. }
  86265. }
  86266. declare module BABYLON {
  86267. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86268. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86269. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86270. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86271. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86272. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86273. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86274. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86275. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86276. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86277. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86278. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86279. /**
  86280. * Decorator used to define property that can be serialized as reference to a camera
  86281. * @param sourceName defines the name of the property to decorate
  86282. */
  86283. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86284. /**
  86285. * Class used to help serialization objects
  86286. */
  86287. export class SerializationHelper {
  86288. /** hidden */
  86289. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86290. /** hidden */
  86291. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86292. /** hidden */
  86293. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86294. /** hidden */
  86295. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86296. /**
  86297. * Appends the serialized animations from the source animations
  86298. * @param source Source containing the animations
  86299. * @param destination Target to store the animations
  86300. */
  86301. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86302. /**
  86303. * Static function used to serialized a specific entity
  86304. * @param entity defines the entity to serialize
  86305. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86306. * @returns a JSON compatible object representing the serialization of the entity
  86307. */
  86308. static Serialize<T>(entity: T, serializationObject?: any): any;
  86309. /**
  86310. * Creates a new entity from a serialization data object
  86311. * @param creationFunction defines a function used to instanciated the new entity
  86312. * @param source defines the source serialization data
  86313. * @param scene defines the hosting scene
  86314. * @param rootUrl defines the root url for resources
  86315. * @returns a new entity
  86316. */
  86317. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86318. /**
  86319. * Clones an object
  86320. * @param creationFunction defines the function used to instanciate the new object
  86321. * @param source defines the source object
  86322. * @returns the cloned object
  86323. */
  86324. static Clone<T>(creationFunction: () => T, source: T): T;
  86325. /**
  86326. * Instanciates a new object based on a source one (some data will be shared between both object)
  86327. * @param creationFunction defines the function used to instanciate the new object
  86328. * @param source defines the source object
  86329. * @returns the new object
  86330. */
  86331. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86332. }
  86333. }
  86334. declare module BABYLON {
  86335. /**
  86336. * This is the base class of all the camera used in the application.
  86337. * @see http://doc.babylonjs.com/features/cameras
  86338. */
  86339. export class Camera extends Node {
  86340. /** @hidden */
  86341. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86342. /**
  86343. * This is the default projection mode used by the cameras.
  86344. * It helps recreating a feeling of perspective and better appreciate depth.
  86345. * This is the best way to simulate real life cameras.
  86346. */
  86347. static readonly PERSPECTIVE_CAMERA: number;
  86348. /**
  86349. * This helps creating camera with an orthographic mode.
  86350. * 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.
  86351. */
  86352. static readonly ORTHOGRAPHIC_CAMERA: number;
  86353. /**
  86354. * This is the default FOV mode for perspective cameras.
  86355. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86356. */
  86357. static readonly FOVMODE_VERTICAL_FIXED: number;
  86358. /**
  86359. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86360. */
  86361. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86362. /**
  86363. * This specifies ther is no need for a camera rig.
  86364. * Basically only one eye is rendered corresponding to the camera.
  86365. */
  86366. static readonly RIG_MODE_NONE: number;
  86367. /**
  86368. * Simulates a camera Rig with one blue eye and one red eye.
  86369. * This can be use with 3d blue and red glasses.
  86370. */
  86371. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86372. /**
  86373. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86374. */
  86375. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86376. /**
  86377. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86378. */
  86379. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86380. /**
  86381. * Defines that both eyes of the camera will be rendered over under each other.
  86382. */
  86383. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86384. /**
  86385. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86386. */
  86387. static readonly RIG_MODE_VR: number;
  86388. /**
  86389. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86390. */
  86391. static readonly RIG_MODE_WEBVR: number;
  86392. /**
  86393. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86394. */
  86395. static readonly RIG_MODE_CUSTOM: number;
  86396. /**
  86397. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86398. */
  86399. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86400. /**
  86401. * @hidden
  86402. * Might be removed once multiview will be a thing
  86403. */
  86404. static UseAlternateWebVRRendering: boolean;
  86405. /**
  86406. * Define the input manager associated with the camera.
  86407. */
  86408. inputs: CameraInputsManager<Camera>;
  86409. /**
  86410. * Define the current local position of the camera in the scene
  86411. */
  86412. position: Vector3;
  86413. /**
  86414. * The vector the camera should consider as up.
  86415. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86416. */
  86417. upVector: Vector3;
  86418. /**
  86419. * Define the current limit on the left side for an orthographic camera
  86420. * In scene unit
  86421. */
  86422. orthoLeft: Nullable<number>;
  86423. /**
  86424. * Define the current limit on the right side for an orthographic camera
  86425. * In scene unit
  86426. */
  86427. orthoRight: Nullable<number>;
  86428. /**
  86429. * Define the current limit on the bottom side for an orthographic camera
  86430. * In scene unit
  86431. */
  86432. orthoBottom: Nullable<number>;
  86433. /**
  86434. * Define the current limit on the top side for an orthographic camera
  86435. * In scene unit
  86436. */
  86437. orthoTop: Nullable<number>;
  86438. /**
  86439. * Field Of View is set in Radians. (default is 0.8)
  86440. */
  86441. fov: number;
  86442. /**
  86443. * Define the minimum distance the camera can see from.
  86444. * This is important to note that the depth buffer are not infinite and the closer it starts
  86445. * the more your scene might encounter depth fighting issue.
  86446. */
  86447. minZ: number;
  86448. /**
  86449. * Define the maximum distance the camera can see to.
  86450. * This is important to note that the depth buffer are not infinite and the further it end
  86451. * the more your scene might encounter depth fighting issue.
  86452. */
  86453. maxZ: number;
  86454. /**
  86455. * Define the default inertia of the camera.
  86456. * This helps giving a smooth feeling to the camera movement.
  86457. */
  86458. inertia: number;
  86459. /**
  86460. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86461. */
  86462. mode: number;
  86463. /**
  86464. * Define wether the camera is intermediate.
  86465. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86466. */
  86467. isIntermediate: boolean;
  86468. /**
  86469. * Define the viewport of the camera.
  86470. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86471. */
  86472. viewport: Viewport;
  86473. /**
  86474. * Restricts the camera to viewing objects with the same layerMask.
  86475. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86476. */
  86477. layerMask: number;
  86478. /**
  86479. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86480. */
  86481. fovMode: number;
  86482. /**
  86483. * Rig mode of the camera.
  86484. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86485. * This is normally controlled byt the camera themselves as internal use.
  86486. */
  86487. cameraRigMode: number;
  86488. /**
  86489. * Defines the distance between both "eyes" in case of a RIG
  86490. */
  86491. interaxialDistance: number;
  86492. /**
  86493. * Defines if stereoscopic rendering is done side by side or over under.
  86494. */
  86495. isStereoscopicSideBySide: boolean;
  86496. /**
  86497. * 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
  86498. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86499. * else in the scene.
  86500. */
  86501. customRenderTargets: RenderTargetTexture[];
  86502. /**
  86503. * When set, the camera will render to this render target instead of the default canvas
  86504. */
  86505. outputRenderTarget: Nullable<RenderTargetTexture>;
  86506. /**
  86507. * Observable triggered when the camera view matrix has changed.
  86508. */
  86509. onViewMatrixChangedObservable: Observable<Camera>;
  86510. /**
  86511. * Observable triggered when the camera Projection matrix has changed.
  86512. */
  86513. onProjectionMatrixChangedObservable: Observable<Camera>;
  86514. /**
  86515. * Observable triggered when the inputs have been processed.
  86516. */
  86517. onAfterCheckInputsObservable: Observable<Camera>;
  86518. /**
  86519. * Observable triggered when reset has been called and applied to the camera.
  86520. */
  86521. onRestoreStateObservable: Observable<Camera>;
  86522. /** @hidden */
  86523. _cameraRigParams: any;
  86524. /** @hidden */
  86525. _rigCameras: Camera[];
  86526. /** @hidden */
  86527. _rigPostProcess: Nullable<PostProcess>;
  86528. protected _webvrViewMatrix: Matrix;
  86529. /** @hidden */
  86530. _skipRendering: boolean;
  86531. /** @hidden */
  86532. _alternateCamera: Camera;
  86533. /** @hidden */
  86534. _projectionMatrix: Matrix;
  86535. /** @hidden */
  86536. _postProcesses: Nullable<PostProcess>[];
  86537. /** @hidden */
  86538. _activeMeshes: SmartArray<AbstractMesh>;
  86539. protected _globalPosition: Vector3;
  86540. /** hidden */
  86541. _computedViewMatrix: Matrix;
  86542. private _doNotComputeProjectionMatrix;
  86543. private _transformMatrix;
  86544. private _frustumPlanes;
  86545. private _refreshFrustumPlanes;
  86546. private _storedFov;
  86547. private _stateStored;
  86548. /**
  86549. * Instantiates a new camera object.
  86550. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86551. * @see http://doc.babylonjs.com/features/cameras
  86552. * @param name Defines the name of the camera in the scene
  86553. * @param position Defines the position of the camera
  86554. * @param scene Defines the scene the camera belongs too
  86555. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86556. */
  86557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86558. /**
  86559. * Store current camera state (fov, position, etc..)
  86560. * @returns the camera
  86561. */
  86562. storeState(): Camera;
  86563. /**
  86564. * Restores the camera state values if it has been stored. You must call storeState() first
  86565. */
  86566. protected _restoreStateValues(): boolean;
  86567. /**
  86568. * Restored camera state. You must call storeState() first.
  86569. * @returns true if restored and false otherwise
  86570. */
  86571. restoreState(): boolean;
  86572. /**
  86573. * Gets the class name of the camera.
  86574. * @returns the class name
  86575. */
  86576. getClassName(): string;
  86577. /** @hidden */
  86578. readonly _isCamera: boolean;
  86579. /**
  86580. * Gets a string representation of the camera useful for debug purpose.
  86581. * @param fullDetails Defines that a more verboe level of logging is required
  86582. * @returns the string representation
  86583. */
  86584. toString(fullDetails?: boolean): string;
  86585. /**
  86586. * Gets the current world space position of the camera.
  86587. */
  86588. readonly globalPosition: Vector3;
  86589. /**
  86590. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86591. * @returns the active meshe list
  86592. */
  86593. getActiveMeshes(): SmartArray<AbstractMesh>;
  86594. /**
  86595. * Check wether a mesh is part of the current active mesh list of the camera
  86596. * @param mesh Defines the mesh to check
  86597. * @returns true if active, false otherwise
  86598. */
  86599. isActiveMesh(mesh: Mesh): boolean;
  86600. /**
  86601. * Is this camera ready to be used/rendered
  86602. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86603. * @return true if the camera is ready
  86604. */
  86605. isReady(completeCheck?: boolean): boolean;
  86606. /** @hidden */
  86607. _initCache(): void;
  86608. /** @hidden */
  86609. _updateCache(ignoreParentClass?: boolean): void;
  86610. /** @hidden */
  86611. _isSynchronized(): boolean;
  86612. /** @hidden */
  86613. _isSynchronizedViewMatrix(): boolean;
  86614. /** @hidden */
  86615. _isSynchronizedProjectionMatrix(): boolean;
  86616. /**
  86617. * Attach the input controls to a specific dom element to get the input from.
  86618. * @param element Defines the element the controls should be listened from
  86619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86620. */
  86621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86622. /**
  86623. * Detach the current controls from the specified dom element.
  86624. * @param element Defines the element to stop listening the inputs from
  86625. */
  86626. detachControl(element: HTMLElement): void;
  86627. /**
  86628. * Update the camera state according to the different inputs gathered during the frame.
  86629. */
  86630. update(): void;
  86631. /** @hidden */
  86632. _checkInputs(): void;
  86633. /** @hidden */
  86634. readonly rigCameras: Camera[];
  86635. /**
  86636. * Gets the post process used by the rig cameras
  86637. */
  86638. readonly rigPostProcess: Nullable<PostProcess>;
  86639. /**
  86640. * Internal, gets the first post proces.
  86641. * @returns the first post process to be run on this camera.
  86642. */
  86643. _getFirstPostProcess(): Nullable<PostProcess>;
  86644. private _cascadePostProcessesToRigCams;
  86645. /**
  86646. * Attach a post process to the camera.
  86647. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86648. * @param postProcess The post process to attach to the camera
  86649. * @param insertAt The position of the post process in case several of them are in use in the scene
  86650. * @returns the position the post process has been inserted at
  86651. */
  86652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86653. /**
  86654. * Detach a post process to the camera.
  86655. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86656. * @param postProcess The post process to detach from the camera
  86657. */
  86658. detachPostProcess(postProcess: PostProcess): void;
  86659. /**
  86660. * Gets the current world matrix of the camera
  86661. */
  86662. getWorldMatrix(): Matrix;
  86663. /** @hidden */
  86664. _getViewMatrix(): Matrix;
  86665. /**
  86666. * Gets the current view matrix of the camera.
  86667. * @param force forces the camera to recompute the matrix without looking at the cached state
  86668. * @returns the view matrix
  86669. */
  86670. getViewMatrix(force?: boolean): Matrix;
  86671. /**
  86672. * Freeze the projection matrix.
  86673. * It will prevent the cache check of the camera projection compute and can speed up perf
  86674. * if no parameter of the camera are meant to change
  86675. * @param projection Defines manually a projection if necessary
  86676. */
  86677. freezeProjectionMatrix(projection?: Matrix): void;
  86678. /**
  86679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86680. */
  86681. unfreezeProjectionMatrix(): void;
  86682. /**
  86683. * Gets the current projection matrix of the camera.
  86684. * @param force forces the camera to recompute the matrix without looking at the cached state
  86685. * @returns the projection matrix
  86686. */
  86687. getProjectionMatrix(force?: boolean): Matrix;
  86688. /**
  86689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86690. * @returns a Matrix
  86691. */
  86692. getTransformationMatrix(): Matrix;
  86693. private _updateFrustumPlanes;
  86694. /**
  86695. * Checks if a cullable object (mesh...) is in the camera frustum
  86696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86697. * @param target The object to check
  86698. * @returns true if the object is in frustum otherwise false
  86699. */
  86700. isInFrustum(target: ICullable): boolean;
  86701. /**
  86702. * Checks if a cullable object (mesh...) is in the camera frustum
  86703. * Unlike isInFrustum this cheks the full bounding box
  86704. * @param target The object to check
  86705. * @returns true if the object is in frustum otherwise false
  86706. */
  86707. isCompletelyInFrustum(target: ICullable): boolean;
  86708. /**
  86709. * Gets a ray in the forward direction from the camera.
  86710. * @param length Defines the length of the ray to create
  86711. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86712. * @param origin Defines the start point of the ray which defaults to the camera position
  86713. * @returns the forward ray
  86714. */
  86715. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86716. /**
  86717. * Releases resources associated with this node.
  86718. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86719. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86720. */
  86721. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86722. /**
  86723. * Gets the left camera of a rig setup in case of Rigged Camera
  86724. */
  86725. readonly leftCamera: Nullable<FreeCamera>;
  86726. /**
  86727. * Gets the right camera of a rig setup in case of Rigged Camera
  86728. */
  86729. readonly rightCamera: Nullable<FreeCamera>;
  86730. /**
  86731. * Gets the left camera target of a rig setup in case of Rigged Camera
  86732. * @returns the target position
  86733. */
  86734. getLeftTarget(): Nullable<Vector3>;
  86735. /**
  86736. * Gets the right camera target of a rig setup in case of Rigged Camera
  86737. * @returns the target position
  86738. */
  86739. getRightTarget(): Nullable<Vector3>;
  86740. /**
  86741. * @hidden
  86742. */
  86743. setCameraRigMode(mode: number, rigParams: any): void;
  86744. /** @hidden */
  86745. static _setStereoscopicRigMode(camera: Camera): void;
  86746. /** @hidden */
  86747. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86748. /** @hidden */
  86749. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86750. /** @hidden */
  86751. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86752. /** @hidden */
  86753. _getVRProjectionMatrix(): Matrix;
  86754. protected _updateCameraRotationMatrix(): void;
  86755. protected _updateWebVRCameraRotationMatrix(): void;
  86756. /**
  86757. * This function MUST be overwritten by the different WebVR cameras available.
  86758. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86759. * @hidden
  86760. */
  86761. _getWebVRProjectionMatrix(): Matrix;
  86762. /**
  86763. * This function MUST be overwritten by the different WebVR cameras available.
  86764. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86765. * @hidden
  86766. */
  86767. _getWebVRViewMatrix(): Matrix;
  86768. /** @hidden */
  86769. setCameraRigParameter(name: string, value: any): void;
  86770. /**
  86771. * needs to be overridden by children so sub has required properties to be copied
  86772. * @hidden
  86773. */
  86774. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86775. /**
  86776. * May need to be overridden by children
  86777. * @hidden
  86778. */
  86779. _updateRigCameras(): void;
  86780. /** @hidden */
  86781. _setupInputs(): void;
  86782. /**
  86783. * Serialiaze the camera setup to a json represention
  86784. * @returns the JSON representation
  86785. */
  86786. serialize(): any;
  86787. /**
  86788. * Clones the current camera.
  86789. * @param name The cloned camera name
  86790. * @returns the cloned camera
  86791. */
  86792. clone(name: string): Camera;
  86793. /**
  86794. * Gets the direction of the camera relative to a given local axis.
  86795. * @param localAxis Defines the reference axis to provide a relative direction.
  86796. * @return the direction
  86797. */
  86798. getDirection(localAxis: Vector3): Vector3;
  86799. /**
  86800. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86801. * @param localAxis Defines the reference axis to provide a relative direction.
  86802. * @param result Defines the vector to store the result in
  86803. */
  86804. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86805. /**
  86806. * Gets a camera constructor for a given camera type
  86807. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86808. * @param name The name of the camera the result will be able to instantiate
  86809. * @param scene The scene the result will construct the camera in
  86810. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86811. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86812. * @returns a factory method to construc the camera
  86813. */
  86814. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86815. /**
  86816. * Compute the world matrix of the camera.
  86817. * @returns the camera workd matrix
  86818. */
  86819. computeWorldMatrix(): Matrix;
  86820. /**
  86821. * Parse a JSON and creates the camera from the parsed information
  86822. * @param parsedCamera The JSON to parse
  86823. * @param scene The scene to instantiate the camera in
  86824. * @returns the newly constructed camera
  86825. */
  86826. static Parse(parsedCamera: any, scene: Scene): Camera;
  86827. }
  86828. }
  86829. declare module BABYLON {
  86830. /**
  86831. * Interface for any object that can request an animation frame
  86832. */
  86833. export interface ICustomAnimationFrameRequester {
  86834. /**
  86835. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86836. */
  86837. renderFunction?: Function;
  86838. /**
  86839. * Called to request the next frame to render to
  86840. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86841. */
  86842. requestAnimationFrame: Function;
  86843. /**
  86844. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86845. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86846. */
  86847. requestID?: number;
  86848. }
  86849. /**
  86850. * Interface containing an array of animations
  86851. */
  86852. export interface IAnimatable {
  86853. /**
  86854. * Array of animations
  86855. */
  86856. animations: Array<Animation>;
  86857. }
  86858. /** Interface used by value gradients (color, factor, ...) */
  86859. export interface IValueGradient {
  86860. /**
  86861. * Gets or sets the gradient value (between 0 and 1)
  86862. */
  86863. gradient: number;
  86864. }
  86865. /** Class used to store color4 gradient */
  86866. export class ColorGradient implements IValueGradient {
  86867. /**
  86868. * Gets or sets the gradient value (between 0 and 1)
  86869. */
  86870. gradient: number;
  86871. /**
  86872. * Gets or sets first associated color
  86873. */
  86874. color1: Color4;
  86875. /**
  86876. * Gets or sets second associated color
  86877. */
  86878. color2?: Color4;
  86879. /**
  86880. * Will get a color picked randomly between color1 and color2.
  86881. * If color2 is undefined then color1 will be used
  86882. * @param result defines the target Color4 to store the result in
  86883. */
  86884. getColorToRef(result: Color4): void;
  86885. }
  86886. /** Class used to store color 3 gradient */
  86887. export class Color3Gradient implements IValueGradient {
  86888. /**
  86889. * Gets or sets the gradient value (between 0 and 1)
  86890. */
  86891. gradient: number;
  86892. /**
  86893. * Gets or sets the associated color
  86894. */
  86895. color: Color3;
  86896. }
  86897. /** Class used to store factor gradient */
  86898. export class FactorGradient implements IValueGradient {
  86899. /**
  86900. * Gets or sets the gradient value (between 0 and 1)
  86901. */
  86902. gradient: number;
  86903. /**
  86904. * Gets or sets first associated factor
  86905. */
  86906. factor1: number;
  86907. /**
  86908. * Gets or sets second associated factor
  86909. */
  86910. factor2?: number;
  86911. /**
  86912. * Will get a number picked randomly between factor1 and factor2.
  86913. * If factor2 is undefined then factor1 will be used
  86914. * @returns the picked number
  86915. */
  86916. getFactor(): number;
  86917. }
  86918. /**
  86919. * @ignore
  86920. * Application error to support additional information when loading a file
  86921. */
  86922. export class LoadFileError extends Error {
  86923. /** defines the optional XHR request */
  86924. request?: XMLHttpRequest | undefined;
  86925. private static _setPrototypeOf;
  86926. /**
  86927. * Creates a new LoadFileError
  86928. * @param message defines the message of the error
  86929. * @param request defines the optional XHR request
  86930. */
  86931. constructor(message: string,
  86932. /** defines the optional XHR request */
  86933. request?: XMLHttpRequest | undefined);
  86934. }
  86935. /**
  86936. * Class used to define a retry strategy when error happens while loading assets
  86937. */
  86938. export class RetryStrategy {
  86939. /**
  86940. * Function used to defines an exponential back off strategy
  86941. * @param maxRetries defines the maximum number of retries (3 by default)
  86942. * @param baseInterval defines the interval between retries
  86943. * @returns the strategy function to use
  86944. */
  86945. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86946. }
  86947. /**
  86948. * File request interface
  86949. */
  86950. export interface IFileRequest {
  86951. /**
  86952. * Raised when the request is complete (success or error).
  86953. */
  86954. onCompleteObservable: Observable<IFileRequest>;
  86955. /**
  86956. * Aborts the request for a file.
  86957. */
  86958. abort: () => void;
  86959. }
  86960. /**
  86961. * Class containing a set of static utilities functions
  86962. */
  86963. export class Tools {
  86964. /**
  86965. * Gets or sets the base URL to use to load assets
  86966. */
  86967. static BaseUrl: string;
  86968. /**
  86969. * Enable/Disable Custom HTTP Request Headers globally.
  86970. * default = false
  86971. * @see CustomRequestHeaders
  86972. */
  86973. static UseCustomRequestHeaders: boolean;
  86974. /**
  86975. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86976. * i.e. when loading files, where the server/service expects an Authorization header.
  86977. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86978. */
  86979. static CustomRequestHeaders: {
  86980. [key: string]: string;
  86981. };
  86982. /**
  86983. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86984. */
  86985. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86986. /**
  86987. * Default behaviour for cors in the application.
  86988. * It can be a string if the expected behavior is identical in the entire app.
  86989. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86990. */
  86991. static CorsBehavior: string | ((url: string | string[]) => string);
  86992. /**
  86993. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86994. * @ignorenaming
  86995. */
  86996. static UseFallbackTexture: boolean;
  86997. /**
  86998. * Use this object to register external classes like custom textures or material
  86999. * to allow the laoders to instantiate them
  87000. */
  87001. static RegisteredExternalClasses: {
  87002. [key: string]: Object;
  87003. };
  87004. /**
  87005. * Texture content used if a texture cannot loaded
  87006. * @ignorenaming
  87007. */
  87008. static fallbackTexture: string;
  87009. /**
  87010. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87011. * @param u defines the coordinate on X axis
  87012. * @param v defines the coordinate on Y axis
  87013. * @param width defines the width of the source data
  87014. * @param height defines the height of the source data
  87015. * @param pixels defines the source byte array
  87016. * @param color defines the output color
  87017. */
  87018. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87019. /**
  87020. * Interpolates between a and b via alpha
  87021. * @param a The lower value (returned when alpha = 0)
  87022. * @param b The upper value (returned when alpha = 1)
  87023. * @param alpha The interpolation-factor
  87024. * @return The mixed value
  87025. */
  87026. static Mix(a: number, b: number, alpha: number): number;
  87027. /**
  87028. * Tries to instantiate a new object from a given class name
  87029. * @param className defines the class name to instantiate
  87030. * @returns the new object or null if the system was not able to do the instantiation
  87031. */
  87032. static Instantiate(className: string): any;
  87033. /**
  87034. * Provides a slice function that will work even on IE
  87035. * @param data defines the array to slice
  87036. * @param start defines the start of the data (optional)
  87037. * @param end defines the end of the data (optional)
  87038. * @returns the new sliced array
  87039. */
  87040. static Slice<T>(data: T, start?: number, end?: number): T;
  87041. /**
  87042. * Polyfill for setImmediate
  87043. * @param action defines the action to execute after the current execution block
  87044. */
  87045. static SetImmediate(action: () => void): void;
  87046. /**
  87047. * Function indicating if a number is an exponent of 2
  87048. * @param value defines the value to test
  87049. * @returns true if the value is an exponent of 2
  87050. */
  87051. static IsExponentOfTwo(value: number): boolean;
  87052. private static _tmpFloatArray;
  87053. /**
  87054. * Returns the nearest 32-bit single precision float representation of a Number
  87055. * @param value A Number. If the parameter is of a different type, it will get converted
  87056. * to a number or to NaN if it cannot be converted
  87057. * @returns number
  87058. */
  87059. static FloatRound(value: number): number;
  87060. /**
  87061. * Find the next highest power of two.
  87062. * @param x Number to start search from.
  87063. * @return Next highest power of two.
  87064. */
  87065. static CeilingPOT(x: number): number;
  87066. /**
  87067. * Find the next lowest power of two.
  87068. * @param x Number to start search from.
  87069. * @return Next lowest power of two.
  87070. */
  87071. static FloorPOT(x: number): number;
  87072. /**
  87073. * Find the nearest power of two.
  87074. * @param x Number to start search from.
  87075. * @return Next nearest power of two.
  87076. */
  87077. static NearestPOT(x: number): number;
  87078. /**
  87079. * Get the closest exponent of two
  87080. * @param value defines the value to approximate
  87081. * @param max defines the maximum value to return
  87082. * @param mode defines how to define the closest value
  87083. * @returns closest exponent of two of the given value
  87084. */
  87085. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87086. /**
  87087. * Extracts the filename from a path
  87088. * @param path defines the path to use
  87089. * @returns the filename
  87090. */
  87091. static GetFilename(path: string): string;
  87092. /**
  87093. * Extracts the "folder" part of a path (everything before the filename).
  87094. * @param uri The URI to extract the info from
  87095. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87096. * @returns The "folder" part of the path
  87097. */
  87098. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87099. /**
  87100. * Extracts text content from a DOM element hierarchy
  87101. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87102. */
  87103. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87104. /**
  87105. * Convert an angle in radians to degrees
  87106. * @param angle defines the angle to convert
  87107. * @returns the angle in degrees
  87108. */
  87109. static ToDegrees(angle: number): number;
  87110. /**
  87111. * Convert an angle in degrees to radians
  87112. * @param angle defines the angle to convert
  87113. * @returns the angle in radians
  87114. */
  87115. static ToRadians(angle: number): number;
  87116. /**
  87117. * Encode a buffer to a base64 string
  87118. * @param buffer defines the buffer to encode
  87119. * @returns the encoded string
  87120. */
  87121. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87122. /**
  87123. * Extracts minimum and maximum values from a list of indexed positions
  87124. * @param positions defines the positions to use
  87125. * @param indices defines the indices to the positions
  87126. * @param indexStart defines the start index
  87127. * @param indexCount defines the end index
  87128. * @param bias defines bias value to add to the result
  87129. * @return minimum and maximum values
  87130. */
  87131. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87132. minimum: Vector3;
  87133. maximum: Vector3;
  87134. };
  87135. /**
  87136. * Extracts minimum and maximum values from a list of positions
  87137. * @param positions defines the positions to use
  87138. * @param start defines the start index in the positions array
  87139. * @param count defines the number of positions to handle
  87140. * @param bias defines bias value to add to the result
  87141. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87142. * @return minimum and maximum values
  87143. */
  87144. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87145. minimum: Vector3;
  87146. maximum: Vector3;
  87147. };
  87148. /**
  87149. * Returns an array if obj is not an array
  87150. * @param obj defines the object to evaluate as an array
  87151. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87152. * @returns either obj directly if obj is an array or a new array containing obj
  87153. */
  87154. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87155. /**
  87156. * Gets the pointer prefix to use
  87157. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87158. */
  87159. static GetPointerPrefix(): string;
  87160. /**
  87161. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87162. * @param func - the function to be called
  87163. * @param requester - the object that will request the next frame. Falls back to window.
  87164. * @returns frame number
  87165. */
  87166. static QueueNewFrame(func: () => void, requester?: any): number;
  87167. /**
  87168. * Ask the browser to promote the current element to fullscreen rendering mode
  87169. * @param element defines the DOM element to promote
  87170. */
  87171. static RequestFullscreen(element: HTMLElement): void;
  87172. /**
  87173. * Asks the browser to exit fullscreen mode
  87174. */
  87175. static ExitFullscreen(): void;
  87176. /**
  87177. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87178. * @param url define the url we are trying
  87179. * @param element define the dom element where to configure the cors policy
  87180. */
  87181. static SetCorsBehavior(url: string | string[], element: {
  87182. crossOrigin: string | null;
  87183. }): void;
  87184. /**
  87185. * Removes unwanted characters from an url
  87186. * @param url defines the url to clean
  87187. * @returns the cleaned url
  87188. */
  87189. static CleanUrl(url: string): string;
  87190. /**
  87191. * Gets or sets a function used to pre-process url before using them to load assets
  87192. */
  87193. static PreprocessUrl: (url: string) => string;
  87194. /**
  87195. * Loads an image as an HTMLImageElement.
  87196. * @param input url string, ArrayBuffer, or Blob to load
  87197. * @param onLoad callback called when the image successfully loads
  87198. * @param onError callback called when the image fails to load
  87199. * @param offlineProvider offline provider for caching
  87200. * @returns the HTMLImageElement of the loaded image
  87201. */
  87202. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87203. /**
  87204. * Loads a file
  87205. * @param url url string, ArrayBuffer, or Blob to load
  87206. * @param onSuccess callback called when the file successfully loads
  87207. * @param onProgress callback called while file is loading (if the server supports this mode)
  87208. * @param offlineProvider defines the offline provider for caching
  87209. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87210. * @param onError callback called when the file fails to load
  87211. * @returns a file request object
  87212. */
  87213. 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;
  87214. /**
  87215. * Load a script (identified by an url). When the url returns, the
  87216. * content of this file is added into a new script element, attached to the DOM (body element)
  87217. * @param scriptUrl defines the url of the script to laod
  87218. * @param onSuccess defines the callback called when the script is loaded
  87219. * @param onError defines the callback to call if an error occurs
  87220. */
  87221. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87222. /**
  87223. * Loads a file from a blob
  87224. * @param fileToLoad defines the blob to use
  87225. * @param callback defines the callback to call when data is loaded
  87226. * @param progressCallback defines the callback to call during loading process
  87227. * @returns a file request object
  87228. */
  87229. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87230. /**
  87231. * Loads a file
  87232. * @param fileToLoad defines the file to load
  87233. * @param callback defines the callback to call when data is loaded
  87234. * @param progressCallBack defines the callback to call during loading process
  87235. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87236. * @returns a file request object
  87237. */
  87238. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87239. /**
  87240. * Creates a data url from a given string content
  87241. * @param content defines the content to convert
  87242. * @returns the new data url link
  87243. */
  87244. static FileAsURL(content: string): string;
  87245. /**
  87246. * Format the given number to a specific decimal format
  87247. * @param value defines the number to format
  87248. * @param decimals defines the number of decimals to use
  87249. * @returns the formatted string
  87250. */
  87251. static Format(value: number, decimals?: number): string;
  87252. /**
  87253. * Checks if a given vector is inside a specific range
  87254. * @param v defines the vector to test
  87255. * @param min defines the minimum range
  87256. * @param max defines the maximum range
  87257. */
  87258. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87259. /**
  87260. * Tries to copy an object by duplicating every property
  87261. * @param source defines the source object
  87262. * @param destination defines the target object
  87263. * @param doNotCopyList defines a list of properties to avoid
  87264. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87265. */
  87266. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87267. /**
  87268. * Gets a boolean indicating if the given object has no own property
  87269. * @param obj defines the object to test
  87270. * @returns true if object has no own property
  87271. */
  87272. static IsEmpty(obj: any): boolean;
  87273. /**
  87274. * Function used to register events at window level
  87275. * @param events defines the events to register
  87276. */
  87277. static RegisterTopRootEvents(events: {
  87278. name: string;
  87279. handler: Nullable<(e: FocusEvent) => any>;
  87280. }[]): void;
  87281. /**
  87282. * Function used to unregister events from window level
  87283. * @param events defines the events to unregister
  87284. */
  87285. static UnregisterTopRootEvents(events: {
  87286. name: string;
  87287. handler: Nullable<(e: FocusEvent) => any>;
  87288. }[]): void;
  87289. /**
  87290. * Dumps the current bound framebuffer
  87291. * @param width defines the rendering width
  87292. * @param height defines the rendering height
  87293. * @param engine defines the hosting engine
  87294. * @param successCallback defines the callback triggered once the data are available
  87295. * @param mimeType defines the mime type of the result
  87296. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87297. */
  87298. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87299. /**
  87300. * Converts the canvas data to blob.
  87301. * This acts as a polyfill for browsers not supporting the to blob function.
  87302. * @param canvas Defines the canvas to extract the data from
  87303. * @param successCallback Defines the callback triggered once the data are available
  87304. * @param mimeType Defines the mime type of the result
  87305. */
  87306. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87307. /**
  87308. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87309. * @param successCallback defines the callback triggered once the data are available
  87310. * @param mimeType defines the mime type of the result
  87311. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87312. */
  87313. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87314. /**
  87315. * Downloads a blob in the browser
  87316. * @param blob defines the blob to download
  87317. * @param fileName defines the name of the downloaded file
  87318. */
  87319. static Download(blob: Blob, fileName: string): void;
  87320. /**
  87321. * Captures a screenshot of the current rendering
  87322. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87323. * @param engine defines the rendering engine
  87324. * @param camera defines the source camera
  87325. * @param size This parameter can be set to a single number or to an object with the
  87326. * following (optional) properties: precision, width, height. If a single number is passed,
  87327. * it will be used for both width and height. If an object is passed, the screenshot size
  87328. * will be derived from the parameters. The precision property is a multiplier allowing
  87329. * rendering at a higher or lower resolution
  87330. * @param successCallback defines the callback receives a single parameter which contains the
  87331. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87332. * src parameter of an <img> to display it
  87333. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87334. * Check your browser for supported MIME types
  87335. */
  87336. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87337. /**
  87338. * Generates an image screenshot from the specified camera.
  87339. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87340. * @param engine The engine to use for rendering
  87341. * @param camera The camera to use for rendering
  87342. * @param size This parameter can be set to a single number or to an object with the
  87343. * following (optional) properties: precision, width, height. If a single number is passed,
  87344. * it will be used for both width and height. If an object is passed, the screenshot size
  87345. * will be derived from the parameters. The precision property is a multiplier allowing
  87346. * rendering at a higher or lower resolution
  87347. * @param successCallback The callback receives a single parameter which contains the
  87348. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87349. * src parameter of an <img> to display it
  87350. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87351. * Check your browser for supported MIME types
  87352. * @param samples Texture samples (default: 1)
  87353. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87354. * @param fileName A name for for the downloaded file.
  87355. */
  87356. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87357. /**
  87358. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87359. * Be aware Math.random() could cause collisions, but:
  87360. * "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"
  87361. * @returns a pseudo random id
  87362. */
  87363. static RandomId(): string;
  87364. /**
  87365. * Test if the given uri is a base64 string
  87366. * @param uri The uri to test
  87367. * @return True if the uri is a base64 string or false otherwise
  87368. */
  87369. static IsBase64(uri: string): boolean;
  87370. /**
  87371. * Decode the given base64 uri.
  87372. * @param uri The uri to decode
  87373. * @return The decoded base64 data.
  87374. */
  87375. static DecodeBase64(uri: string): ArrayBuffer;
  87376. /**
  87377. * No log
  87378. */
  87379. static readonly NoneLogLevel: number;
  87380. /**
  87381. * Only message logs
  87382. */
  87383. static readonly MessageLogLevel: number;
  87384. /**
  87385. * Only warning logs
  87386. */
  87387. static readonly WarningLogLevel: number;
  87388. /**
  87389. * Only error logs
  87390. */
  87391. static readonly ErrorLogLevel: number;
  87392. /**
  87393. * All logs
  87394. */
  87395. static readonly AllLogLevel: number;
  87396. /**
  87397. * Gets a value indicating the number of loading errors
  87398. * @ignorenaming
  87399. */
  87400. static readonly errorsCount: number;
  87401. /**
  87402. * Callback called when a new log is added
  87403. */
  87404. static OnNewCacheEntry: (entry: string) => void;
  87405. /**
  87406. * Log a message to the console
  87407. * @param message defines the message to log
  87408. */
  87409. static Log(message: string): void;
  87410. /**
  87411. * Write a warning message to the console
  87412. * @param message defines the message to log
  87413. */
  87414. static Warn(message: string): void;
  87415. /**
  87416. * Write an error message to the console
  87417. * @param message defines the message to log
  87418. */
  87419. static Error(message: string): void;
  87420. /**
  87421. * Gets current log cache (list of logs)
  87422. */
  87423. static readonly LogCache: string;
  87424. /**
  87425. * Clears the log cache
  87426. */
  87427. static ClearLogCache(): void;
  87428. /**
  87429. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87430. */
  87431. static LogLevels: number;
  87432. /**
  87433. * Checks if the loaded document was accessed via `file:`-Protocol.
  87434. * @returns boolean
  87435. */
  87436. static IsFileURL(): boolean;
  87437. /**
  87438. * Checks if the window object exists
  87439. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87440. */
  87441. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87442. /**
  87443. * No performance log
  87444. */
  87445. static readonly PerformanceNoneLogLevel: number;
  87446. /**
  87447. * Use user marks to log performance
  87448. */
  87449. static readonly PerformanceUserMarkLogLevel: number;
  87450. /**
  87451. * Log performance to the console
  87452. */
  87453. static readonly PerformanceConsoleLogLevel: number;
  87454. private static _performance;
  87455. /**
  87456. * Sets the current performance log level
  87457. */
  87458. static PerformanceLogLevel: number;
  87459. private static _StartPerformanceCounterDisabled;
  87460. private static _EndPerformanceCounterDisabled;
  87461. private static _StartUserMark;
  87462. private static _EndUserMark;
  87463. private static _StartPerformanceConsole;
  87464. private static _EndPerformanceConsole;
  87465. /**
  87466. * Injects the @see CustomRequestHeaders into the given request
  87467. * @param request the request that should be used for injection
  87468. */
  87469. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87470. /**
  87471. * Starts a performance counter
  87472. */
  87473. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87474. /**
  87475. * Ends a specific performance coutner
  87476. */
  87477. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87478. /**
  87479. * Gets either window.performance.now() if supported or Date.now() else
  87480. */
  87481. static readonly Now: number;
  87482. /**
  87483. * This method will return the name of the class used to create the instance of the given object.
  87484. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87485. * @param object the object to get the class name from
  87486. * @param isType defines if the object is actually a type
  87487. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87488. */
  87489. static GetClassName(object: any, isType?: boolean): string;
  87490. /**
  87491. * Gets the first element of an array satisfying a given predicate
  87492. * @param array defines the array to browse
  87493. * @param predicate defines the predicate to use
  87494. * @returns null if not found or the element
  87495. */
  87496. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87497. /**
  87498. * This method will return the name of the full name of the class, including its owning module (if any).
  87499. * 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).
  87500. * @param object the object to get the class name from
  87501. * @param isType defines if the object is actually a type
  87502. * @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.
  87503. * @ignorenaming
  87504. */
  87505. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87506. /**
  87507. * Returns a promise that resolves after the given amount of time.
  87508. * @param delay Number of milliseconds to delay
  87509. * @returns Promise that resolves after the given amount of time
  87510. */
  87511. static DelayAsync(delay: number): Promise<void>;
  87512. /**
  87513. * Gets the current gradient from an array of IValueGradient
  87514. * @param ratio defines the current ratio to get
  87515. * @param gradients defines the array of IValueGradient
  87516. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87517. */
  87518. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87519. }
  87520. /**
  87521. * This class is used to track a performance counter which is number based.
  87522. * The user has access to many properties which give statistics of different nature.
  87523. *
  87524. * The implementer can track two kinds of Performance Counter: time and count.
  87525. * 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.
  87526. * 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.
  87527. */
  87528. export class PerfCounter {
  87529. /**
  87530. * Gets or sets a global boolean to turn on and off all the counters
  87531. */
  87532. static Enabled: boolean;
  87533. /**
  87534. * Returns the smallest value ever
  87535. */
  87536. readonly min: number;
  87537. /**
  87538. * Returns the biggest value ever
  87539. */
  87540. readonly max: number;
  87541. /**
  87542. * Returns the average value since the performance counter is running
  87543. */
  87544. readonly average: number;
  87545. /**
  87546. * Returns the average value of the last second the counter was monitored
  87547. */
  87548. readonly lastSecAverage: number;
  87549. /**
  87550. * Returns the current value
  87551. */
  87552. readonly current: number;
  87553. /**
  87554. * Gets the accumulated total
  87555. */
  87556. readonly total: number;
  87557. /**
  87558. * Gets the total value count
  87559. */
  87560. readonly count: number;
  87561. /**
  87562. * Creates a new counter
  87563. */
  87564. constructor();
  87565. /**
  87566. * Call this method to start monitoring a new frame.
  87567. * 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.
  87568. */
  87569. fetchNewFrame(): void;
  87570. /**
  87571. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87572. * @param newCount the count value to add to the monitored count
  87573. * @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.
  87574. */
  87575. addCount(newCount: number, fetchResult: boolean): void;
  87576. /**
  87577. * Start monitoring this performance counter
  87578. */
  87579. beginMonitoring(): void;
  87580. /**
  87581. * Compute the time lapsed since the previous beginMonitoring() call.
  87582. * @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
  87583. */
  87584. endMonitoring(newFrame?: boolean): void;
  87585. private _fetchResult;
  87586. private _startMonitoringTime;
  87587. private _min;
  87588. private _max;
  87589. private _average;
  87590. private _current;
  87591. private _totalValueCount;
  87592. private _totalAccumulated;
  87593. private _lastSecAverage;
  87594. private _lastSecAccumulated;
  87595. private _lastSecTime;
  87596. private _lastSecValueCount;
  87597. }
  87598. /**
  87599. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87600. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87601. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87602. * @param name The name of the class, case should be preserved
  87603. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87604. */
  87605. export function className(name: string, module?: string): (target: Object) => void;
  87606. /**
  87607. * An implementation of a loop for asynchronous functions.
  87608. */
  87609. export class AsyncLoop {
  87610. /**
  87611. * Defines the number of iterations for the loop
  87612. */
  87613. iterations: number;
  87614. /**
  87615. * Defines the current index of the loop.
  87616. */
  87617. index: number;
  87618. private _done;
  87619. private _fn;
  87620. private _successCallback;
  87621. /**
  87622. * Constructor.
  87623. * @param iterations the number of iterations.
  87624. * @param func the function to run each iteration
  87625. * @param successCallback the callback that will be called upon succesful execution
  87626. * @param offset starting offset.
  87627. */
  87628. constructor(
  87629. /**
  87630. * Defines the number of iterations for the loop
  87631. */
  87632. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87633. /**
  87634. * Execute the next iteration. Must be called after the last iteration was finished.
  87635. */
  87636. executeNext(): void;
  87637. /**
  87638. * Break the loop and run the success callback.
  87639. */
  87640. breakLoop(): void;
  87641. /**
  87642. * Create and run an async loop.
  87643. * @param iterations the number of iterations.
  87644. * @param fn the function to run each iteration
  87645. * @param successCallback the callback that will be called upon succesful execution
  87646. * @param offset starting offset.
  87647. * @returns the created async loop object
  87648. */
  87649. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87650. /**
  87651. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87652. * @param iterations total number of iterations
  87653. * @param syncedIterations number of synchronous iterations in each async iteration.
  87654. * @param fn the function to call each iteration.
  87655. * @param callback a success call back that will be called when iterating stops.
  87656. * @param breakFunction a break condition (optional)
  87657. * @param timeout timeout settings for the setTimeout function. default - 0.
  87658. * @returns the created async loop object
  87659. */
  87660. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87661. }
  87662. }
  87663. declare module BABYLON {
  87664. /**
  87665. * This class defines the direct association between an animation and a target
  87666. */
  87667. export class TargetedAnimation {
  87668. /**
  87669. * Animation to perform
  87670. */
  87671. animation: Animation;
  87672. /**
  87673. * Target to animate
  87674. */
  87675. target: any;
  87676. }
  87677. /**
  87678. * Use this class to create coordinated animations on multiple targets
  87679. */
  87680. export class AnimationGroup implements IDisposable {
  87681. /** The name of the animation group */
  87682. name: string;
  87683. private _scene;
  87684. private _targetedAnimations;
  87685. private _animatables;
  87686. private _from;
  87687. private _to;
  87688. private _isStarted;
  87689. private _isPaused;
  87690. private _speedRatio;
  87691. /**
  87692. * Gets or sets the unique id of the node
  87693. */
  87694. uniqueId: number;
  87695. /**
  87696. * This observable will notify when one animation have ended
  87697. */
  87698. onAnimationEndObservable: Observable<TargetedAnimation>;
  87699. /**
  87700. * Observer raised when one animation loops
  87701. */
  87702. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87703. /**
  87704. * This observable will notify when all animations have ended.
  87705. */
  87706. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87707. /**
  87708. * This observable will notify when all animations have paused.
  87709. */
  87710. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87711. /**
  87712. * This observable will notify when all animations are playing.
  87713. */
  87714. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87715. /**
  87716. * Gets the first frame
  87717. */
  87718. readonly from: number;
  87719. /**
  87720. * Gets the last frame
  87721. */
  87722. readonly to: number;
  87723. /**
  87724. * Define if the animations are started
  87725. */
  87726. readonly isStarted: boolean;
  87727. /**
  87728. * Gets a value indicating that the current group is playing
  87729. */
  87730. readonly isPlaying: boolean;
  87731. /**
  87732. * Gets or sets the speed ratio to use for all animations
  87733. */
  87734. /**
  87735. * Gets or sets the speed ratio to use for all animations
  87736. */
  87737. speedRatio: number;
  87738. /**
  87739. * Gets the targeted animations for this animation group
  87740. */
  87741. readonly targetedAnimations: Array<TargetedAnimation>;
  87742. /**
  87743. * returning the list of animatables controlled by this animation group.
  87744. */
  87745. readonly animatables: Array<Animatable>;
  87746. /**
  87747. * Instantiates a new Animation Group.
  87748. * This helps managing several animations at once.
  87749. * @see http://doc.babylonjs.com/how_to/group
  87750. * @param name Defines the name of the group
  87751. * @param scene Defines the scene the group belongs to
  87752. */
  87753. constructor(
  87754. /** The name of the animation group */
  87755. name: string, scene?: Nullable<Scene>);
  87756. /**
  87757. * Add an animation (with its target) in the group
  87758. * @param animation defines the animation we want to add
  87759. * @param target defines the target of the animation
  87760. * @returns the TargetedAnimation object
  87761. */
  87762. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87763. /**
  87764. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87765. * It can add constant keys at begin or end
  87766. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87767. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87768. * @returns the animation group
  87769. */
  87770. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87771. /**
  87772. * Start all animations on given targets
  87773. * @param loop defines if animations must loop
  87774. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87775. * @param from defines the from key (optional)
  87776. * @param to defines the to key (optional)
  87777. * @returns the current animation group
  87778. */
  87779. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87780. /**
  87781. * Pause all animations
  87782. * @returns the animation group
  87783. */
  87784. pause(): AnimationGroup;
  87785. /**
  87786. * Play all animations to initial state
  87787. * This function will start() the animations if they were not started or will restart() them if they were paused
  87788. * @param loop defines if animations must loop
  87789. * @returns the animation group
  87790. */
  87791. play(loop?: boolean): AnimationGroup;
  87792. /**
  87793. * Reset all animations to initial state
  87794. * @returns the animation group
  87795. */
  87796. reset(): AnimationGroup;
  87797. /**
  87798. * Restart animations from key 0
  87799. * @returns the animation group
  87800. */
  87801. restart(): AnimationGroup;
  87802. /**
  87803. * Stop all animations
  87804. * @returns the animation group
  87805. */
  87806. stop(): AnimationGroup;
  87807. /**
  87808. * Set animation weight for all animatables
  87809. * @param weight defines the weight to use
  87810. * @return the animationGroup
  87811. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87812. */
  87813. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87814. /**
  87815. * Synchronize and normalize all animatables with a source animatable
  87816. * @param root defines the root animatable to synchronize with
  87817. * @return the animationGroup
  87818. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87819. */
  87820. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87821. /**
  87822. * Goes to a specific frame in this animation group
  87823. * @param frame the frame number to go to
  87824. * @return the animationGroup
  87825. */
  87826. goToFrame(frame: number): AnimationGroup;
  87827. /**
  87828. * Dispose all associated resources
  87829. */
  87830. dispose(): void;
  87831. private _checkAnimationGroupEnded;
  87832. /**
  87833. * Returns a new AnimationGroup object parsed from the source provided.
  87834. * @param parsedAnimationGroup defines the source
  87835. * @param scene defines the scene that will receive the animationGroup
  87836. * @returns a new AnimationGroup
  87837. */
  87838. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87839. /**
  87840. * Returns the string "AnimationGroup"
  87841. * @returns "AnimationGroup"
  87842. */
  87843. getClassName(): string;
  87844. /**
  87845. * Creates a detailled string about the object
  87846. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87847. * @returns a string representing the object
  87848. */
  87849. toString(fullDetails?: boolean): string;
  87850. }
  87851. }
  87852. declare module BABYLON {
  87853. /** @hidden */
  87854. export interface ICollisionCoordinator {
  87855. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87856. init(scene: Scene): void;
  87857. destroy(): void;
  87858. onMeshAdded(mesh: AbstractMesh): void;
  87859. onMeshUpdated(mesh: AbstractMesh): void;
  87860. onMeshRemoved(mesh: AbstractMesh): void;
  87861. onGeometryAdded(geometry: Geometry): void;
  87862. onGeometryUpdated(geometry: Geometry): void;
  87863. onGeometryDeleted(geometry: Geometry): void;
  87864. }
  87865. /** @hidden */
  87866. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  87867. private _scene;
  87868. private _scaledPosition;
  87869. private _scaledVelocity;
  87870. private _finalPosition;
  87871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87872. init(scene: Scene): void;
  87873. destroy(): void;
  87874. onMeshAdded(mesh: AbstractMesh): void;
  87875. onMeshUpdated(mesh: AbstractMesh): void;
  87876. onMeshRemoved(mesh: AbstractMesh): void;
  87877. onGeometryAdded(geometry: Geometry): void;
  87878. onGeometryUpdated(geometry: Geometry): void;
  87879. onGeometryDeleted(geometry: Geometry): void;
  87880. private _collideWithWorld;
  87881. }
  87882. }
  87883. declare module BABYLON {
  87884. /**
  87885. * Define an interface for all classes that will hold resources
  87886. */
  87887. export interface IDisposable {
  87888. /**
  87889. * Releases all held resources
  87890. */
  87891. dispose(): void;
  87892. }
  87893. /** Interface defining initialization parameters for Scene class */
  87894. export interface SceneOptions {
  87895. /**
  87896. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87897. * It will improve performance when the number of geometries becomes important.
  87898. */
  87899. useGeometryUniqueIdsMap?: boolean;
  87900. /**
  87901. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87902. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87903. */
  87904. useMaterialMeshMap?: boolean;
  87905. /**
  87906. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87907. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87908. */
  87909. useClonedMeshhMap?: boolean;
  87910. }
  87911. /**
  87912. * Represents a scene to be rendered by the engine.
  87913. * @see http://doc.babylonjs.com/features/scene
  87914. */
  87915. export class Scene extends AbstractScene implements IAnimatable {
  87916. private static _uniqueIdCounter;
  87917. /** The fog is deactivated */
  87918. static readonly FOGMODE_NONE: number;
  87919. /** The fog density is following an exponential function */
  87920. static readonly FOGMODE_EXP: number;
  87921. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87922. static readonly FOGMODE_EXP2: number;
  87923. /** The fog density is following a linear function. */
  87924. static readonly FOGMODE_LINEAR: number;
  87925. /**
  87926. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87928. */
  87929. static MinDeltaTime: number;
  87930. /**
  87931. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87933. */
  87934. static MaxDeltaTime: number;
  87935. /**
  87936. * Factory used to create the default material.
  87937. * @param name The name of the material to create
  87938. * @param scene The scene to create the material for
  87939. * @returns The default material
  87940. */
  87941. static DefaultMaterialFactory(scene: Scene): Material;
  87942. /** @hidden */
  87943. readonly _isScene: boolean;
  87944. /**
  87945. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87946. */
  87947. autoClear: boolean;
  87948. /**
  87949. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87950. */
  87951. autoClearDepthAndStencil: boolean;
  87952. /**
  87953. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87954. */
  87955. clearColor: Color4;
  87956. /**
  87957. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87958. */
  87959. ambientColor: Color3;
  87960. /** @hidden */
  87961. _environmentBRDFTexture: BaseTexture;
  87962. /** @hidden */
  87963. protected _environmentTexture: Nullable<BaseTexture>;
  87964. /**
  87965. * Texture used in all pbr material as the reflection texture.
  87966. * As in the majority of the scene they are the same (exception for multi room and so on),
  87967. * this is easier to reference from here than from all the materials.
  87968. */
  87969. /**
  87970. * Texture used in all pbr material as the reflection texture.
  87971. * As in the majority of the scene they are the same (exception for multi room and so on),
  87972. * this is easier to set here than in all the materials.
  87973. */
  87974. environmentTexture: Nullable<BaseTexture>;
  87975. /** @hidden */
  87976. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87977. /**
  87978. * Default image processing configuration used either in the rendering
  87979. * Forward main pass or through the imageProcessingPostProcess if present.
  87980. * As in the majority of the scene they are the same (exception for multi camera),
  87981. * this is easier to reference from here than from all the materials and post process.
  87982. *
  87983. * No setter as we it is a shared configuration, you can set the values instead.
  87984. */
  87985. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87986. private _forceWireframe;
  87987. /**
  87988. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87989. */
  87990. forceWireframe: boolean;
  87991. private _forcePointsCloud;
  87992. /**
  87993. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87994. */
  87995. forcePointsCloud: boolean;
  87996. /**
  87997. * Gets or sets the active clipplane 1
  87998. */
  87999. clipPlane: Nullable<Plane>;
  88000. /**
  88001. * Gets or sets the active clipplane 2
  88002. */
  88003. clipPlane2: Nullable<Plane>;
  88004. /**
  88005. * Gets or sets the active clipplane 3
  88006. */
  88007. clipPlane3: Nullable<Plane>;
  88008. /**
  88009. * Gets or sets the active clipplane 4
  88010. */
  88011. clipPlane4: Nullable<Plane>;
  88012. /**
  88013. * Gets or sets a boolean indicating if animations are enabled
  88014. */
  88015. animationsEnabled: boolean;
  88016. private _animationPropertiesOverride;
  88017. /**
  88018. * Gets or sets the animation properties override
  88019. */
  88020. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88021. /**
  88022. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88023. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88024. */
  88025. useConstantAnimationDeltaTime: boolean;
  88026. /**
  88027. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88028. * Please note that it requires to run a ray cast through the scene on every frame
  88029. */
  88030. constantlyUpdateMeshUnderPointer: boolean;
  88031. /**
  88032. * Defines the HTML cursor to use when hovering over interactive elements
  88033. */
  88034. hoverCursor: string;
  88035. /**
  88036. * Defines the HTML default cursor to use (empty by default)
  88037. */
  88038. defaultCursor: string;
  88039. /**
  88040. * This is used to call preventDefault() on pointer down
  88041. * in order to block unwanted artifacts like system double clicks
  88042. */
  88043. preventDefaultOnPointerDown: boolean;
  88044. /**
  88045. * This is used to call preventDefault() on pointer up
  88046. * in order to block unwanted artifacts like system double clicks
  88047. */
  88048. preventDefaultOnPointerUp: boolean;
  88049. /**
  88050. * Gets or sets user defined metadata
  88051. */
  88052. metadata: any;
  88053. /**
  88054. * For internal use only. Please do not use.
  88055. */
  88056. reservedDataStore: any;
  88057. /**
  88058. * Gets the name of the plugin used to load this scene (null by default)
  88059. */
  88060. loadingPluginName: string;
  88061. /**
  88062. * Use this array to add regular expressions used to disable offline support for specific urls
  88063. */
  88064. disableOfflineSupportExceptionRules: RegExp[];
  88065. /**
  88066. * An event triggered when the scene is disposed.
  88067. */
  88068. onDisposeObservable: Observable<Scene>;
  88069. private _onDisposeObserver;
  88070. /** Sets a function to be executed when this scene is disposed. */
  88071. onDispose: () => void;
  88072. /**
  88073. * An event triggered before rendering the scene (right after animations and physics)
  88074. */
  88075. onBeforeRenderObservable: Observable<Scene>;
  88076. private _onBeforeRenderObserver;
  88077. /** Sets a function to be executed before rendering this scene */
  88078. beforeRender: Nullable<() => void>;
  88079. /**
  88080. * An event triggered after rendering the scene
  88081. */
  88082. onAfterRenderObservable: Observable<Scene>;
  88083. private _onAfterRenderObserver;
  88084. /** Sets a function to be executed after rendering this scene */
  88085. afterRender: Nullable<() => void>;
  88086. /**
  88087. * An event triggered before animating the scene
  88088. */
  88089. onBeforeAnimationsObservable: Observable<Scene>;
  88090. /**
  88091. * An event triggered after animations processing
  88092. */
  88093. onAfterAnimationsObservable: Observable<Scene>;
  88094. /**
  88095. * An event triggered before draw calls are ready to be sent
  88096. */
  88097. onBeforeDrawPhaseObservable: Observable<Scene>;
  88098. /**
  88099. * An event triggered after draw calls have been sent
  88100. */
  88101. onAfterDrawPhaseObservable: Observable<Scene>;
  88102. /**
  88103. * An event triggered when the scene is ready
  88104. */
  88105. onReadyObservable: Observable<Scene>;
  88106. /**
  88107. * An event triggered before rendering a camera
  88108. */
  88109. onBeforeCameraRenderObservable: Observable<Camera>;
  88110. private _onBeforeCameraRenderObserver;
  88111. /** Sets a function to be executed before rendering a camera*/
  88112. beforeCameraRender: () => void;
  88113. /**
  88114. * An event triggered after rendering a camera
  88115. */
  88116. onAfterCameraRenderObservable: Observable<Camera>;
  88117. private _onAfterCameraRenderObserver;
  88118. /** Sets a function to be executed after rendering a camera*/
  88119. afterCameraRender: () => void;
  88120. /**
  88121. * An event triggered when active meshes evaluation is about to start
  88122. */
  88123. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88124. /**
  88125. * An event triggered when active meshes evaluation is done
  88126. */
  88127. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88128. /**
  88129. * An event triggered when particles rendering is about to start
  88130. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88131. */
  88132. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88133. /**
  88134. * An event triggered when particles rendering is done
  88135. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88136. */
  88137. onAfterParticlesRenderingObservable: Observable<Scene>;
  88138. /**
  88139. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88140. */
  88141. onDataLoadedObservable: Observable<Scene>;
  88142. /**
  88143. * An event triggered when a camera is created
  88144. */
  88145. onNewCameraAddedObservable: Observable<Camera>;
  88146. /**
  88147. * An event triggered when a camera is removed
  88148. */
  88149. onCameraRemovedObservable: Observable<Camera>;
  88150. /**
  88151. * An event triggered when a light is created
  88152. */
  88153. onNewLightAddedObservable: Observable<Light>;
  88154. /**
  88155. * An event triggered when a light is removed
  88156. */
  88157. onLightRemovedObservable: Observable<Light>;
  88158. /**
  88159. * An event triggered when a geometry is created
  88160. */
  88161. onNewGeometryAddedObservable: Observable<Geometry>;
  88162. /**
  88163. * An event triggered when a geometry is removed
  88164. */
  88165. onGeometryRemovedObservable: Observable<Geometry>;
  88166. /**
  88167. * An event triggered when a transform node is created
  88168. */
  88169. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88170. /**
  88171. * An event triggered when a transform node is removed
  88172. */
  88173. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88174. /**
  88175. * An event triggered when a mesh is created
  88176. */
  88177. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88178. /**
  88179. * An event triggered when a mesh is removed
  88180. */
  88181. onMeshRemovedObservable: Observable<AbstractMesh>;
  88182. /**
  88183. * An event triggered when a material is created
  88184. */
  88185. onNewMaterialAddedObservable: Observable<Material>;
  88186. /**
  88187. * An event triggered when a material is removed
  88188. */
  88189. onMaterialRemovedObservable: Observable<Material>;
  88190. /**
  88191. * An event triggered when a texture is created
  88192. */
  88193. onNewTextureAddedObservable: Observable<BaseTexture>;
  88194. /**
  88195. * An event triggered when a texture is removed
  88196. */
  88197. onTextureRemovedObservable: Observable<BaseTexture>;
  88198. /**
  88199. * An event triggered when render targets are about to be rendered
  88200. * Can happen multiple times per frame.
  88201. */
  88202. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88203. /**
  88204. * An event triggered when render targets were rendered.
  88205. * Can happen multiple times per frame.
  88206. */
  88207. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88208. /**
  88209. * An event triggered before calculating deterministic simulation step
  88210. */
  88211. onBeforeStepObservable: Observable<Scene>;
  88212. /**
  88213. * An event triggered after calculating deterministic simulation step
  88214. */
  88215. onAfterStepObservable: Observable<Scene>;
  88216. /**
  88217. * An event triggered when the activeCamera property is updated
  88218. */
  88219. onActiveCameraChanged: Observable<Scene>;
  88220. /**
  88221. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88222. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88223. * 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)
  88224. */
  88225. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88226. /**
  88227. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88228. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88229. * 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)
  88230. */
  88231. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88232. /**
  88233. * This Observable will when a mesh has been imported into the scene.
  88234. */
  88235. onMeshImportedObservable: Observable<AbstractMesh>;
  88236. private _registeredForLateAnimationBindings;
  88237. /**
  88238. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88239. */
  88240. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88241. /**
  88242. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88243. */
  88244. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88245. /**
  88246. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88247. */
  88248. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88249. private _onPointerMove;
  88250. private _onPointerDown;
  88251. private _onPointerUp;
  88252. /** Callback called when a pointer move is detected */
  88253. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88254. /** Callback called when a pointer down is detected */
  88255. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88256. /** Callback called when a pointer up is detected */
  88257. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88258. /** Callback called when a pointer pick is detected */
  88259. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88260. /**
  88261. * 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).
  88262. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88263. */
  88264. onPrePointerObservable: Observable<PointerInfoPre>;
  88265. /**
  88266. * Observable event triggered each time an input event is received from the rendering canvas
  88267. */
  88268. onPointerObservable: Observable<PointerInfo>;
  88269. /**
  88270. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88271. */
  88272. readonly unTranslatedPointer: Vector2;
  88273. /** The distance in pixel that you have to move to prevent some events */
  88274. static DragMovementThreshold: number;
  88275. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88276. static LongPressDelay: number;
  88277. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88278. static DoubleClickDelay: number;
  88279. /** If you need to check double click without raising a single click at first click, enable this flag */
  88280. static ExclusiveDoubleClickMode: boolean;
  88281. private _initClickEvent;
  88282. private _initActionManager;
  88283. private _delayedSimpleClick;
  88284. private _delayedSimpleClickTimeout;
  88285. private _previousDelayedSimpleClickTimeout;
  88286. private _meshPickProceed;
  88287. private _previousButtonPressed;
  88288. private _currentPickResult;
  88289. private _previousPickResult;
  88290. private _totalPointersPressed;
  88291. private _doubleClickOccured;
  88292. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88293. cameraToUseForPointers: Nullable<Camera>;
  88294. private _pointerX;
  88295. private _pointerY;
  88296. private _unTranslatedPointerX;
  88297. private _unTranslatedPointerY;
  88298. private _startingPointerPosition;
  88299. private _previousStartingPointerPosition;
  88300. private _startingPointerTime;
  88301. private _previousStartingPointerTime;
  88302. private _pointerCaptures;
  88303. private _timeAccumulator;
  88304. private _currentStepId;
  88305. private _currentInternalStep;
  88306. /** @hidden */
  88307. _mirroredCameraPosition: Nullable<Vector3>;
  88308. /**
  88309. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88310. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88311. */
  88312. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88313. /**
  88314. * Observable event triggered each time an keyboard event is received from the hosting window
  88315. */
  88316. onKeyboardObservable: Observable<KeyboardInfo>;
  88317. private _onKeyDown;
  88318. private _onKeyUp;
  88319. private _onCanvasFocusObserver;
  88320. private _onCanvasBlurObserver;
  88321. private _useRightHandedSystem;
  88322. /**
  88323. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88324. */
  88325. useRightHandedSystem: boolean;
  88326. /**
  88327. * Sets the step Id used by deterministic lock step
  88328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88329. * @param newStepId defines the step Id
  88330. */
  88331. setStepId(newStepId: number): void;
  88332. /**
  88333. * Gets the step Id used by deterministic lock step
  88334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88335. * @returns the step Id
  88336. */
  88337. getStepId(): number;
  88338. /**
  88339. * Gets the internal step used by deterministic lock step
  88340. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88341. * @returns the internal step
  88342. */
  88343. getInternalStep(): number;
  88344. private _fogEnabled;
  88345. /**
  88346. * Gets or sets a boolean indicating if fog is enabled on this scene
  88347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88348. * (Default is true)
  88349. */
  88350. fogEnabled: boolean;
  88351. private _fogMode;
  88352. /**
  88353. * Gets or sets the fog mode to use
  88354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88355. * | mode | value |
  88356. * | --- | --- |
  88357. * | FOGMODE_NONE | 0 |
  88358. * | FOGMODE_EXP | 1 |
  88359. * | FOGMODE_EXP2 | 2 |
  88360. * | FOGMODE_LINEAR | 3 |
  88361. */
  88362. fogMode: number;
  88363. /**
  88364. * Gets or sets the fog color to use
  88365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88366. * (Default is Color3(0.2, 0.2, 0.3))
  88367. */
  88368. fogColor: Color3;
  88369. /**
  88370. * Gets or sets the fog density to use
  88371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88372. * (Default is 0.1)
  88373. */
  88374. fogDensity: number;
  88375. /**
  88376. * Gets or sets the fog start distance to use
  88377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88378. * (Default is 0)
  88379. */
  88380. fogStart: number;
  88381. /**
  88382. * Gets or sets the fog end distance to use
  88383. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88384. * (Default is 1000)
  88385. */
  88386. fogEnd: number;
  88387. private _shadowsEnabled;
  88388. /**
  88389. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88390. */
  88391. shadowsEnabled: boolean;
  88392. private _lightsEnabled;
  88393. /**
  88394. * Gets or sets a boolean indicating if lights are enabled on this scene
  88395. */
  88396. lightsEnabled: boolean;
  88397. /** All of the active cameras added to this scene. */
  88398. activeCameras: Camera[];
  88399. private _activeCamera;
  88400. /** Gets or sets the current active camera */
  88401. activeCamera: Nullable<Camera>;
  88402. private _defaultMaterial;
  88403. /** The default material used on meshes when no material is affected */
  88404. /** The default material used on meshes when no material is affected */
  88405. defaultMaterial: Material;
  88406. private _texturesEnabled;
  88407. /**
  88408. * Gets or sets a boolean indicating if textures are enabled on this scene
  88409. */
  88410. texturesEnabled: boolean;
  88411. /**
  88412. * Gets or sets a boolean indicating if particles are enabled on this scene
  88413. */
  88414. particlesEnabled: boolean;
  88415. /**
  88416. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88417. */
  88418. spritesEnabled: boolean;
  88419. private _skeletonsEnabled;
  88420. /**
  88421. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88422. */
  88423. skeletonsEnabled: boolean;
  88424. /**
  88425. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88426. */
  88427. lensFlaresEnabled: boolean;
  88428. /**
  88429. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88431. */
  88432. collisionsEnabled: boolean;
  88433. /** @hidden */
  88434. collisionCoordinator: ICollisionCoordinator;
  88435. /**
  88436. * Defines the gravity applied to this scene (used only for collisions)
  88437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88438. */
  88439. gravity: Vector3;
  88440. /**
  88441. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88442. */
  88443. postProcessesEnabled: boolean;
  88444. /**
  88445. * The list of postprocesses added to the scene
  88446. */
  88447. postProcesses: PostProcess[];
  88448. /**
  88449. * Gets the current postprocess manager
  88450. */
  88451. postProcessManager: PostProcessManager;
  88452. /**
  88453. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88454. */
  88455. renderTargetsEnabled: boolean;
  88456. /**
  88457. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88458. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88459. */
  88460. dumpNextRenderTargets: boolean;
  88461. /**
  88462. * The list of user defined render targets added to the scene
  88463. */
  88464. customRenderTargets: RenderTargetTexture[];
  88465. /**
  88466. * Defines if texture loading must be delayed
  88467. * If true, textures will only be loaded when they need to be rendered
  88468. */
  88469. useDelayedTextureLoading: boolean;
  88470. /**
  88471. * Gets the list of meshes imported to the scene through SceneLoader
  88472. */
  88473. importedMeshesFiles: String[];
  88474. /**
  88475. * Gets or sets a boolean indicating if probes are enabled on this scene
  88476. */
  88477. probesEnabled: boolean;
  88478. /**
  88479. * Gets or sets the current offline provider to use to store scene data
  88480. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88481. */
  88482. offlineProvider: IOfflineProvider;
  88483. /**
  88484. * Gets or sets the action manager associated with the scene
  88485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88486. */
  88487. actionManager: ActionManager;
  88488. private _meshesForIntersections;
  88489. /**
  88490. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88491. */
  88492. proceduralTexturesEnabled: boolean;
  88493. private _engine;
  88494. private _totalVertices;
  88495. /** @hidden */
  88496. _activeIndices: PerfCounter;
  88497. /** @hidden */
  88498. _activeParticles: PerfCounter;
  88499. /** @hidden */
  88500. _activeBones: PerfCounter;
  88501. private _animationRatio;
  88502. private _animationTimeLast;
  88503. private _animationTime;
  88504. /**
  88505. * Gets or sets a general scale for animation speed
  88506. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88507. */
  88508. animationTimeScale: number;
  88509. /** @hidden */
  88510. _cachedMaterial: Nullable<Material>;
  88511. /** @hidden */
  88512. _cachedEffect: Nullable<Effect>;
  88513. /** @hidden */
  88514. _cachedVisibility: Nullable<number>;
  88515. private _renderId;
  88516. private _frameId;
  88517. private _executeWhenReadyTimeoutId;
  88518. private _intermediateRendering;
  88519. private _viewUpdateFlag;
  88520. private _projectionUpdateFlag;
  88521. private _alternateViewUpdateFlag;
  88522. private _alternateProjectionUpdateFlag;
  88523. /** @hidden */
  88524. _toBeDisposed: Nullable<IDisposable>[];
  88525. private _activeRequests;
  88526. private _pendingData;
  88527. private _isDisposed;
  88528. /**
  88529. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88530. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88531. */
  88532. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88533. private _activeMeshes;
  88534. private _processedMaterials;
  88535. private _renderTargets;
  88536. /** @hidden */
  88537. _activeParticleSystems: SmartArray<IParticleSystem>;
  88538. private _activeSkeletons;
  88539. private _softwareSkinnedMeshes;
  88540. private _renderingManager;
  88541. /** @hidden */
  88542. _activeAnimatables: Animatable[];
  88543. private _transformMatrix;
  88544. private _sceneUbo;
  88545. private _alternateSceneUbo;
  88546. private _pickWithRayInverseMatrix;
  88547. private _viewMatrix;
  88548. private _projectionMatrix;
  88549. private _alternateViewMatrix;
  88550. private _alternateProjectionMatrix;
  88551. private _alternateTransformMatrix;
  88552. private _useAlternateCameraConfiguration;
  88553. private _alternateRendering;
  88554. private _wheelEventName;
  88555. /** @hidden */
  88556. _forcedViewPosition: Nullable<Vector3>;
  88557. /** @hidden */
  88558. readonly _isAlternateRenderingEnabled: boolean;
  88559. private _frustumPlanes;
  88560. /**
  88561. * Gets the list of frustum planes (built from the active camera)
  88562. */
  88563. readonly frustumPlanes: Plane[];
  88564. /**
  88565. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88566. * This is useful if there are more lights that the maximum simulteanous authorized
  88567. */
  88568. requireLightSorting: boolean;
  88569. /** @hidden */
  88570. readonly useMaterialMeshMap: boolean;
  88571. /** @hidden */
  88572. readonly useClonedMeshhMap: boolean;
  88573. private _pointerOverMesh;
  88574. private _pickedDownMesh;
  88575. private _pickedUpMesh;
  88576. private _externalData;
  88577. private _uid;
  88578. /**
  88579. * @hidden
  88580. * Backing store of defined scene components.
  88581. */
  88582. _components: ISceneComponent[];
  88583. /**
  88584. * @hidden
  88585. * Backing store of defined scene components.
  88586. */
  88587. _serializableComponents: ISceneSerializableComponent[];
  88588. /**
  88589. * List of components to register on the next registration step.
  88590. */
  88591. private _transientComponents;
  88592. /**
  88593. * Registers the transient components if needed.
  88594. */
  88595. private _registerTransientComponents;
  88596. /**
  88597. * @hidden
  88598. * Add a component to the scene.
  88599. * Note that the ccomponent could be registered on th next frame if this is called after
  88600. * the register component stage.
  88601. * @param component Defines the component to add to the scene
  88602. */
  88603. _addComponent(component: ISceneComponent): void;
  88604. /**
  88605. * @hidden
  88606. * Gets a component from the scene.
  88607. * @param name defines the name of the component to retrieve
  88608. * @returns the component or null if not present
  88609. */
  88610. _getComponent(name: string): Nullable<ISceneComponent>;
  88611. /**
  88612. * @hidden
  88613. * Defines the actions happening before camera updates.
  88614. */
  88615. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88616. /**
  88617. * @hidden
  88618. * Defines the actions happening before clear the canvas.
  88619. */
  88620. _beforeClearStage: Stage<SimpleStageAction>;
  88621. /**
  88622. * @hidden
  88623. * Defines the actions when collecting render targets for the frame.
  88624. */
  88625. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88626. /**
  88627. * @hidden
  88628. * Defines the actions happening for one camera in the frame.
  88629. */
  88630. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88631. /**
  88632. * @hidden
  88633. * Defines the actions happening during the per mesh ready checks.
  88634. */
  88635. _isReadyForMeshStage: Stage<MeshStageAction>;
  88636. /**
  88637. * @hidden
  88638. * Defines the actions happening before evaluate active mesh checks.
  88639. */
  88640. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88641. /**
  88642. * @hidden
  88643. * Defines the actions happening during the evaluate sub mesh checks.
  88644. */
  88645. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88646. /**
  88647. * @hidden
  88648. * Defines the actions happening during the active mesh stage.
  88649. */
  88650. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88651. /**
  88652. * @hidden
  88653. * Defines the actions happening during the per camera render target step.
  88654. */
  88655. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88656. /**
  88657. * @hidden
  88658. * Defines the actions happening just before the active camera is drawing.
  88659. */
  88660. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88661. /**
  88662. * @hidden
  88663. * Defines the actions happening just before a render target is drawing.
  88664. */
  88665. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88666. /**
  88667. * @hidden
  88668. * Defines the actions happening just before a rendering group is drawing.
  88669. */
  88670. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88671. /**
  88672. * @hidden
  88673. * Defines the actions happening just before a mesh is drawing.
  88674. */
  88675. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88676. /**
  88677. * @hidden
  88678. * Defines the actions happening just after a mesh has been drawn.
  88679. */
  88680. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88681. /**
  88682. * @hidden
  88683. * Defines the actions happening just after a rendering group has been drawn.
  88684. */
  88685. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88686. /**
  88687. * @hidden
  88688. * Defines the actions happening just after the active camera has been drawn.
  88689. */
  88690. _afterCameraDrawStage: Stage<CameraStageAction>;
  88691. /**
  88692. * @hidden
  88693. * Defines the actions happening just after a render target has been drawn.
  88694. */
  88695. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88696. /**
  88697. * @hidden
  88698. * Defines the actions happening just after rendering all cameras and computing intersections.
  88699. */
  88700. _afterRenderStage: Stage<SimpleStageAction>;
  88701. /**
  88702. * @hidden
  88703. * Defines the actions happening when a pointer move event happens.
  88704. */
  88705. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88706. /**
  88707. * @hidden
  88708. * Defines the actions happening when a pointer down event happens.
  88709. */
  88710. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88711. /**
  88712. * @hidden
  88713. * Defines the actions happening when a pointer up event happens.
  88714. */
  88715. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88716. /**
  88717. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88718. */
  88719. private geometriesByUniqueId;
  88720. /**
  88721. * Creates a new Scene
  88722. * @param engine defines the engine to use to render this scene
  88723. */
  88724. constructor(engine: Engine, options?: SceneOptions);
  88725. private _defaultMeshCandidates;
  88726. /**
  88727. * @hidden
  88728. */
  88729. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88730. private _defaultSubMeshCandidates;
  88731. /**
  88732. * @hidden
  88733. */
  88734. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88735. /**
  88736. * Sets the default candidate providers for the scene.
  88737. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88738. * and getCollidingSubMeshCandidates to their default function
  88739. */
  88740. setDefaultCandidateProviders(): void;
  88741. /**
  88742. * Gets a boolean indicating if collisions are processed on a web worker
  88743. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  88744. */
  88745. workerCollisions: boolean;
  88746. /**
  88747. * Gets the mesh that is currently under the pointer
  88748. */
  88749. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88750. /**
  88751. * Gets or sets the current on-screen X position of the pointer
  88752. */
  88753. pointerX: number;
  88754. /**
  88755. * Gets or sets the current on-screen Y position of the pointer
  88756. */
  88757. pointerY: number;
  88758. /**
  88759. * Gets the cached material (ie. the latest rendered one)
  88760. * @returns the cached material
  88761. */
  88762. getCachedMaterial(): Nullable<Material>;
  88763. /**
  88764. * Gets the cached effect (ie. the latest rendered one)
  88765. * @returns the cached effect
  88766. */
  88767. getCachedEffect(): Nullable<Effect>;
  88768. /**
  88769. * Gets the cached visibility state (ie. the latest rendered one)
  88770. * @returns the cached visibility state
  88771. */
  88772. getCachedVisibility(): Nullable<number>;
  88773. /**
  88774. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88775. * @param material defines the current material
  88776. * @param effect defines the current effect
  88777. * @param visibility defines the current visibility state
  88778. * @returns true if one parameter is not cached
  88779. */
  88780. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88781. /**
  88782. * Gets the engine associated with the scene
  88783. * @returns an Engine
  88784. */
  88785. getEngine(): Engine;
  88786. /**
  88787. * Gets the total number of vertices rendered per frame
  88788. * @returns the total number of vertices rendered per frame
  88789. */
  88790. getTotalVertices(): number;
  88791. /**
  88792. * Gets the performance counter for total vertices
  88793. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88794. */
  88795. readonly totalVerticesPerfCounter: PerfCounter;
  88796. /**
  88797. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88798. * @returns the total number of active indices rendered per frame
  88799. */
  88800. getActiveIndices(): number;
  88801. /**
  88802. * Gets the performance counter for active indices
  88803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88804. */
  88805. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88806. /**
  88807. * Gets the total number of active particles rendered per frame
  88808. * @returns the total number of active particles rendered per frame
  88809. */
  88810. getActiveParticles(): number;
  88811. /**
  88812. * Gets the performance counter for active particles
  88813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88814. */
  88815. readonly activeParticlesPerfCounter: PerfCounter;
  88816. /**
  88817. * Gets the total number of active bones rendered per frame
  88818. * @returns the total number of active bones rendered per frame
  88819. */
  88820. getActiveBones(): number;
  88821. /**
  88822. * Gets the performance counter for active bones
  88823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88824. */
  88825. readonly activeBonesPerfCounter: PerfCounter;
  88826. /**
  88827. * Gets the array of active meshes
  88828. * @returns an array of AbstractMesh
  88829. */
  88830. getActiveMeshes(): SmartArray<AbstractMesh>;
  88831. /**
  88832. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88833. * @returns a number
  88834. */
  88835. getAnimationRatio(): number;
  88836. /**
  88837. * Gets an unique Id for the current render phase
  88838. * @returns a number
  88839. */
  88840. getRenderId(): number;
  88841. /**
  88842. * Gets an unique Id for the current frame
  88843. * @returns a number
  88844. */
  88845. getFrameId(): number;
  88846. /** Call this function if you want to manually increment the render Id*/
  88847. incrementRenderId(): void;
  88848. private _updatePointerPosition;
  88849. private _createUbo;
  88850. private _createAlternateUbo;
  88851. private _setRayOnPointerInfo;
  88852. /**
  88853. * Use this method to simulate a pointer move on a mesh
  88854. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88855. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88856. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88857. * @returns the current scene
  88858. */
  88859. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88860. private _processPointerMove;
  88861. private _checkPrePointerObservable;
  88862. /**
  88863. * Use this method to simulate a pointer down on a mesh
  88864. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88865. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88866. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88867. * @returns the current scene
  88868. */
  88869. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88870. private _processPointerDown;
  88871. /**
  88872. * Use this method to simulate a pointer up on a mesh
  88873. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88874. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88875. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88876. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88877. * @returns the current scene
  88878. */
  88879. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88880. private _processPointerUp;
  88881. /**
  88882. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88883. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88884. * @returns true if the pointer was captured
  88885. */
  88886. isPointerCaptured(pointerId?: number): boolean;
  88887. /** @hidden */
  88888. _isPointerSwiping(): boolean;
  88889. /**
  88890. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88891. * @param attachUp defines if you want to attach events to pointerup
  88892. * @param attachDown defines if you want to attach events to pointerdown
  88893. * @param attachMove defines if you want to attach events to pointermove
  88894. */
  88895. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88896. /** Detaches all event handlers*/
  88897. detachControl(): void;
  88898. /**
  88899. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88900. * Delay loaded resources are not taking in account
  88901. * @return true if all required resources are ready
  88902. */
  88903. isReady(): boolean;
  88904. /** Resets all cached information relative to material (including effect and visibility) */
  88905. resetCachedMaterial(): void;
  88906. /**
  88907. * Registers a function to be called before every frame render
  88908. * @param func defines the function to register
  88909. */
  88910. registerBeforeRender(func: () => void): void;
  88911. /**
  88912. * Unregisters a function called before every frame render
  88913. * @param func defines the function to unregister
  88914. */
  88915. unregisterBeforeRender(func: () => void): void;
  88916. /**
  88917. * Registers a function to be called after every frame render
  88918. * @param func defines the function to register
  88919. */
  88920. registerAfterRender(func: () => void): void;
  88921. /**
  88922. * Unregisters a function called after every frame render
  88923. * @param func defines the function to unregister
  88924. */
  88925. unregisterAfterRender(func: () => void): void;
  88926. private _executeOnceBeforeRender;
  88927. /**
  88928. * The provided function will run before render once and will be disposed afterwards.
  88929. * A timeout delay can be provided so that the function will be executed in N ms.
  88930. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88931. * @param func The function to be executed.
  88932. * @param timeout optional delay in ms
  88933. */
  88934. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88935. /** @hidden */
  88936. _addPendingData(data: any): void;
  88937. /** @hidden */
  88938. _removePendingData(data: any): void;
  88939. /**
  88940. * Returns the number of items waiting to be loaded
  88941. * @returns the number of items waiting to be loaded
  88942. */
  88943. getWaitingItemsCount(): number;
  88944. /**
  88945. * Returns a boolean indicating if the scene is still loading data
  88946. */
  88947. readonly isLoading: boolean;
  88948. /**
  88949. * Registers a function to be executed when the scene is ready
  88950. * @param {Function} func - the function to be executed
  88951. */
  88952. executeWhenReady(func: () => void): void;
  88953. /**
  88954. * Returns a promise that resolves when the scene is ready
  88955. * @returns A promise that resolves when the scene is ready
  88956. */
  88957. whenReadyAsync(): Promise<void>;
  88958. /** @hidden */
  88959. _checkIsReady(): void;
  88960. /**
  88961. * Will start the animation sequence of a given target
  88962. * @param target defines the target
  88963. * @param from defines from which frame should animation start
  88964. * @param to defines until which frame should animation run.
  88965. * @param weight defines the weight to apply to the animation (1.0 by default)
  88966. * @param loop defines if the animation loops
  88967. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88968. * @param onAnimationEnd defines the function to be executed when the animation ends
  88969. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88970. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88971. * @param onAnimationLoop defines the callback to call when an animation loops
  88972. * @returns the animatable object created for this animation
  88973. */
  88974. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88975. /**
  88976. * Will start the animation sequence of a given target
  88977. * @param target defines the target
  88978. * @param from defines from which frame should animation start
  88979. * @param to defines until which frame should animation run.
  88980. * @param loop defines if the animation loops
  88981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88982. * @param onAnimationEnd defines the function to be executed when the animation ends
  88983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88985. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88986. * @param onAnimationLoop defines the callback to call when an animation loops
  88987. * @returns the animatable object created for this animation
  88988. */
  88989. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88990. /**
  88991. * Will start the animation sequence of a given target and its hierarchy
  88992. * @param target defines the target
  88993. * @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.
  88994. * @param from defines from which frame should animation start
  88995. * @param to defines until which frame should animation run.
  88996. * @param loop defines if the animation loops
  88997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88998. * @param onAnimationEnd defines the function to be executed when the animation ends
  88999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89000. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89001. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89002. * @param onAnimationLoop defines the callback to call when an animation loops
  89003. * @returns the list of created animatables
  89004. */
  89005. 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[];
  89006. /**
  89007. * Begin a new animation on a given node
  89008. * @param target defines the target where the animation will take place
  89009. * @param animations defines the list of animations to start
  89010. * @param from defines the initial value
  89011. * @param to defines the final value
  89012. * @param loop defines if you want animation to loop (off by default)
  89013. * @param speedRatio defines the speed ratio to apply to all animations
  89014. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89015. * @param onAnimationLoop defines the callback to call when an animation loops
  89016. * @returns the list of created animatables
  89017. */
  89018. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  89019. /**
  89020. * Begin a new animation on a given node and its hierarchy
  89021. * @param target defines the root node where the animation will take place
  89022. * @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.
  89023. * @param animations defines the list of animations to start
  89024. * @param from defines the initial value
  89025. * @param to defines the final value
  89026. * @param loop defines if you want animation to loop (off by default)
  89027. * @param speedRatio defines the speed ratio to apply to all animations
  89028. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89029. * @param onAnimationLoop defines the callback to call when an animation loops
  89030. * @returns the list of animatables created for all nodes
  89031. */
  89032. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  89033. /**
  89034. * Gets the animatable associated with a specific target
  89035. * @param target defines the target of the animatable
  89036. * @returns the required animatable if found
  89037. */
  89038. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89039. /**
  89040. * Gets all animatables associated with a given target
  89041. * @param target defines the target to look animatables for
  89042. * @returns an array of Animatables
  89043. */
  89044. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89045. /**
  89046. * Gets all animatable attached to the scene
  89047. */
  89048. readonly animatables: Animatable[];
  89049. /**
  89050. * Will stop the animation of the given target
  89051. * @param target - the target
  89052. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  89053. * @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)
  89054. */
  89055. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  89056. /**
  89057. * Stops and removes all animations that have been applied to the scene
  89058. */
  89059. stopAllAnimations(): void;
  89060. /**
  89061. * Resets the last animation time frame.
  89062. * Useful to override when animations start running when loading a scene for the first time.
  89063. */
  89064. resetLastAnimationTimeFrame(): void;
  89065. private _animate;
  89066. /** @hidden */
  89067. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89068. private _processLateAnimationBindingsForMatrices;
  89069. private _processLateAnimationBindingsForQuaternions;
  89070. private _processLateAnimationBindings;
  89071. /** @hidden */
  89072. _switchToAlternateCameraConfiguration(active: boolean): void;
  89073. /**
  89074. * Gets the current view matrix
  89075. * @returns a Matrix
  89076. */
  89077. getViewMatrix(): Matrix;
  89078. /**
  89079. * Gets the current projection matrix
  89080. * @returns a Matrix
  89081. */
  89082. getProjectionMatrix(): Matrix;
  89083. /**
  89084. * Gets the current transform matrix
  89085. * @returns a Matrix made of View * Projection
  89086. */
  89087. getTransformMatrix(): Matrix;
  89088. /**
  89089. * Sets the current transform matrix
  89090. * @param view defines the View matrix to use
  89091. * @param projection defines the Projection matrix to use
  89092. */
  89093. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89094. /** @hidden */
  89095. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89096. /**
  89097. * Gets the uniform buffer used to store scene data
  89098. * @returns a UniformBuffer
  89099. */
  89100. getSceneUniformBuffer(): UniformBuffer;
  89101. /**
  89102. * Gets an unique (relatively to the current scene) Id
  89103. * @returns an unique number for the scene
  89104. */
  89105. getUniqueId(): number;
  89106. /**
  89107. * Add a mesh to the list of scene's meshes
  89108. * @param newMesh defines the mesh to add
  89109. * @param recursive if all child meshes should also be added to the scene
  89110. */
  89111. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89112. /**
  89113. * Remove a mesh for the list of scene's meshes
  89114. * @param toRemove defines the mesh to remove
  89115. * @param recursive if all child meshes should also be removed from the scene
  89116. * @returns the index where the mesh was in the mesh list
  89117. */
  89118. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89119. /**
  89120. * Add a transform node to the list of scene's transform nodes
  89121. * @param newTransformNode defines the transform node to add
  89122. */
  89123. addTransformNode(newTransformNode: TransformNode): void;
  89124. /**
  89125. * Remove a transform node for the list of scene's transform nodes
  89126. * @param toRemove defines the transform node to remove
  89127. * @returns the index where the transform node was in the transform node list
  89128. */
  89129. removeTransformNode(toRemove: TransformNode): number;
  89130. /**
  89131. * Remove a skeleton for the list of scene's skeletons
  89132. * @param toRemove defines the skeleton to remove
  89133. * @returns the index where the skeleton was in the skeleton list
  89134. */
  89135. removeSkeleton(toRemove: Skeleton): number;
  89136. /**
  89137. * Remove a morph target for the list of scene's morph targets
  89138. * @param toRemove defines the morph target to remove
  89139. * @returns the index where the morph target was in the morph target list
  89140. */
  89141. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89142. /**
  89143. * Remove a light for the list of scene's lights
  89144. * @param toRemove defines the light to remove
  89145. * @returns the index where the light was in the light list
  89146. */
  89147. removeLight(toRemove: Light): number;
  89148. /**
  89149. * Remove a camera for the list of scene's cameras
  89150. * @param toRemove defines the camera to remove
  89151. * @returns the index where the camera was in the camera list
  89152. */
  89153. removeCamera(toRemove: Camera): number;
  89154. /**
  89155. * Remove a particle system for the list of scene's particle systems
  89156. * @param toRemove defines the particle system to remove
  89157. * @returns the index where the particle system was in the particle system list
  89158. */
  89159. removeParticleSystem(toRemove: IParticleSystem): number;
  89160. /**
  89161. * Remove a animation for the list of scene's animations
  89162. * @param toRemove defines the animation to remove
  89163. * @returns the index where the animation was in the animation list
  89164. */
  89165. removeAnimation(toRemove: Animation): number;
  89166. /**
  89167. * Removes the given animation group from this scene.
  89168. * @param toRemove The animation group to remove
  89169. * @returns The index of the removed animation group
  89170. */
  89171. removeAnimationGroup(toRemove: AnimationGroup): number;
  89172. /**
  89173. * Removes the given multi-material from this scene.
  89174. * @param toRemove The multi-material to remove
  89175. * @returns The index of the removed multi-material
  89176. */
  89177. removeMultiMaterial(toRemove: MultiMaterial): number;
  89178. /**
  89179. * Removes the given material from this scene.
  89180. * @param toRemove The material to remove
  89181. * @returns The index of the removed material
  89182. */
  89183. removeMaterial(toRemove: Material): number;
  89184. /**
  89185. * Removes the given action manager from this scene.
  89186. * @param toRemove The action manager to remove
  89187. * @returns The index of the removed action manager
  89188. */
  89189. removeActionManager(toRemove: ActionManager): number;
  89190. /**
  89191. * Removes the given texture from this scene.
  89192. * @param toRemove The texture to remove
  89193. * @returns The index of the removed texture
  89194. */
  89195. removeTexture(toRemove: BaseTexture): number;
  89196. /**
  89197. * Adds the given light to this scene
  89198. * @param newLight The light to add
  89199. */
  89200. addLight(newLight: Light): void;
  89201. /**
  89202. * Sorts the list list based on light priorities
  89203. */
  89204. sortLightsByPriority(): void;
  89205. /**
  89206. * Adds the given camera to this scene
  89207. * @param newCamera The camera to add
  89208. */
  89209. addCamera(newCamera: Camera): void;
  89210. /**
  89211. * Adds the given skeleton to this scene
  89212. * @param newSkeleton The skeleton to add
  89213. */
  89214. addSkeleton(newSkeleton: Skeleton): void;
  89215. /**
  89216. * Adds the given particle system to this scene
  89217. * @param newParticleSystem The particle system to add
  89218. */
  89219. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89220. /**
  89221. * Adds the given animation to this scene
  89222. * @param newAnimation The animation to add
  89223. */
  89224. addAnimation(newAnimation: Animation): void;
  89225. /**
  89226. * Adds the given animation group to this scene.
  89227. * @param newAnimationGroup The animation group to add
  89228. */
  89229. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89230. /**
  89231. * Adds the given multi-material to this scene
  89232. * @param newMultiMaterial The multi-material to add
  89233. */
  89234. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89235. /**
  89236. * Adds the given material to this scene
  89237. * @param newMaterial The material to add
  89238. */
  89239. addMaterial(newMaterial: Material): void;
  89240. /**
  89241. * Adds the given morph target to this scene
  89242. * @param newMorphTargetManager The morph target to add
  89243. */
  89244. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89245. /**
  89246. * Adds the given geometry to this scene
  89247. * @param newGeometry The geometry to add
  89248. */
  89249. addGeometry(newGeometry: Geometry): void;
  89250. /**
  89251. * Adds the given action manager to this scene
  89252. * @param newActionManager The action manager to add
  89253. */
  89254. addActionManager(newActionManager: ActionManager): void;
  89255. /**
  89256. * Adds the given texture to this scene.
  89257. * @param newTexture The texture to add
  89258. */
  89259. addTexture(newTexture: BaseTexture): void;
  89260. /**
  89261. * Switch active camera
  89262. * @param newCamera defines the new active camera
  89263. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89264. */
  89265. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89266. /**
  89267. * sets the active camera of the scene using its ID
  89268. * @param id defines the camera's ID
  89269. * @return the new active camera or null if none found.
  89270. */
  89271. setActiveCameraByID(id: string): Nullable<Camera>;
  89272. /**
  89273. * sets the active camera of the scene using its name
  89274. * @param name defines the camera's name
  89275. * @returns the new active camera or null if none found.
  89276. */
  89277. setActiveCameraByName(name: string): Nullable<Camera>;
  89278. /**
  89279. * get an animation group using its name
  89280. * @param name defines the material's name
  89281. * @return the animation group or null if none found.
  89282. */
  89283. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89284. /**
  89285. * get a material using its id
  89286. * @param id defines the material's ID
  89287. * @return the material or null if none found.
  89288. */
  89289. getMaterialByID(id: string): Nullable<Material>;
  89290. /**
  89291. * Gets a material using its name
  89292. * @param name defines the material's name
  89293. * @return the material or null if none found.
  89294. */
  89295. getMaterialByName(name: string): Nullable<Material>;
  89296. /**
  89297. * Gets a camera using its id
  89298. * @param id defines the id to look for
  89299. * @returns the camera or null if not found
  89300. */
  89301. getCameraByID(id: string): Nullable<Camera>;
  89302. /**
  89303. * Gets a camera using its unique id
  89304. * @param uniqueId defines the unique id to look for
  89305. * @returns the camera or null if not found
  89306. */
  89307. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89308. /**
  89309. * Gets a camera using its name
  89310. * @param name defines the camera's name
  89311. * @return the camera or null if none found.
  89312. */
  89313. getCameraByName(name: string): Nullable<Camera>;
  89314. /**
  89315. * Gets a bone using its id
  89316. * @param id defines the bone's id
  89317. * @return the bone or null if not found
  89318. */
  89319. getBoneByID(id: string): Nullable<Bone>;
  89320. /**
  89321. * Gets a bone using its id
  89322. * @param name defines the bone's name
  89323. * @return the bone or null if not found
  89324. */
  89325. getBoneByName(name: string): Nullable<Bone>;
  89326. /**
  89327. * Gets a light node using its name
  89328. * @param name defines the the light's name
  89329. * @return the light or null if none found.
  89330. */
  89331. getLightByName(name: string): Nullable<Light>;
  89332. /**
  89333. * Gets a light node using its id
  89334. * @param id defines the light's id
  89335. * @return the light or null if none found.
  89336. */
  89337. getLightByID(id: string): Nullable<Light>;
  89338. /**
  89339. * Gets a light node using its scene-generated unique ID
  89340. * @param uniqueId defines the light's unique id
  89341. * @return the light or null if none found.
  89342. */
  89343. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89344. /**
  89345. * Gets a particle system by id
  89346. * @param id defines the particle system id
  89347. * @return the corresponding system or null if none found
  89348. */
  89349. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89350. /**
  89351. * Gets a geometry using its ID
  89352. * @param id defines the geometry's id
  89353. * @return the geometry or null if none found.
  89354. */
  89355. getGeometryByID(id: string): Nullable<Geometry>;
  89356. private _getGeometryByUniqueID;
  89357. /**
  89358. * Add a new geometry to this scene
  89359. * @param geometry defines the geometry to be added to the scene.
  89360. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89361. * @return a boolean defining if the geometry was added or not
  89362. */
  89363. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89364. /**
  89365. * Removes an existing geometry
  89366. * @param geometry defines the geometry to be removed from the scene
  89367. * @return a boolean defining if the geometry was removed or not
  89368. */
  89369. removeGeometry(geometry: Geometry): boolean;
  89370. /**
  89371. * Gets the list of geometries attached to the scene
  89372. * @returns an array of Geometry
  89373. */
  89374. getGeometries(): Geometry[];
  89375. /**
  89376. * Gets the first added mesh found of a given ID
  89377. * @param id defines the id to search for
  89378. * @return the mesh found or null if not found at all
  89379. */
  89380. getMeshByID(id: string): Nullable<AbstractMesh>;
  89381. /**
  89382. * Gets a list of meshes using their id
  89383. * @param id defines the id to search for
  89384. * @returns a list of meshes
  89385. */
  89386. getMeshesByID(id: string): Array<AbstractMesh>;
  89387. /**
  89388. * Gets the first added transform node found of a given ID
  89389. * @param id defines the id to search for
  89390. * @return the found transform node or null if not found at all.
  89391. */
  89392. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89393. /**
  89394. * Gets a list of transform nodes using their id
  89395. * @param id defines the id to search for
  89396. * @returns a list of transform nodes
  89397. */
  89398. getTransformNodesByID(id: string): Array<TransformNode>;
  89399. /**
  89400. * Gets a mesh with its auto-generated unique id
  89401. * @param uniqueId defines the unique id to search for
  89402. * @return the found mesh or null if not found at all.
  89403. */
  89404. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89405. /**
  89406. * Gets a the last added mesh using a given id
  89407. * @param id defines the id to search for
  89408. * @return the found mesh or null if not found at all.
  89409. */
  89410. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89411. /**
  89412. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89413. * @param id defines the id to search for
  89414. * @return the found node or null if not found at all
  89415. */
  89416. getLastEntryByID(id: string): Nullable<Node>;
  89417. /**
  89418. * Gets a node (Mesh, Camera, Light) using a given id
  89419. * @param id defines the id to search for
  89420. * @return the found node or null if not found at all
  89421. */
  89422. getNodeByID(id: string): Nullable<Node>;
  89423. /**
  89424. * Gets a node (Mesh, Camera, Light) using a given name
  89425. * @param name defines the name to search for
  89426. * @return the found node or null if not found at all.
  89427. */
  89428. getNodeByName(name: string): Nullable<Node>;
  89429. /**
  89430. * Gets a mesh using a given name
  89431. * @param name defines the name to search for
  89432. * @return the found mesh or null if not found at all.
  89433. */
  89434. getMeshByName(name: string): Nullable<AbstractMesh>;
  89435. /**
  89436. * Gets a transform node using a given name
  89437. * @param name defines the name to search for
  89438. * @return the found transform node or null if not found at all.
  89439. */
  89440. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89441. /**
  89442. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89443. * @param id defines the id to search for
  89444. * @return the found skeleton or null if not found at all.
  89445. */
  89446. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89447. /**
  89448. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89449. * @param id defines the id to search for
  89450. * @return the found skeleton or null if not found at all.
  89451. */
  89452. getSkeletonById(id: string): Nullable<Skeleton>;
  89453. /**
  89454. * Gets a skeleton using a given name
  89455. * @param name defines the name to search for
  89456. * @return the found skeleton or null if not found at all.
  89457. */
  89458. getSkeletonByName(name: string): Nullable<Skeleton>;
  89459. /**
  89460. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89461. * @param id defines the id to search for
  89462. * @return the found morph target manager or null if not found at all.
  89463. */
  89464. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89465. /**
  89466. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89467. * @param id defines the id to search for
  89468. * @return the found morph target or null if not found at all.
  89469. */
  89470. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89471. /**
  89472. * Gets a boolean indicating if the given mesh is active
  89473. * @param mesh defines the mesh to look for
  89474. * @returns true if the mesh is in the active list
  89475. */
  89476. isActiveMesh(mesh: AbstractMesh): boolean;
  89477. /**
  89478. * Return a unique id as a string which can serve as an identifier for the scene
  89479. */
  89480. readonly uid: string;
  89481. /**
  89482. * Add an externaly attached data from its key.
  89483. * This method call will fail and return false, if such key already exists.
  89484. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89485. * @param key the unique key that identifies the data
  89486. * @param data the data object to associate to the key for this Engine instance
  89487. * @return true if no such key were already present and the data was added successfully, false otherwise
  89488. */
  89489. addExternalData<T>(key: string, data: T): boolean;
  89490. /**
  89491. * Get an externaly attached data from its key
  89492. * @param key the unique key that identifies the data
  89493. * @return the associated data, if present (can be null), or undefined if not present
  89494. */
  89495. getExternalData<T>(key: string): Nullable<T>;
  89496. /**
  89497. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89498. * @param key the unique key that identifies the data
  89499. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89500. * @return the associated data, can be null if the factory returned null.
  89501. */
  89502. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89503. /**
  89504. * Remove an externaly attached data from the Engine instance
  89505. * @param key the unique key that identifies the data
  89506. * @return true if the data was successfully removed, false if it doesn't exist
  89507. */
  89508. removeExternalData(key: string): boolean;
  89509. private _evaluateSubMesh;
  89510. /**
  89511. * Clear the processed materials smart array preventing retention point in material dispose.
  89512. */
  89513. freeProcessedMaterials(): void;
  89514. private _preventFreeActiveMeshesAndRenderingGroups;
  89515. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89516. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89517. * when disposing several meshes in a row or a hierarchy of meshes.
  89518. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89519. */
  89520. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89521. /**
  89522. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89523. */
  89524. freeActiveMeshes(): void;
  89525. /**
  89526. * Clear the info related to rendering groups preventing retention points during dispose.
  89527. */
  89528. freeRenderingGroups(): void;
  89529. /** @hidden */
  89530. _isInIntermediateRendering(): boolean;
  89531. /**
  89532. * Lambda returning the list of potentially active meshes.
  89533. */
  89534. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89535. /**
  89536. * Lambda returning the list of potentially active sub meshes.
  89537. */
  89538. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89539. /**
  89540. * Lambda returning the list of potentially intersecting sub meshes.
  89541. */
  89542. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89543. /**
  89544. * Lambda returning the list of potentially colliding sub meshes.
  89545. */
  89546. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89547. private _activeMeshesFrozen;
  89548. /**
  89549. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89550. * @returns the current scene
  89551. */
  89552. freezeActiveMeshes(): Scene;
  89553. /**
  89554. * Use this function to restart evaluating active meshes on every frame
  89555. * @returns the current scene
  89556. */
  89557. unfreezeActiveMeshes(): Scene;
  89558. private _evaluateActiveMeshes;
  89559. private _activeMesh;
  89560. /**
  89561. * Update the transform matrix to update from the current active camera
  89562. * @param force defines a boolean used to force the update even if cache is up to date
  89563. */
  89564. updateTransformMatrix(force?: boolean): void;
  89565. /**
  89566. * 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)
  89567. * @param alternateCamera defines the camera to use
  89568. */
  89569. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89570. /** @hidden */
  89571. _allowPostProcessClearColor: boolean;
  89572. private _renderForCamera;
  89573. private _processSubCameras;
  89574. private _checkIntersections;
  89575. /** @hidden */
  89576. _advancePhysicsEngineStep(step: number): void;
  89577. /**
  89578. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89579. */
  89580. getDeterministicFrameTime: () => number;
  89581. /**
  89582. * Render the scene
  89583. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89584. */
  89585. render(updateCameras?: boolean): void;
  89586. /**
  89587. * Freeze all materials
  89588. * A frozen material will not be updatable but should be faster to render
  89589. */
  89590. freezeMaterials(): void;
  89591. /**
  89592. * Unfreeze all materials
  89593. * A frozen material will not be updatable but should be faster to render
  89594. */
  89595. unfreezeMaterials(): void;
  89596. /**
  89597. * Releases all held ressources
  89598. */
  89599. dispose(): void;
  89600. /**
  89601. * Gets if the scene is already disposed
  89602. */
  89603. readonly isDisposed: boolean;
  89604. /**
  89605. * Call this function to reduce memory footprint of the scene.
  89606. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89607. */
  89608. clearCachedVertexData(): void;
  89609. /**
  89610. * This function will remove the local cached buffer data from texture.
  89611. * It will save memory but will prevent the texture from being rebuilt
  89612. */
  89613. cleanCachedTextureBuffer(): void;
  89614. /**
  89615. * Get the world extend vectors with an optional filter
  89616. *
  89617. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89618. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89619. */
  89620. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89621. min: Vector3;
  89622. max: Vector3;
  89623. };
  89624. /**
  89625. * Creates a ray that can be used to pick in the scene
  89626. * @param x defines the x coordinate of the origin (on-screen)
  89627. * @param y defines the y coordinate of the origin (on-screen)
  89628. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89629. * @param camera defines the camera to use for the picking
  89630. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89631. * @returns a Ray
  89632. */
  89633. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89634. /**
  89635. * Creates a ray that can be used to pick in the scene
  89636. * @param x defines the x coordinate of the origin (on-screen)
  89637. * @param y defines the y coordinate of the origin (on-screen)
  89638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89639. * @param result defines the ray where to store the picking ray
  89640. * @param camera defines the camera to use for the picking
  89641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89642. * @returns the current scene
  89643. */
  89644. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89645. /**
  89646. * Creates a ray that can be used to pick in the scene
  89647. * @param x defines the x coordinate of the origin (on-screen)
  89648. * @param y defines the y coordinate of the origin (on-screen)
  89649. * @param camera defines the camera to use for the picking
  89650. * @returns a Ray
  89651. */
  89652. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89653. /**
  89654. * Creates a ray that can be used to pick in the scene
  89655. * @param x defines the x coordinate of the origin (on-screen)
  89656. * @param y defines the y coordinate of the origin (on-screen)
  89657. * @param result defines the ray where to store the picking ray
  89658. * @param camera defines the camera to use for the picking
  89659. * @returns the current scene
  89660. */
  89661. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89662. private _internalPick;
  89663. private _internalMultiPick;
  89664. private _tempPickingRay;
  89665. /** Launch a ray to try to pick a mesh in the scene
  89666. * @param x position on screen
  89667. * @param y position on screen
  89668. * @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
  89669. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89670. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89671. * @returns a PickingInfo
  89672. */
  89673. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89674. private _cachedRayForTransform;
  89675. /** Use the given ray to pick a mesh in the scene
  89676. * @param ray The ray to use to pick meshes
  89677. * @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
  89678. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89679. * @returns a PickingInfo
  89680. */
  89681. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89682. /**
  89683. * Launch a ray to try to pick a mesh in the scene
  89684. * @param x X position on screen
  89685. * @param y Y position on screen
  89686. * @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
  89687. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89688. * @returns an array of PickingInfo
  89689. */
  89690. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89691. /**
  89692. * Launch a ray to try to pick a mesh in the scene
  89693. * @param ray Ray to use
  89694. * @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
  89695. * @returns an array of PickingInfo
  89696. */
  89697. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89698. /**
  89699. * Force the value of meshUnderPointer
  89700. * @param mesh defines the mesh to use
  89701. */
  89702. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89703. /**
  89704. * Gets the mesh under the pointer
  89705. * @returns a Mesh or null if no mesh is under the pointer
  89706. */
  89707. getPointerOverMesh(): Nullable<AbstractMesh>;
  89708. /** @hidden */
  89709. _rebuildGeometries(): void;
  89710. /** @hidden */
  89711. _rebuildTextures(): void;
  89712. private _getByTags;
  89713. /**
  89714. * Get a list of meshes by tags
  89715. * @param tagsQuery defines the tags query to use
  89716. * @param forEach defines a predicate used to filter results
  89717. * @returns an array of Mesh
  89718. */
  89719. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89720. /**
  89721. * Get a list of cameras by tags
  89722. * @param tagsQuery defines the tags query to use
  89723. * @param forEach defines a predicate used to filter results
  89724. * @returns an array of Camera
  89725. */
  89726. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89727. /**
  89728. * Get a list of lights by tags
  89729. * @param tagsQuery defines the tags query to use
  89730. * @param forEach defines a predicate used to filter results
  89731. * @returns an array of Light
  89732. */
  89733. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89734. /**
  89735. * Get a list of materials by tags
  89736. * @param tagsQuery defines the tags query to use
  89737. * @param forEach defines a predicate used to filter results
  89738. * @returns an array of Material
  89739. */
  89740. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89741. /**
  89742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89743. * This allowed control for front to back rendering or reversly depending of the special needs.
  89744. *
  89745. * @param renderingGroupId The rendering group id corresponding to its index
  89746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89749. */
  89750. 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;
  89751. /**
  89752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89753. *
  89754. * @param renderingGroupId The rendering group id corresponding to its index
  89755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89758. */
  89759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89760. /**
  89761. * Gets the current auto clear configuration for one rendering group of the rendering
  89762. * manager.
  89763. * @param index the rendering group index to get the information for
  89764. * @returns The auto clear setup for the requested rendering group
  89765. */
  89766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89767. private _blockMaterialDirtyMechanism;
  89768. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89769. blockMaterialDirtyMechanism: boolean;
  89770. /**
  89771. * Will flag all materials as dirty to trigger new shader compilation
  89772. * @param flag defines the flag used to specify which material part must be marked as dirty
  89773. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89774. */
  89775. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89776. /** @hidden */
  89777. _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;
  89778. /** @hidden */
  89779. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89780. }
  89781. }
  89782. declare module BABYLON {
  89783. /**
  89784. * Set of assets to keep when moving a scene into an asset container.
  89785. */
  89786. export class KeepAssets extends AbstractScene {
  89787. }
  89788. /**
  89789. * Container with a set of assets that can be added or removed from a scene.
  89790. */
  89791. export class AssetContainer extends AbstractScene {
  89792. /**
  89793. * The scene the AssetContainer belongs to.
  89794. */
  89795. scene: Scene;
  89796. /**
  89797. * Instantiates an AssetContainer.
  89798. * @param scene The scene the AssetContainer belongs to.
  89799. */
  89800. constructor(scene: Scene);
  89801. /**
  89802. * Adds all the assets from the container to the scene.
  89803. */
  89804. addAllToScene(): void;
  89805. /**
  89806. * Removes all the assets in the container from the scene
  89807. */
  89808. removeAllFromScene(): void;
  89809. /**
  89810. * Disposes all the assets in the container
  89811. */
  89812. dispose(): void;
  89813. private _moveAssets;
  89814. /**
  89815. * Removes all the assets contained in the scene and adds them to the container.
  89816. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89817. */
  89818. moveAllFromScene(keepAssets?: KeepAssets): void;
  89819. /**
  89820. * 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.
  89821. * @returns the root mesh
  89822. */
  89823. createRootMesh(): Mesh;
  89824. }
  89825. }
  89826. declare module BABYLON {
  89827. /**
  89828. * Defines how the parser contract is defined.
  89829. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89830. */
  89831. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89832. /**
  89833. * Defines how the individual parser contract is defined.
  89834. * These parser can parse an individual asset
  89835. */
  89836. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89837. /**
  89838. * Base class of the scene acting as a container for the different elements composing a scene.
  89839. * This class is dynamically extended by the different components of the scene increasing
  89840. * flexibility and reducing coupling
  89841. */
  89842. export abstract class AbstractScene {
  89843. /**
  89844. * Stores the list of available parsers in the application.
  89845. */
  89846. private static _BabylonFileParsers;
  89847. /**
  89848. * Stores the list of available individual parsers in the application.
  89849. */
  89850. private static _IndividualBabylonFileParsers;
  89851. /**
  89852. * Adds a parser in the list of available ones
  89853. * @param name Defines the name of the parser
  89854. * @param parser Defines the parser to add
  89855. */
  89856. static AddParser(name: string, parser: BabylonFileParser): void;
  89857. /**
  89858. * Gets a general parser from the list of avaialble ones
  89859. * @param name Defines the name of the parser
  89860. * @returns the requested parser or null
  89861. */
  89862. static GetParser(name: string): Nullable<BabylonFileParser>;
  89863. /**
  89864. * Adds n individual parser in the list of available ones
  89865. * @param name Defines the name of the parser
  89866. * @param parser Defines the parser to add
  89867. */
  89868. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89869. /**
  89870. * Gets an individual parser from the list of avaialble ones
  89871. * @param name Defines the name of the parser
  89872. * @returns the requested parser or null
  89873. */
  89874. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89875. /**
  89876. * Parser json data and populate both a scene and its associated container object
  89877. * @param jsonData Defines the data to parse
  89878. * @param scene Defines the scene to parse the data for
  89879. * @param container Defines the container attached to the parsing sequence
  89880. * @param rootUrl Defines the root url of the data
  89881. */
  89882. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89883. /**
  89884. * Gets the list of root nodes (ie. nodes with no parent)
  89885. */
  89886. rootNodes: Node[];
  89887. /** All of the cameras added to this scene
  89888. * @see http://doc.babylonjs.com/babylon101/cameras
  89889. */
  89890. cameras: Camera[];
  89891. /**
  89892. * All of the lights added to this scene
  89893. * @see http://doc.babylonjs.com/babylon101/lights
  89894. */
  89895. lights: Light[];
  89896. /**
  89897. * All of the (abstract) meshes added to this scene
  89898. */
  89899. meshes: AbstractMesh[];
  89900. /**
  89901. * The list of skeletons added to the scene
  89902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89903. */
  89904. skeletons: Skeleton[];
  89905. /**
  89906. * All of the particle systems added to this scene
  89907. * @see http://doc.babylonjs.com/babylon101/particles
  89908. */
  89909. particleSystems: IParticleSystem[];
  89910. /**
  89911. * Gets a list of Animations associated with the scene
  89912. */
  89913. animations: Animation[];
  89914. /**
  89915. * All of the animation groups added to this scene
  89916. * @see http://doc.babylonjs.com/how_to/group
  89917. */
  89918. animationGroups: AnimationGroup[];
  89919. /**
  89920. * All of the multi-materials added to this scene
  89921. * @see http://doc.babylonjs.com/how_to/multi_materials
  89922. */
  89923. multiMaterials: MultiMaterial[];
  89924. /**
  89925. * All of the materials added to this scene
  89926. * In the context of a Scene, it is not supposed to be modified manually.
  89927. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89928. * Note also that the order of the Material wihin the array is not significant and might change.
  89929. * @see http://doc.babylonjs.com/babylon101/materials
  89930. */
  89931. materials: Material[];
  89932. /**
  89933. * The list of morph target managers added to the scene
  89934. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89935. */
  89936. morphTargetManagers: MorphTargetManager[];
  89937. /**
  89938. * The list of geometries used in the scene.
  89939. */
  89940. geometries: Geometry[];
  89941. /**
  89942. * All of the tranform nodes added to this scene
  89943. * In the context of a Scene, it is not supposed to be modified manually.
  89944. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89945. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89946. * @see http://doc.babylonjs.com/how_to/transformnode
  89947. */
  89948. transformNodes: TransformNode[];
  89949. /**
  89950. * ActionManagers available on the scene.
  89951. */
  89952. actionManagers: ActionManager[];
  89953. /**
  89954. * Textures to keep.
  89955. */
  89956. textures: BaseTexture[];
  89957. }
  89958. }
  89959. declare module BABYLON {
  89960. /**
  89961. * Defines a sound that can be played in the application.
  89962. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89964. */
  89965. export class Sound {
  89966. /**
  89967. * The name of the sound in the scene.
  89968. */
  89969. name: string;
  89970. /**
  89971. * Does the sound autoplay once loaded.
  89972. */
  89973. autoplay: boolean;
  89974. /**
  89975. * Does the sound loop after it finishes playing once.
  89976. */
  89977. loop: boolean;
  89978. /**
  89979. * Does the sound use a custom attenuation curve to simulate the falloff
  89980. * happening when the source gets further away from the camera.
  89981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89982. */
  89983. useCustomAttenuation: boolean;
  89984. /**
  89985. * The sound track id this sound belongs to.
  89986. */
  89987. soundTrackId: number;
  89988. /**
  89989. * Is this sound currently played.
  89990. */
  89991. isPlaying: boolean;
  89992. /**
  89993. * Is this sound currently paused.
  89994. */
  89995. isPaused: boolean;
  89996. /**
  89997. * Does this sound enables spatial sound.
  89998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89999. */
  90000. spatialSound: boolean;
  90001. /**
  90002. * Define the reference distance the sound should be heard perfectly.
  90003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90004. */
  90005. refDistance: number;
  90006. /**
  90007. * Define the roll off factor of spatial sounds.
  90008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90009. */
  90010. rolloffFactor: number;
  90011. /**
  90012. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90014. */
  90015. maxDistance: number;
  90016. /**
  90017. * Define the distance attenuation model the sound will follow.
  90018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90019. */
  90020. distanceModel: string;
  90021. /**
  90022. * @hidden
  90023. * Back Compat
  90024. **/
  90025. onended: () => any;
  90026. /**
  90027. * Observable event when the current playing sound finishes.
  90028. */
  90029. onEndedObservable: Observable<Sound>;
  90030. private _panningModel;
  90031. private _playbackRate;
  90032. private _streaming;
  90033. private _startTime;
  90034. private _startOffset;
  90035. private _position;
  90036. /** @hidden */
  90037. _positionInEmitterSpace: boolean;
  90038. private _localDirection;
  90039. private _volume;
  90040. private _isReadyToPlay;
  90041. private _isDirectional;
  90042. private _readyToPlayCallback;
  90043. private _audioBuffer;
  90044. private _soundSource;
  90045. private _streamingSource;
  90046. private _soundPanner;
  90047. private _soundGain;
  90048. private _inputAudioNode;
  90049. private _outputAudioNode;
  90050. private _coneInnerAngle;
  90051. private _coneOuterAngle;
  90052. private _coneOuterGain;
  90053. private _scene;
  90054. private _connectedTransformNode;
  90055. private _customAttenuationFunction;
  90056. private _registerFunc;
  90057. private _isOutputConnected;
  90058. private _htmlAudioElement;
  90059. private _urlType;
  90060. /** @hidden */
  90061. static _SceneComponentInitialization: (scene: Scene) => void;
  90062. /**
  90063. * Create a sound and attach it to a scene
  90064. * @param name Name of your sound
  90065. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90066. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90067. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90068. */
  90069. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90070. /**
  90071. * Release the sound and its associated resources
  90072. */
  90073. dispose(): void;
  90074. /**
  90075. * Gets if the sounds is ready to be played or not.
  90076. * @returns true if ready, otherwise false
  90077. */
  90078. isReady(): boolean;
  90079. private _soundLoaded;
  90080. /**
  90081. * Sets the data of the sound from an audiobuffer
  90082. * @param audioBuffer The audioBuffer containing the data
  90083. */
  90084. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90085. /**
  90086. * Updates the current sounds options such as maxdistance, loop...
  90087. * @param options A JSON object containing values named as the object properties
  90088. */
  90089. updateOptions(options: any): void;
  90090. private _createSpatialParameters;
  90091. private _updateSpatialParameters;
  90092. /**
  90093. * Switch the panning model to HRTF:
  90094. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90096. */
  90097. switchPanningModelToHRTF(): void;
  90098. /**
  90099. * Switch the panning model to Equal Power:
  90100. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90102. */
  90103. switchPanningModelToEqualPower(): void;
  90104. private _switchPanningModel;
  90105. /**
  90106. * Connect this sound to a sound track audio node like gain...
  90107. * @param soundTrackAudioNode the sound track audio node to connect to
  90108. */
  90109. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90110. /**
  90111. * Transform this sound into a directional source
  90112. * @param coneInnerAngle Size of the inner cone in degree
  90113. * @param coneOuterAngle Size of the outer cone in degree
  90114. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90115. */
  90116. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90117. /**
  90118. * Gets or sets the inner angle for the directional cone.
  90119. */
  90120. /**
  90121. * Gets or sets the inner angle for the directional cone.
  90122. */
  90123. directionalConeInnerAngle: number;
  90124. /**
  90125. * Gets or sets the outer angle for the directional cone.
  90126. */
  90127. /**
  90128. * Gets or sets the outer angle for the directional cone.
  90129. */
  90130. directionalConeOuterAngle: number;
  90131. /**
  90132. * Sets the position of the emitter if spatial sound is enabled
  90133. * @param newPosition Defines the new posisiton
  90134. */
  90135. setPosition(newPosition: Vector3): void;
  90136. /**
  90137. * Sets the local direction of the emitter if spatial sound is enabled
  90138. * @param newLocalDirection Defines the new local direction
  90139. */
  90140. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90141. private _updateDirection;
  90142. /** @hidden */
  90143. updateDistanceFromListener(): void;
  90144. /**
  90145. * Sets a new custom attenuation function for the sound.
  90146. * @param callback Defines the function used for the attenuation
  90147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90148. */
  90149. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90150. /**
  90151. * Play the sound
  90152. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90153. * @param offset (optional) Start the sound setting it at a specific time
  90154. */
  90155. play(time?: number, offset?: number): void;
  90156. private _onended;
  90157. /**
  90158. * Stop the sound
  90159. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90160. */
  90161. stop(time?: number): void;
  90162. /**
  90163. * Put the sound in pause
  90164. */
  90165. pause(): void;
  90166. /**
  90167. * Sets a dedicated volume for this sounds
  90168. * @param newVolume Define the new volume of the sound
  90169. * @param time Define in how long the sound should be at this value
  90170. */
  90171. setVolume(newVolume: number, time?: number): void;
  90172. /**
  90173. * Set the sound play back rate
  90174. * @param newPlaybackRate Define the playback rate the sound should be played at
  90175. */
  90176. setPlaybackRate(newPlaybackRate: number): void;
  90177. /**
  90178. * Gets the volume of the sound.
  90179. * @returns the volume of the sound
  90180. */
  90181. getVolume(): number;
  90182. /**
  90183. * Attach the sound to a dedicated mesh
  90184. * @param transformNode The transform node to connect the sound with
  90185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90186. */
  90187. attachToMesh(transformNode: TransformNode): void;
  90188. /**
  90189. * Detach the sound from the previously attached mesh
  90190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90191. */
  90192. detachFromMesh(): void;
  90193. private _onRegisterAfterWorldMatrixUpdate;
  90194. /**
  90195. * Clone the current sound in the scene.
  90196. * @returns the new sound clone
  90197. */
  90198. clone(): Nullable<Sound>;
  90199. /**
  90200. * Gets the current underlying audio buffer containing the data
  90201. * @returns the audio buffer
  90202. */
  90203. getAudioBuffer(): Nullable<AudioBuffer>;
  90204. /**
  90205. * Serializes the Sound in a JSON representation
  90206. * @returns the JSON representation of the sound
  90207. */
  90208. serialize(): any;
  90209. /**
  90210. * Parse a JSON representation of a sound to innstantiate in a given scene
  90211. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90212. * @param scene Define the scene the new parsed sound should be created in
  90213. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90214. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90215. * @returns the newly parsed sound
  90216. */
  90217. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90218. }
  90219. }
  90220. declare module BABYLON {
  90221. /**
  90222. * This defines an action helpful to play a defined sound on a triggered action.
  90223. */
  90224. export class PlaySoundAction extends Action {
  90225. private _sound;
  90226. /**
  90227. * Instantiate the action
  90228. * @param triggerOptions defines the trigger options
  90229. * @param sound defines the sound to play
  90230. * @param condition defines the trigger related conditions
  90231. */
  90232. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90233. /** @hidden */
  90234. _prepare(): void;
  90235. /**
  90236. * Execute the action and play the sound.
  90237. */
  90238. execute(): void;
  90239. /**
  90240. * Serializes the actions and its related information.
  90241. * @param parent defines the object to serialize in
  90242. * @returns the serialized object
  90243. */
  90244. serialize(parent: any): any;
  90245. }
  90246. /**
  90247. * This defines an action helpful to stop a defined sound on a triggered action.
  90248. */
  90249. export class StopSoundAction extends Action {
  90250. private _sound;
  90251. /**
  90252. * Instantiate the action
  90253. * @param triggerOptions defines the trigger options
  90254. * @param sound defines the sound to stop
  90255. * @param condition defines the trigger related conditions
  90256. */
  90257. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90258. /** @hidden */
  90259. _prepare(): void;
  90260. /**
  90261. * Execute the action and stop the sound.
  90262. */
  90263. execute(): void;
  90264. /**
  90265. * Serializes the actions and its related information.
  90266. * @param parent defines the object to serialize in
  90267. * @returns the serialized object
  90268. */
  90269. serialize(parent: any): any;
  90270. }
  90271. }
  90272. declare module BABYLON {
  90273. /**
  90274. * This defines an action responsible to change the value of a property
  90275. * by interpolating between its current value and the newly set one once triggered.
  90276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90277. */
  90278. export class InterpolateValueAction extends Action {
  90279. /**
  90280. * Defines the path of the property where the value should be interpolated
  90281. */
  90282. propertyPath: string;
  90283. /**
  90284. * Defines the target value at the end of the interpolation.
  90285. */
  90286. value: any;
  90287. /**
  90288. * Defines the time it will take for the property to interpolate to the value.
  90289. */
  90290. duration: number;
  90291. /**
  90292. * Defines if the other scene animations should be stopped when the action has been triggered
  90293. */
  90294. stopOtherAnimations?: boolean;
  90295. /**
  90296. * Defines a callback raised once the interpolation animation has been done.
  90297. */
  90298. onInterpolationDone?: () => void;
  90299. /**
  90300. * Observable triggered once the interpolation animation has been done.
  90301. */
  90302. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90303. private _target;
  90304. private _effectiveTarget;
  90305. private _property;
  90306. /**
  90307. * Instantiate the action
  90308. * @param triggerOptions defines the trigger options
  90309. * @param target defines the object containing the value to interpolate
  90310. * @param propertyPath defines the path to the property in the target object
  90311. * @param value defines the target value at the end of the interpolation
  90312. * @param duration deines the time it will take for the property to interpolate to the value.
  90313. * @param condition defines the trigger related conditions
  90314. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90315. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90316. */
  90317. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90318. /** @hidden */
  90319. _prepare(): void;
  90320. /**
  90321. * Execute the action starts the value interpolation.
  90322. */
  90323. execute(): void;
  90324. /**
  90325. * Serializes the actions and its related information.
  90326. * @param parent defines the object to serialize in
  90327. * @returns the serialized object
  90328. */
  90329. serialize(parent: any): any;
  90330. }
  90331. }
  90332. declare module BABYLON {
  90333. /**
  90334. * Options allowed during the creation of a sound track.
  90335. */
  90336. export interface ISoundTrackOptions {
  90337. /**
  90338. * The volume the sound track should take during creation
  90339. */
  90340. volume?: number;
  90341. /**
  90342. * Define if the sound track is the main sound track of the scene
  90343. */
  90344. mainTrack?: boolean;
  90345. }
  90346. /**
  90347. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90348. * It will be also used in a future release to apply effects on a specific track.
  90349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90350. */
  90351. export class SoundTrack {
  90352. /**
  90353. * The unique identifier of the sound track in the scene.
  90354. */
  90355. id: number;
  90356. /**
  90357. * The list of sounds included in the sound track.
  90358. */
  90359. soundCollection: Array<Sound>;
  90360. private _outputAudioNode;
  90361. private _scene;
  90362. private _isMainTrack;
  90363. private _connectedAnalyser;
  90364. private _options;
  90365. private _isInitialized;
  90366. /**
  90367. * Creates a new sound track.
  90368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90369. * @param scene Define the scene the sound track belongs to
  90370. * @param options
  90371. */
  90372. constructor(scene: Scene, options?: ISoundTrackOptions);
  90373. private _initializeSoundTrackAudioGraph;
  90374. /**
  90375. * Release the sound track and its associated resources
  90376. */
  90377. dispose(): void;
  90378. /**
  90379. * Adds a sound to this sound track
  90380. * @param sound define the cound to add
  90381. * @ignoreNaming
  90382. */
  90383. AddSound(sound: Sound): void;
  90384. /**
  90385. * Removes a sound to this sound track
  90386. * @param sound define the cound to remove
  90387. * @ignoreNaming
  90388. */
  90389. RemoveSound(sound: Sound): void;
  90390. /**
  90391. * Set a global volume for the full sound track.
  90392. * @param newVolume Define the new volume of the sound track
  90393. */
  90394. setVolume(newVolume: number): void;
  90395. /**
  90396. * Switch the panning model to HRTF:
  90397. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90399. */
  90400. switchPanningModelToHRTF(): void;
  90401. /**
  90402. * Switch the panning model to Equal Power:
  90403. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90405. */
  90406. switchPanningModelToEqualPower(): void;
  90407. /**
  90408. * Connect the sound track to an audio analyser allowing some amazing
  90409. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90411. * @param analyser The analyser to connect to the engine
  90412. */
  90413. connectToAnalyser(analyser: Analyser): void;
  90414. }
  90415. }
  90416. declare module BABYLON {
  90417. interface AbstractScene {
  90418. /**
  90419. * The list of sounds used in the scene.
  90420. */
  90421. sounds: Nullable<Array<Sound>>;
  90422. }
  90423. interface Scene {
  90424. /**
  90425. * @hidden
  90426. * Backing field
  90427. */
  90428. _mainSoundTrack: SoundTrack;
  90429. /**
  90430. * The main sound track played by the scene.
  90431. * It cotains your primary collection of sounds.
  90432. */
  90433. mainSoundTrack: SoundTrack;
  90434. /**
  90435. * The list of sound tracks added to the scene
  90436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90437. */
  90438. soundTracks: Nullable<Array<SoundTrack>>;
  90439. /**
  90440. * Gets a sound using a given name
  90441. * @param name defines the name to search for
  90442. * @return the found sound or null if not found at all.
  90443. */
  90444. getSoundByName(name: string): Nullable<Sound>;
  90445. /**
  90446. * Gets or sets if audio support is enabled
  90447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90448. */
  90449. audioEnabled: boolean;
  90450. /**
  90451. * Gets or sets if audio will be output to headphones
  90452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90453. */
  90454. headphone: boolean;
  90455. }
  90456. /**
  90457. * Defines the sound scene component responsible to manage any sounds
  90458. * in a given scene.
  90459. */
  90460. export class AudioSceneComponent implements ISceneSerializableComponent {
  90461. /**
  90462. * The component name helpfull to identify the component in the list of scene components.
  90463. */
  90464. readonly name: string;
  90465. /**
  90466. * The scene the component belongs to.
  90467. */
  90468. scene: Scene;
  90469. private _audioEnabled;
  90470. /**
  90471. * Gets whether audio is enabled or not.
  90472. * Please use related enable/disable method to switch state.
  90473. */
  90474. readonly audioEnabled: boolean;
  90475. private _headphone;
  90476. /**
  90477. * Gets whether audio is outputing to headphone or not.
  90478. * Please use the according Switch methods to change output.
  90479. */
  90480. readonly headphone: boolean;
  90481. /**
  90482. * Creates a new instance of the component for the given scene
  90483. * @param scene Defines the scene to register the component in
  90484. */
  90485. constructor(scene: Scene);
  90486. /**
  90487. * Registers the component in a given scene
  90488. */
  90489. register(): void;
  90490. /**
  90491. * Rebuilds the elements related to this component in case of
  90492. * context lost for instance.
  90493. */
  90494. rebuild(): void;
  90495. /**
  90496. * Serializes the component data to the specified json object
  90497. * @param serializationObject The object to serialize to
  90498. */
  90499. serialize(serializationObject: any): void;
  90500. /**
  90501. * Adds all the element from the container to the scene
  90502. * @param container the container holding the elements
  90503. */
  90504. addFromContainer(container: AbstractScene): void;
  90505. /**
  90506. * Removes all the elements in the container from the scene
  90507. * @param container contains the elements to remove
  90508. */
  90509. removeFromContainer(container: AbstractScene): void;
  90510. /**
  90511. * Disposes the component and the associated ressources.
  90512. */
  90513. dispose(): void;
  90514. /**
  90515. * Disables audio in the associated scene.
  90516. */
  90517. disableAudio(): void;
  90518. /**
  90519. * Enables audio in the associated scene.
  90520. */
  90521. enableAudio(): void;
  90522. /**
  90523. * Switch audio to headphone output.
  90524. */
  90525. switchAudioModeForHeadphones(): void;
  90526. /**
  90527. * Switch audio to normal speakers.
  90528. */
  90529. switchAudioModeForNormalSpeakers(): void;
  90530. private _afterRender;
  90531. }
  90532. }
  90533. declare module BABYLON {
  90534. /**
  90535. * Wraps one or more Sound objects and selects one with random weight for playback.
  90536. */
  90537. export class WeightedSound {
  90538. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90539. loop: boolean;
  90540. private _coneInnerAngle;
  90541. private _coneOuterAngle;
  90542. private _volume;
  90543. /** A Sound is currently playing. */
  90544. isPlaying: boolean;
  90545. /** A Sound is currently paused. */
  90546. isPaused: boolean;
  90547. private _sounds;
  90548. private _weights;
  90549. private _currentIndex?;
  90550. /**
  90551. * Creates a new WeightedSound from the list of sounds given.
  90552. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90553. * @param sounds Array of Sounds that will be selected from.
  90554. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90555. */
  90556. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90557. /**
  90558. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90559. */
  90560. /**
  90561. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90562. */
  90563. directionalConeInnerAngle: number;
  90564. /**
  90565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90567. */
  90568. /**
  90569. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90570. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90571. */
  90572. directionalConeOuterAngle: number;
  90573. /**
  90574. * Playback volume.
  90575. */
  90576. /**
  90577. * Playback volume.
  90578. */
  90579. volume: number;
  90580. private _onended;
  90581. /**
  90582. * Suspend playback
  90583. */
  90584. pause(): void;
  90585. /**
  90586. * Stop playback
  90587. */
  90588. stop(): void;
  90589. /**
  90590. * Start playback.
  90591. * @param startOffset Position the clip head at a specific time in seconds.
  90592. */
  90593. play(startOffset?: number): void;
  90594. }
  90595. }
  90596. declare module BABYLON {
  90597. /**
  90598. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90600. */
  90601. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90602. /**
  90603. * Gets the name of the behavior.
  90604. */
  90605. readonly name: string;
  90606. /**
  90607. * The easing function used by animations
  90608. */
  90609. static EasingFunction: BackEase;
  90610. /**
  90611. * The easing mode used by animations
  90612. */
  90613. static EasingMode: number;
  90614. /**
  90615. * The duration of the animation, in milliseconds
  90616. */
  90617. transitionDuration: number;
  90618. /**
  90619. * Length of the distance animated by the transition when lower radius is reached
  90620. */
  90621. lowerRadiusTransitionRange: number;
  90622. /**
  90623. * Length of the distance animated by the transition when upper radius is reached
  90624. */
  90625. upperRadiusTransitionRange: number;
  90626. private _autoTransitionRange;
  90627. /**
  90628. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90629. */
  90630. /**
  90631. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90632. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90633. */
  90634. autoTransitionRange: boolean;
  90635. private _attachedCamera;
  90636. private _onAfterCheckInputsObserver;
  90637. private _onMeshTargetChangedObserver;
  90638. /**
  90639. * Initializes the behavior.
  90640. */
  90641. init(): void;
  90642. /**
  90643. * Attaches the behavior to its arc rotate camera.
  90644. * @param camera Defines the camera to attach the behavior to
  90645. */
  90646. attach(camera: ArcRotateCamera): void;
  90647. /**
  90648. * Detaches the behavior from its current arc rotate camera.
  90649. */
  90650. detach(): void;
  90651. private _radiusIsAnimating;
  90652. private _radiusBounceTransition;
  90653. private _animatables;
  90654. private _cachedWheelPrecision;
  90655. /**
  90656. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90657. * @param radiusLimit The limit to check against.
  90658. * @return Bool to indicate if at limit.
  90659. */
  90660. private _isRadiusAtLimit;
  90661. /**
  90662. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90663. * @param radiusDelta The delta by which to animate to. Can be negative.
  90664. */
  90665. private _applyBoundRadiusAnimation;
  90666. /**
  90667. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90668. */
  90669. protected _clearAnimationLocks(): void;
  90670. /**
  90671. * Stops and removes all animations that have been applied to the camera
  90672. */
  90673. stopAllAnimations(): void;
  90674. }
  90675. }
  90676. declare module BABYLON {
  90677. /**
  90678. * 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.
  90679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90680. */
  90681. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90682. /**
  90683. * Gets the name of the behavior.
  90684. */
  90685. readonly name: string;
  90686. private _mode;
  90687. private _radiusScale;
  90688. private _positionScale;
  90689. private _defaultElevation;
  90690. private _elevationReturnTime;
  90691. private _elevationReturnWaitTime;
  90692. private _zoomStopsAnimation;
  90693. private _framingTime;
  90694. /**
  90695. * The easing function used by animations
  90696. */
  90697. static EasingFunction: ExponentialEase;
  90698. /**
  90699. * The easing mode used by animations
  90700. */
  90701. static EasingMode: number;
  90702. /**
  90703. * Sets the current mode used by the behavior
  90704. */
  90705. /**
  90706. * Gets current mode used by the behavior.
  90707. */
  90708. mode: number;
  90709. /**
  90710. * Sets the scale applied to the radius (1 by default)
  90711. */
  90712. /**
  90713. * Gets the scale applied to the radius
  90714. */
  90715. radiusScale: number;
  90716. /**
  90717. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90718. */
  90719. /**
  90720. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90721. */
  90722. positionScale: number;
  90723. /**
  90724. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90725. * behaviour is triggered, in radians.
  90726. */
  90727. /**
  90728. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90729. * behaviour is triggered, in radians.
  90730. */
  90731. defaultElevation: number;
  90732. /**
  90733. * Sets the time (in milliseconds) taken to return to the default beta position.
  90734. * Negative value indicates camera should not return to default.
  90735. */
  90736. /**
  90737. * Gets the time (in milliseconds) taken to return to the default beta position.
  90738. * Negative value indicates camera should not return to default.
  90739. */
  90740. elevationReturnTime: number;
  90741. /**
  90742. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90743. */
  90744. /**
  90745. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90746. */
  90747. elevationReturnWaitTime: number;
  90748. /**
  90749. * Sets the flag that indicates if user zooming should stop animation.
  90750. */
  90751. /**
  90752. * Gets the flag that indicates if user zooming should stop animation.
  90753. */
  90754. zoomStopsAnimation: boolean;
  90755. /**
  90756. * Sets the transition time when framing the mesh, in milliseconds
  90757. */
  90758. /**
  90759. * Gets the transition time when framing the mesh, in milliseconds
  90760. */
  90761. framingTime: number;
  90762. /**
  90763. * Define if the behavior should automatically change the configured
  90764. * camera limits and sensibilities.
  90765. */
  90766. autoCorrectCameraLimitsAndSensibility: boolean;
  90767. private _onPrePointerObservableObserver;
  90768. private _onAfterCheckInputsObserver;
  90769. private _onMeshTargetChangedObserver;
  90770. private _attachedCamera;
  90771. private _isPointerDown;
  90772. private _lastInteractionTime;
  90773. /**
  90774. * Initializes the behavior.
  90775. */
  90776. init(): void;
  90777. /**
  90778. * Attaches the behavior to its arc rotate camera.
  90779. * @param camera Defines the camera to attach the behavior to
  90780. */
  90781. attach(camera: ArcRotateCamera): void;
  90782. /**
  90783. * Detaches the behavior from its current arc rotate camera.
  90784. */
  90785. detach(): void;
  90786. private _animatables;
  90787. private _betaIsAnimating;
  90788. private _betaTransition;
  90789. private _radiusTransition;
  90790. private _vectorTransition;
  90791. /**
  90792. * Targets the given mesh and updates zoom level accordingly.
  90793. * @param mesh The mesh to target.
  90794. * @param radius Optional. If a cached radius position already exists, overrides default.
  90795. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90796. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90797. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90798. */
  90799. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90800. /**
  90801. * Targets the given mesh with its children and updates zoom level accordingly.
  90802. * @param mesh The mesh to target.
  90803. * @param radius Optional. If a cached radius position already exists, overrides default.
  90804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90807. */
  90808. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90809. /**
  90810. * Targets the given meshes with their children and updates zoom level accordingly.
  90811. * @param meshes The mesh to target.
  90812. * @param radius Optional. If a cached radius position already exists, overrides default.
  90813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90816. */
  90817. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90818. /**
  90819. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90820. * @param minimumWorld Determines the smaller position of the bounding box extend
  90821. * @param maximumWorld Determines the bigger position of the bounding box extend
  90822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90824. */
  90825. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90826. /**
  90827. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90828. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90829. * frustum width.
  90830. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90831. * to fully enclose the mesh in the viewing frustum.
  90832. */
  90833. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90834. /**
  90835. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90836. * is automatically returned to its default position (expected to be above ground plane).
  90837. */
  90838. private _maintainCameraAboveGround;
  90839. /**
  90840. * Returns the frustum slope based on the canvas ratio and camera FOV
  90841. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90842. */
  90843. private _getFrustumSlope;
  90844. /**
  90845. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90846. */
  90847. private _clearAnimationLocks;
  90848. /**
  90849. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90850. */
  90851. private _applyUserInteraction;
  90852. /**
  90853. * Stops and removes all animations that have been applied to the camera
  90854. */
  90855. stopAllAnimations(): void;
  90856. /**
  90857. * Gets a value indicating if the user is moving the camera
  90858. */
  90859. readonly isUserIsMoving: boolean;
  90860. /**
  90861. * The camera can move all the way towards the mesh.
  90862. */
  90863. static IgnoreBoundsSizeMode: number;
  90864. /**
  90865. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90866. */
  90867. static FitFrustumSidesMode: number;
  90868. }
  90869. }
  90870. declare module BABYLON {
  90871. /**
  90872. * Manage the pointers inputs to control an arc rotate camera.
  90873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90874. */
  90875. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90876. /**
  90877. * Defines the camera the input is attached to.
  90878. */
  90879. camera: ArcRotateCamera;
  90880. /**
  90881. * Defines the buttons associated with the input to handle camera move.
  90882. */
  90883. buttons: number[];
  90884. /**
  90885. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90886. */
  90887. angularSensibilityX: number;
  90888. /**
  90889. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90890. */
  90891. angularSensibilityY: number;
  90892. /**
  90893. * Defines the pointer pinch precision or how fast is the camera zooming.
  90894. */
  90895. pinchPrecision: number;
  90896. /**
  90897. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90898. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90899. */
  90900. pinchDeltaPercentage: number;
  90901. /**
  90902. * Defines the pointer panning sensibility or how fast is the camera moving.
  90903. */
  90904. panningSensibility: number;
  90905. /**
  90906. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90907. */
  90908. multiTouchPanning: boolean;
  90909. /**
  90910. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90911. */
  90912. multiTouchPanAndZoom: boolean;
  90913. /**
  90914. * Revers pinch action direction.
  90915. */
  90916. pinchInwards: boolean;
  90917. private _isPanClick;
  90918. private _pointerInput;
  90919. private _observer;
  90920. private _onMouseMove;
  90921. private _onGestureStart;
  90922. private _onGesture;
  90923. private _MSGestureHandler;
  90924. private _onLostFocus;
  90925. private _onContextMenu;
  90926. /**
  90927. * Attach the input controls to a specific dom element to get the input from.
  90928. * @param element Defines the element the controls should be listened from
  90929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90930. */
  90931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90932. /**
  90933. * Detach the current controls from the specified dom element.
  90934. * @param element Defines the element to stop listening the inputs from
  90935. */
  90936. detachControl(element: Nullable<HTMLElement>): void;
  90937. /**
  90938. * Gets the class name of the current intput.
  90939. * @returns the class name
  90940. */
  90941. getClassName(): string;
  90942. /**
  90943. * Get the friendly name associated with the input class.
  90944. * @returns the input friendly name
  90945. */
  90946. getSimpleName(): string;
  90947. }
  90948. }
  90949. declare module BABYLON {
  90950. /**
  90951. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90953. */
  90954. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90955. /**
  90956. * Defines the camera the input is attached to.
  90957. */
  90958. camera: ArcRotateCamera;
  90959. /**
  90960. * Defines the list of key codes associated with the up action (increase alpha)
  90961. */
  90962. keysUp: number[];
  90963. /**
  90964. * Defines the list of key codes associated with the down action (decrease alpha)
  90965. */
  90966. keysDown: number[];
  90967. /**
  90968. * Defines the list of key codes associated with the left action (increase beta)
  90969. */
  90970. keysLeft: number[];
  90971. /**
  90972. * Defines the list of key codes associated with the right action (decrease beta)
  90973. */
  90974. keysRight: number[];
  90975. /**
  90976. * Defines the list of key codes associated with the reset action.
  90977. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90978. */
  90979. keysReset: number[];
  90980. /**
  90981. * Defines the panning sensibility of the inputs.
  90982. * (How fast is the camera paning)
  90983. */
  90984. panningSensibility: number;
  90985. /**
  90986. * Defines the zooming sensibility of the inputs.
  90987. * (How fast is the camera zooming)
  90988. */
  90989. zoomingSensibility: number;
  90990. /**
  90991. * Defines wether maintaining the alt key down switch the movement mode from
  90992. * orientation to zoom.
  90993. */
  90994. useAltToZoom: boolean;
  90995. /**
  90996. * Rotation speed of the camera
  90997. */
  90998. angularSpeed: number;
  90999. private _keys;
  91000. private _ctrlPressed;
  91001. private _altPressed;
  91002. private _onCanvasBlurObserver;
  91003. private _onKeyboardObserver;
  91004. private _engine;
  91005. private _scene;
  91006. /**
  91007. * Attach the input controls to a specific dom element to get the input from.
  91008. * @param element Defines the element the controls should be listened from
  91009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91010. */
  91011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91012. /**
  91013. * Detach the current controls from the specified dom element.
  91014. * @param element Defines the element to stop listening the inputs from
  91015. */
  91016. detachControl(element: Nullable<HTMLElement>): void;
  91017. /**
  91018. * Update the current camera state depending on the inputs that have been used this frame.
  91019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91020. */
  91021. checkInputs(): void;
  91022. /**
  91023. * Gets the class name of the current intput.
  91024. * @returns the class name
  91025. */
  91026. getClassName(): string;
  91027. /**
  91028. * Get the friendly name associated with the input class.
  91029. * @returns the input friendly name
  91030. */
  91031. getSimpleName(): string;
  91032. }
  91033. }
  91034. declare module BABYLON {
  91035. /**
  91036. * Manage the mouse wheel inputs to control an arc rotate camera.
  91037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91038. */
  91039. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91040. /**
  91041. * Defines the camera the input is attached to.
  91042. */
  91043. camera: ArcRotateCamera;
  91044. /**
  91045. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91046. */
  91047. wheelPrecision: number;
  91048. /**
  91049. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91050. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91051. */
  91052. wheelDeltaPercentage: number;
  91053. private _wheel;
  91054. private _observer;
  91055. /**
  91056. * Attach the input controls to a specific dom element to get the input from.
  91057. * @param element Defines the element the controls should be listened from
  91058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91059. */
  91060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91061. /**
  91062. * Detach the current controls from the specified dom element.
  91063. * @param element Defines the element to stop listening the inputs from
  91064. */
  91065. detachControl(element: Nullable<HTMLElement>): void;
  91066. /**
  91067. * Gets the class name of the current intput.
  91068. * @returns the class name
  91069. */
  91070. getClassName(): string;
  91071. /**
  91072. * Get the friendly name associated with the input class.
  91073. * @returns the input friendly name
  91074. */
  91075. getSimpleName(): string;
  91076. }
  91077. }
  91078. declare module BABYLON {
  91079. /**
  91080. * Default Inputs manager for the ArcRotateCamera.
  91081. * It groups all the default supported inputs for ease of use.
  91082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91083. */
  91084. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91085. /**
  91086. * Instantiates a new ArcRotateCameraInputsManager.
  91087. * @param camera Defines the camera the inputs belong to
  91088. */
  91089. constructor(camera: ArcRotateCamera);
  91090. /**
  91091. * Add mouse wheel input support to the input manager.
  91092. * @returns the current input manager
  91093. */
  91094. addMouseWheel(): ArcRotateCameraInputsManager;
  91095. /**
  91096. * Add pointers input support to the input manager.
  91097. * @returns the current input manager
  91098. */
  91099. addPointers(): ArcRotateCameraInputsManager;
  91100. /**
  91101. * Add keyboard input support to the input manager.
  91102. * @returns the current input manager
  91103. */
  91104. addKeyboard(): ArcRotateCameraInputsManager;
  91105. }
  91106. }
  91107. declare module BABYLON {
  91108. /**
  91109. * This represents an orbital type of camera.
  91110. *
  91111. * 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.
  91112. * 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.
  91113. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91114. */
  91115. export class ArcRotateCamera extends TargetCamera {
  91116. /**
  91117. * Defines the rotation angle of the camera along the longitudinal axis.
  91118. */
  91119. alpha: number;
  91120. /**
  91121. * Defines the rotation angle of the camera along the latitudinal axis.
  91122. */
  91123. beta: number;
  91124. /**
  91125. * Defines the radius of the camera from it s target point.
  91126. */
  91127. radius: number;
  91128. protected _target: Vector3;
  91129. protected _targetHost: Nullable<AbstractMesh>;
  91130. /**
  91131. * Defines the target point of the camera.
  91132. * The camera looks towards it form the radius distance.
  91133. */
  91134. target: Vector3;
  91135. /**
  91136. * Current inertia value on the longitudinal axis.
  91137. * The bigger this number the longer it will take for the camera to stop.
  91138. */
  91139. inertialAlphaOffset: number;
  91140. /**
  91141. * Current inertia value on the latitudinal axis.
  91142. * The bigger this number the longer it will take for the camera to stop.
  91143. */
  91144. inertialBetaOffset: number;
  91145. /**
  91146. * Current inertia value on the radius axis.
  91147. * The bigger this number the longer it will take for the camera to stop.
  91148. */
  91149. inertialRadiusOffset: number;
  91150. /**
  91151. * Minimum allowed angle on the longitudinal axis.
  91152. * This can help limiting how the Camera is able to move in the scene.
  91153. */
  91154. lowerAlphaLimit: Nullable<number>;
  91155. /**
  91156. * Maximum allowed angle on the longitudinal axis.
  91157. * This can help limiting how the Camera is able to move in the scene.
  91158. */
  91159. upperAlphaLimit: Nullable<number>;
  91160. /**
  91161. * Minimum allowed angle on the latitudinal axis.
  91162. * This can help limiting how the Camera is able to move in the scene.
  91163. */
  91164. lowerBetaLimit: number;
  91165. /**
  91166. * Maximum allowed angle on the latitudinal axis.
  91167. * This can help limiting how the Camera is able to move in the scene.
  91168. */
  91169. upperBetaLimit: number;
  91170. /**
  91171. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91172. * This can help limiting how the Camera is able to move in the scene.
  91173. */
  91174. lowerRadiusLimit: Nullable<number>;
  91175. /**
  91176. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91177. * This can help limiting how the Camera is able to move in the scene.
  91178. */
  91179. upperRadiusLimit: Nullable<number>;
  91180. /**
  91181. * Defines the current inertia value used during panning of the camera along the X axis.
  91182. */
  91183. inertialPanningX: number;
  91184. /**
  91185. * Defines the current inertia value used during panning of the camera along the Y axis.
  91186. */
  91187. inertialPanningY: number;
  91188. /**
  91189. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91190. * Basically if your fingers moves away from more than this distance you will be considered
  91191. * in pinch mode.
  91192. */
  91193. pinchToPanMaxDistance: number;
  91194. /**
  91195. * Defines the maximum distance the camera can pan.
  91196. * This could help keeping the cammera always in your scene.
  91197. */
  91198. panningDistanceLimit: Nullable<number>;
  91199. /**
  91200. * Defines the target of the camera before paning.
  91201. */
  91202. panningOriginTarget: Vector3;
  91203. /**
  91204. * Defines the value of the inertia used during panning.
  91205. * 0 would mean stop inertia and one would mean no decelleration at all.
  91206. */
  91207. panningInertia: number;
  91208. /**
  91209. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91210. */
  91211. angularSensibilityX: number;
  91212. /**
  91213. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91214. */
  91215. angularSensibilityY: number;
  91216. /**
  91217. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91218. */
  91219. pinchPrecision: number;
  91220. /**
  91221. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91222. * It will be used instead of pinchDeltaPrecision if different from 0.
  91223. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91224. */
  91225. pinchDeltaPercentage: number;
  91226. /**
  91227. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91228. */
  91229. panningSensibility: number;
  91230. /**
  91231. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91232. */
  91233. keysUp: number[];
  91234. /**
  91235. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91236. */
  91237. keysDown: number[];
  91238. /**
  91239. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91240. */
  91241. keysLeft: number[];
  91242. /**
  91243. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91244. */
  91245. keysRight: number[];
  91246. /**
  91247. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91248. */
  91249. wheelPrecision: number;
  91250. /**
  91251. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91252. * It will be used instead of pinchDeltaPrecision if different from 0.
  91253. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91254. */
  91255. wheelDeltaPercentage: number;
  91256. /**
  91257. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91258. */
  91259. zoomOnFactor: number;
  91260. /**
  91261. * Defines a screen offset for the camera position.
  91262. */
  91263. targetScreenOffset: Vector2;
  91264. /**
  91265. * Allows the camera to be completely reversed.
  91266. * If false the camera can not arrive upside down.
  91267. */
  91268. allowUpsideDown: boolean;
  91269. /**
  91270. * Define if double tap/click is used to restore the previously saved state of the camera.
  91271. */
  91272. useInputToRestoreState: boolean;
  91273. /** @hidden */
  91274. _viewMatrix: Matrix;
  91275. /** @hidden */
  91276. _useCtrlForPanning: boolean;
  91277. /** @hidden */
  91278. _panningMouseButton: number;
  91279. /**
  91280. * Defines the input associated to the camera.
  91281. */
  91282. inputs: ArcRotateCameraInputsManager;
  91283. /** @hidden */
  91284. _reset: () => void;
  91285. /**
  91286. * Defines the allowed panning axis.
  91287. */
  91288. panningAxis: Vector3;
  91289. protected _localDirection: Vector3;
  91290. protected _transformedDirection: Vector3;
  91291. private _bouncingBehavior;
  91292. /**
  91293. * Gets the bouncing behavior of the camera if it has been enabled.
  91294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91295. */
  91296. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91297. /**
  91298. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91300. */
  91301. useBouncingBehavior: boolean;
  91302. private _framingBehavior;
  91303. /**
  91304. * Gets the framing behavior of the camera if it has been enabled.
  91305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91306. */
  91307. readonly framingBehavior: Nullable<FramingBehavior>;
  91308. /**
  91309. * Defines if the framing behavior of the camera is enabled on the camera.
  91310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91311. */
  91312. useFramingBehavior: boolean;
  91313. private _autoRotationBehavior;
  91314. /**
  91315. * Gets the auto rotation behavior of the camera if it has been enabled.
  91316. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91317. */
  91318. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91319. /**
  91320. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91322. */
  91323. useAutoRotationBehavior: boolean;
  91324. /**
  91325. * Observable triggered when the mesh target has been changed on the camera.
  91326. */
  91327. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91328. /**
  91329. * Event raised when the camera is colliding with a mesh.
  91330. */
  91331. onCollide: (collidedMesh: AbstractMesh) => void;
  91332. /**
  91333. * Defines whether the camera should check collision with the objects oh the scene.
  91334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91335. */
  91336. checkCollisions: boolean;
  91337. /**
  91338. * Defines the collision radius of the camera.
  91339. * This simulates a sphere around the camera.
  91340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91341. */
  91342. collisionRadius: Vector3;
  91343. protected _collider: Collider;
  91344. protected _previousPosition: Vector3;
  91345. protected _collisionVelocity: Vector3;
  91346. protected _newPosition: Vector3;
  91347. protected _previousAlpha: number;
  91348. protected _previousBeta: number;
  91349. protected _previousRadius: number;
  91350. protected _collisionTriggered: boolean;
  91351. protected _targetBoundingCenter: Nullable<Vector3>;
  91352. private _computationVector;
  91353. private _tempAxisVector;
  91354. private _tempAxisRotationMatrix;
  91355. /**
  91356. * Instantiates a new ArcRotateCamera in a given scene
  91357. * @param name Defines the name of the camera
  91358. * @param alpha Defines the camera rotation along the logitudinal axis
  91359. * @param beta Defines the camera rotation along the latitudinal axis
  91360. * @param radius Defines the camera distance from its target
  91361. * @param target Defines the camera target
  91362. * @param scene Defines the scene the camera belongs to
  91363. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91364. */
  91365. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91366. /** @hidden */
  91367. _initCache(): void;
  91368. /** @hidden */
  91369. _updateCache(ignoreParentClass?: boolean): void;
  91370. protected _getTargetPosition(): Vector3;
  91371. private _storedAlpha;
  91372. private _storedBeta;
  91373. private _storedRadius;
  91374. private _storedTarget;
  91375. /**
  91376. * Stores the current state of the camera (alpha, beta, radius and target)
  91377. * @returns the camera itself
  91378. */
  91379. storeState(): Camera;
  91380. /**
  91381. * @hidden
  91382. * Restored camera state. You must call storeState() first
  91383. */
  91384. _restoreStateValues(): boolean;
  91385. /** @hidden */
  91386. _isSynchronizedViewMatrix(): boolean;
  91387. /**
  91388. * Attached controls to the current camera.
  91389. * @param element Defines the element the controls should be listened from
  91390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91391. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91392. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91393. */
  91394. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91395. /**
  91396. * Detach the current controls from the camera.
  91397. * The camera will stop reacting to inputs.
  91398. * @param element Defines the element to stop listening the inputs from
  91399. */
  91400. detachControl(element: HTMLElement): void;
  91401. /** @hidden */
  91402. _checkInputs(): void;
  91403. protected _checkLimits(): void;
  91404. /**
  91405. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  91406. */
  91407. rebuildAnglesAndRadius(): void;
  91408. /**
  91409. * Use a position to define the current camera related information like aplha, beta and radius
  91410. * @param position Defines the position to set the camera at
  91411. */
  91412. setPosition(position: Vector3): void;
  91413. /**
  91414. * Defines the target the camera should look at.
  91415. * This will automatically adapt alpha beta and radius to fit within the new target.
  91416. * @param target Defines the new target as a Vector or a mesh
  91417. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91418. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91419. */
  91420. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91421. /** @hidden */
  91422. _getViewMatrix(): Matrix;
  91423. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91424. /**
  91425. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91426. * @param meshes Defines the mesh to zoom on
  91427. * @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)
  91428. */
  91429. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91430. /**
  91431. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91432. * The target will be changed but the radius
  91433. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91434. * @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)
  91435. */
  91436. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91437. min: Vector3;
  91438. max: Vector3;
  91439. distance: number;
  91440. }, doNotUpdateMaxZ?: boolean): void;
  91441. /**
  91442. * @override
  91443. * Override Camera.createRigCamera
  91444. */
  91445. createRigCamera(name: string, cameraIndex: number): Camera;
  91446. /**
  91447. * @hidden
  91448. * @override
  91449. * Override Camera._updateRigCameras
  91450. */
  91451. _updateRigCameras(): void;
  91452. /**
  91453. * Destroy the camera and release the current resources hold by it.
  91454. */
  91455. dispose(): void;
  91456. /**
  91457. * Gets the current object class name.
  91458. * @return the class name
  91459. */
  91460. getClassName(): string;
  91461. }
  91462. }
  91463. declare module BABYLON {
  91464. /**
  91465. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91467. */
  91468. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91469. /**
  91470. * Gets the name of the behavior.
  91471. */
  91472. readonly name: string;
  91473. private _zoomStopsAnimation;
  91474. private _idleRotationSpeed;
  91475. private _idleRotationWaitTime;
  91476. private _idleRotationSpinupTime;
  91477. /**
  91478. * Sets the flag that indicates if user zooming should stop animation.
  91479. */
  91480. /**
  91481. * Gets the flag that indicates if user zooming should stop animation.
  91482. */
  91483. zoomStopsAnimation: boolean;
  91484. /**
  91485. * Sets the default speed at which the camera rotates around the model.
  91486. */
  91487. /**
  91488. * Gets the default speed at which the camera rotates around the model.
  91489. */
  91490. idleRotationSpeed: number;
  91491. /**
  91492. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91493. */
  91494. /**
  91495. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91496. */
  91497. idleRotationWaitTime: number;
  91498. /**
  91499. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91500. */
  91501. /**
  91502. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91503. */
  91504. idleRotationSpinupTime: number;
  91505. /**
  91506. * Gets a value indicating if the camera is currently rotating because of this behavior
  91507. */
  91508. readonly rotationInProgress: boolean;
  91509. private _onPrePointerObservableObserver;
  91510. private _onAfterCheckInputsObserver;
  91511. private _attachedCamera;
  91512. private _isPointerDown;
  91513. private _lastFrameTime;
  91514. private _lastInteractionTime;
  91515. private _cameraRotationSpeed;
  91516. /**
  91517. * Initializes the behavior.
  91518. */
  91519. init(): void;
  91520. /**
  91521. * Attaches the behavior to its arc rotate camera.
  91522. * @param camera Defines the camera to attach the behavior to
  91523. */
  91524. attach(camera: ArcRotateCamera): void;
  91525. /**
  91526. * Detaches the behavior from its current arc rotate camera.
  91527. */
  91528. detach(): void;
  91529. /**
  91530. * Returns true if user is scrolling.
  91531. * @return true if user is scrolling.
  91532. */
  91533. private _userIsZooming;
  91534. private _lastFrameRadius;
  91535. private _shouldAnimationStopForInteraction;
  91536. /**
  91537. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91538. */
  91539. private _applyUserInteraction;
  91540. private _userIsMoving;
  91541. }
  91542. }
  91543. declare module BABYLON {
  91544. /**
  91545. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  91546. */
  91547. export class AttachToBoxBehavior implements Behavior<Mesh> {
  91548. private ui;
  91549. /**
  91550. * The name of the behavior
  91551. */
  91552. name: string;
  91553. /**
  91554. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  91555. */
  91556. distanceAwayFromFace: number;
  91557. /**
  91558. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  91559. */
  91560. distanceAwayFromBottomOfFace: number;
  91561. private _faceVectors;
  91562. private _target;
  91563. private _scene;
  91564. private _onRenderObserver;
  91565. private _tmpMatrix;
  91566. private _tmpVector;
  91567. /**
  91568. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  91569. * @param ui The transform node that should be attched to the mesh
  91570. */
  91571. constructor(ui: TransformNode);
  91572. /**
  91573. * Initializes the behavior
  91574. */
  91575. init(): void;
  91576. private _closestFace;
  91577. private _zeroVector;
  91578. private _lookAtTmpMatrix;
  91579. private _lookAtToRef;
  91580. /**
  91581. * Attaches the AttachToBoxBehavior to the passed in mesh
  91582. * @param target The mesh that the specified node will be attached to
  91583. */
  91584. attach(target: Mesh): void;
  91585. /**
  91586. * Detaches the behavior from the mesh
  91587. */
  91588. detach(): void;
  91589. }
  91590. }
  91591. declare module BABYLON {
  91592. /**
  91593. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  91594. */
  91595. export class FadeInOutBehavior implements Behavior<Mesh> {
  91596. /**
  91597. * Time in milliseconds to delay before fading in (Default: 0)
  91598. */
  91599. delay: number;
  91600. /**
  91601. * Time in milliseconds for the mesh to fade in (Default: 300)
  91602. */
  91603. fadeInTime: number;
  91604. private _millisecondsPerFrame;
  91605. private _hovered;
  91606. private _hoverValue;
  91607. private _ownerNode;
  91608. /**
  91609. * Instatiates the FadeInOutBehavior
  91610. */
  91611. constructor();
  91612. /**
  91613. * The name of the behavior
  91614. */
  91615. readonly name: string;
  91616. /**
  91617. * Initializes the behavior
  91618. */
  91619. init(): void;
  91620. /**
  91621. * Attaches the fade behavior on the passed in mesh
  91622. * @param ownerNode The mesh that will be faded in/out once attached
  91623. */
  91624. attach(ownerNode: Mesh): void;
  91625. /**
  91626. * Detaches the behavior from the mesh
  91627. */
  91628. detach(): void;
  91629. /**
  91630. * Triggers the mesh to begin fading in or out
  91631. * @param value if the object should fade in or out (true to fade in)
  91632. */
  91633. fadeIn(value: boolean): void;
  91634. private _update;
  91635. private _setAllVisibility;
  91636. }
  91637. }
  91638. declare module BABYLON {
  91639. /**
  91640. * Class containing a set of static utilities functions for managing Pivots
  91641. * @hidden
  91642. */
  91643. export class PivotTools {
  91644. private static _PivotCached;
  91645. private static _OldPivotPoint;
  91646. private static _PivotTranslation;
  91647. private static _PivotTmpVector;
  91648. /** @hidden */
  91649. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  91650. /** @hidden */
  91651. static _RestorePivotPoint(mesh: AbstractMesh): void;
  91652. }
  91653. }
  91654. declare module BABYLON {
  91655. /**
  91656. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91657. */
  91658. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91659. private static _AnyMouseID;
  91660. private _attachedNode;
  91661. private _dragPlane;
  91662. private _scene;
  91663. private _pointerObserver;
  91664. private _beforeRenderObserver;
  91665. private static _planeScene;
  91666. /**
  91667. * 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)
  91668. */
  91669. maxDragAngle: number;
  91670. /**
  91671. * @hidden
  91672. */
  91673. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91674. /**
  91675. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91676. */
  91677. currentDraggingPointerID: number;
  91678. /**
  91679. * The last position where the pointer hit the drag plane in world space
  91680. */
  91681. lastDragPosition: Vector3;
  91682. /**
  91683. * If the behavior is currently in a dragging state
  91684. */
  91685. dragging: boolean;
  91686. /**
  91687. * 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)
  91688. */
  91689. dragDeltaRatio: number;
  91690. /**
  91691. * If the drag plane orientation should be updated during the dragging (Default: true)
  91692. */
  91693. updateDragPlane: boolean;
  91694. private _debugMode;
  91695. private _moving;
  91696. /**
  91697. * Fires each time the attached mesh is dragged with the pointer
  91698. * * delta between last drag position and current drag position in world space
  91699. * * dragDistance along the drag axis
  91700. * * dragPlaneNormal normal of the current drag plane used during the drag
  91701. * * dragPlanePoint in world space where the drag intersects the drag plane
  91702. */
  91703. onDragObservable: Observable<{
  91704. delta: Vector3;
  91705. dragPlanePoint: Vector3;
  91706. dragPlaneNormal: Vector3;
  91707. dragDistance: number;
  91708. pointerId: number;
  91709. }>;
  91710. /**
  91711. * Fires each time a drag begins (eg. mouse down on mesh)
  91712. */
  91713. onDragStartObservable: Observable<{
  91714. dragPlanePoint: Vector3;
  91715. pointerId: number;
  91716. }>;
  91717. /**
  91718. * Fires each time a drag ends (eg. mouse release after drag)
  91719. */
  91720. onDragEndObservable: Observable<{
  91721. dragPlanePoint: Vector3;
  91722. pointerId: number;
  91723. }>;
  91724. /**
  91725. * If the attached mesh should be moved when dragged
  91726. */
  91727. moveAttached: boolean;
  91728. /**
  91729. * If the drag behavior will react to drag events (Default: true)
  91730. */
  91731. enabled: boolean;
  91732. /**
  91733. * If camera controls should be detached during the drag
  91734. */
  91735. detachCameraControls: boolean;
  91736. /**
  91737. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91738. */
  91739. useObjectOrienationForDragging: boolean;
  91740. private _options;
  91741. /**
  91742. * Creates a pointer drag behavior that can be attached to a mesh
  91743. * @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)
  91744. */
  91745. constructor(options?: {
  91746. dragAxis?: Vector3;
  91747. dragPlaneNormal?: Vector3;
  91748. });
  91749. /**
  91750. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91751. */
  91752. validateDrag: (targetPosition: Vector3) => boolean;
  91753. /**
  91754. * The name of the behavior
  91755. */
  91756. readonly name: string;
  91757. /**
  91758. * Initializes the behavior
  91759. */
  91760. init(): void;
  91761. private _tmpVector;
  91762. private _alternatePickedPoint;
  91763. private _worldDragAxis;
  91764. private _targetPosition;
  91765. private _attachedElement;
  91766. /**
  91767. * Attaches the drag behavior the passed in mesh
  91768. * @param ownerNode The mesh that will be dragged around once attached
  91769. */
  91770. attach(ownerNode: AbstractMesh): void;
  91771. /**
  91772. * Force relase the drag action by code.
  91773. */
  91774. releaseDrag(): void;
  91775. private _startDragRay;
  91776. private _lastPointerRay;
  91777. /**
  91778. * Simulates the start of a pointer drag event on the behavior
  91779. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91780. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91781. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91782. */
  91783. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91784. private _startDrag;
  91785. private _dragDelta;
  91786. private _moveDrag;
  91787. private _pickWithRayOnDragPlane;
  91788. private _pointA;
  91789. private _pointB;
  91790. private _pointC;
  91791. private _lineA;
  91792. private _lineB;
  91793. private _localAxis;
  91794. private _lookAt;
  91795. private _updateDragPlanePosition;
  91796. /**
  91797. * Detaches the behavior from the mesh
  91798. */
  91799. detach(): void;
  91800. }
  91801. }
  91802. declare module BABYLON {
  91803. /**
  91804. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91805. */
  91806. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91807. private _dragBehaviorA;
  91808. private _dragBehaviorB;
  91809. private _startDistance;
  91810. private _initialScale;
  91811. private _targetScale;
  91812. private _ownerNode;
  91813. private _sceneRenderObserver;
  91814. /**
  91815. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91816. */
  91817. constructor();
  91818. /**
  91819. * The name of the behavior
  91820. */
  91821. readonly name: string;
  91822. /**
  91823. * Initializes the behavior
  91824. */
  91825. init(): void;
  91826. private _getCurrentDistance;
  91827. /**
  91828. * Attaches the scale behavior the passed in mesh
  91829. * @param ownerNode The mesh that will be scaled around once attached
  91830. */
  91831. attach(ownerNode: Mesh): void;
  91832. /**
  91833. * Detaches the behavior from the mesh
  91834. */
  91835. detach(): void;
  91836. }
  91837. }
  91838. declare module BABYLON {
  91839. /**
  91840. * 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
  91841. */
  91842. export class SixDofDragBehavior implements Behavior<Mesh> {
  91843. private static _virtualScene;
  91844. private _ownerNode;
  91845. private _sceneRenderObserver;
  91846. private _scene;
  91847. private _targetPosition;
  91848. private _virtualOriginMesh;
  91849. private _virtualDragMesh;
  91850. private _pointerObserver;
  91851. private _moving;
  91852. private _startingOrientation;
  91853. /**
  91854. * 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)
  91855. */
  91856. private zDragFactor;
  91857. /**
  91858. * If the object should rotate to face the drag origin
  91859. */
  91860. rotateDraggedObject: boolean;
  91861. /**
  91862. * If the behavior is currently in a dragging state
  91863. */
  91864. dragging: boolean;
  91865. /**
  91866. * 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)
  91867. */
  91868. dragDeltaRatio: number;
  91869. /**
  91870. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91871. */
  91872. currentDraggingPointerID: number;
  91873. /**
  91874. * If camera controls should be detached during the drag
  91875. */
  91876. detachCameraControls: boolean;
  91877. /**
  91878. * Fires each time a drag starts
  91879. */
  91880. onDragStartObservable: Observable<{}>;
  91881. /**
  91882. * Fires each time a drag ends (eg. mouse release after drag)
  91883. */
  91884. onDragEndObservable: Observable<{}>;
  91885. /**
  91886. * 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
  91887. */
  91888. constructor();
  91889. /**
  91890. * The name of the behavior
  91891. */
  91892. readonly name: string;
  91893. /**
  91894. * Initializes the behavior
  91895. */
  91896. init(): void;
  91897. /**
  91898. * Attaches the scale behavior the passed in mesh
  91899. * @param ownerNode The mesh that will be scaled around once attached
  91900. */
  91901. attach(ownerNode: Mesh): void;
  91902. /**
  91903. * Detaches the behavior from the mesh
  91904. */
  91905. detach(): void;
  91906. }
  91907. }
  91908. declare module BABYLON {
  91909. /**
  91910. * Class used to apply inverse kinematics to bones
  91911. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91912. */
  91913. export class BoneIKController {
  91914. private static _tmpVecs;
  91915. private static _tmpQuat;
  91916. private static _tmpMats;
  91917. /**
  91918. * Gets or sets the target mesh
  91919. */
  91920. targetMesh: AbstractMesh;
  91921. /** Gets or sets the mesh used as pole */
  91922. poleTargetMesh: AbstractMesh;
  91923. /**
  91924. * Gets or sets the bone used as pole
  91925. */
  91926. poleTargetBone: Nullable<Bone>;
  91927. /**
  91928. * Gets or sets the target position
  91929. */
  91930. targetPosition: Vector3;
  91931. /**
  91932. * Gets or sets the pole target position
  91933. */
  91934. poleTargetPosition: Vector3;
  91935. /**
  91936. * Gets or sets the pole target local offset
  91937. */
  91938. poleTargetLocalOffset: Vector3;
  91939. /**
  91940. * Gets or sets the pole angle
  91941. */
  91942. poleAngle: number;
  91943. /**
  91944. * Gets or sets the mesh associated with the controller
  91945. */
  91946. mesh: AbstractMesh;
  91947. /**
  91948. * 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)
  91949. */
  91950. slerpAmount: number;
  91951. private _bone1Quat;
  91952. private _bone1Mat;
  91953. private _bone2Ang;
  91954. private _bone1;
  91955. private _bone2;
  91956. private _bone1Length;
  91957. private _bone2Length;
  91958. private _maxAngle;
  91959. private _maxReach;
  91960. private _rightHandedSystem;
  91961. private _bendAxis;
  91962. private _slerping;
  91963. private _adjustRoll;
  91964. /**
  91965. * Gets or sets maximum allowed angle
  91966. */
  91967. maxAngle: number;
  91968. /**
  91969. * Creates a new BoneIKController
  91970. * @param mesh defines the mesh to control
  91971. * @param bone defines the bone to control
  91972. * @param options defines options to set up the controller
  91973. */
  91974. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91975. targetMesh?: AbstractMesh;
  91976. poleTargetMesh?: AbstractMesh;
  91977. poleTargetBone?: Bone;
  91978. poleTargetLocalOffset?: Vector3;
  91979. poleAngle?: number;
  91980. bendAxis?: Vector3;
  91981. maxAngle?: number;
  91982. slerpAmount?: number;
  91983. });
  91984. private _setMaxAngle;
  91985. /**
  91986. * Force the controller to update the bones
  91987. */
  91988. update(): void;
  91989. }
  91990. }
  91991. declare module BABYLON {
  91992. /**
  91993. * Class used to make a bone look toward a point in space
  91994. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91995. */
  91996. export class BoneLookController {
  91997. private static _tmpVecs;
  91998. private static _tmpQuat;
  91999. private static _tmpMats;
  92000. /**
  92001. * The target Vector3 that the bone will look at
  92002. */
  92003. target: Vector3;
  92004. /**
  92005. * The mesh that the bone is attached to
  92006. */
  92007. mesh: AbstractMesh;
  92008. /**
  92009. * The bone that will be looking to the target
  92010. */
  92011. bone: Bone;
  92012. /**
  92013. * The up axis of the coordinate system that is used when the bone is rotated
  92014. */
  92015. upAxis: Vector3;
  92016. /**
  92017. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92018. */
  92019. upAxisSpace: Space;
  92020. /**
  92021. * Used to make an adjustment to the yaw of the bone
  92022. */
  92023. adjustYaw: number;
  92024. /**
  92025. * Used to make an adjustment to the pitch of the bone
  92026. */
  92027. adjustPitch: number;
  92028. /**
  92029. * Used to make an adjustment to the roll of the bone
  92030. */
  92031. adjustRoll: number;
  92032. /**
  92033. * 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)
  92034. */
  92035. slerpAmount: number;
  92036. private _minYaw;
  92037. private _maxYaw;
  92038. private _minPitch;
  92039. private _maxPitch;
  92040. private _minYawSin;
  92041. private _minYawCos;
  92042. private _maxYawSin;
  92043. private _maxYawCos;
  92044. private _midYawConstraint;
  92045. private _minPitchTan;
  92046. private _maxPitchTan;
  92047. private _boneQuat;
  92048. private _slerping;
  92049. private _transformYawPitch;
  92050. private _transformYawPitchInv;
  92051. private _firstFrameSkipped;
  92052. private _yawRange;
  92053. private _fowardAxis;
  92054. /**
  92055. * Gets or sets the minimum yaw angle that the bone can look to
  92056. */
  92057. minYaw: number;
  92058. /**
  92059. * Gets or sets the maximum yaw angle that the bone can look to
  92060. */
  92061. maxYaw: number;
  92062. /**
  92063. * Gets or sets the minimum pitch angle that the bone can look to
  92064. */
  92065. minPitch: number;
  92066. /**
  92067. * Gets or sets the maximum pitch angle that the bone can look to
  92068. */
  92069. maxPitch: number;
  92070. /**
  92071. * Create a BoneLookController
  92072. * @param mesh the mesh that the bone belongs to
  92073. * @param bone the bone that will be looking to the target
  92074. * @param target the target Vector3 to look at
  92075. * @param settings optional settings:
  92076. * * maxYaw: the maximum angle the bone will yaw to
  92077. * * minYaw: the minimum angle the bone will yaw to
  92078. * * maxPitch: the maximum angle the bone will pitch to
  92079. * * minPitch: the minimum angle the bone will yaw to
  92080. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92081. * * upAxis: the up axis of the coordinate system
  92082. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92083. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92084. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92085. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92086. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92087. * * adjustRoll: used to make an adjustment to the roll of the bone
  92088. **/
  92089. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92090. maxYaw?: number;
  92091. minYaw?: number;
  92092. maxPitch?: number;
  92093. minPitch?: number;
  92094. slerpAmount?: number;
  92095. upAxis?: Vector3;
  92096. upAxisSpace?: Space;
  92097. yawAxis?: Vector3;
  92098. pitchAxis?: Vector3;
  92099. adjustYaw?: number;
  92100. adjustPitch?: number;
  92101. adjustRoll?: number;
  92102. });
  92103. /**
  92104. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92105. */
  92106. update(): void;
  92107. private _getAngleDiff;
  92108. private _getAngleBetween;
  92109. private _isAngleBetween;
  92110. }
  92111. }
  92112. declare module BABYLON {
  92113. /**
  92114. * Manage the gamepad inputs to control an arc rotate camera.
  92115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92116. */
  92117. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92118. /**
  92119. * Defines the camera the input is attached to.
  92120. */
  92121. camera: ArcRotateCamera;
  92122. /**
  92123. * Defines the gamepad the input is gathering event from.
  92124. */
  92125. gamepad: Nullable<Gamepad>;
  92126. /**
  92127. * Defines the gamepad rotation sensiblity.
  92128. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92129. */
  92130. gamepadRotationSensibility: number;
  92131. /**
  92132. * Defines the gamepad move sensiblity.
  92133. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92134. */
  92135. gamepadMoveSensibility: number;
  92136. private _onGamepadConnectedObserver;
  92137. private _onGamepadDisconnectedObserver;
  92138. /**
  92139. * Attach the input controls to a specific dom element to get the input from.
  92140. * @param element Defines the element the controls should be listened from
  92141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92142. */
  92143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92144. /**
  92145. * Detach the current controls from the specified dom element.
  92146. * @param element Defines the element to stop listening the inputs from
  92147. */
  92148. detachControl(element: Nullable<HTMLElement>): void;
  92149. /**
  92150. * Update the current camera state depending on the inputs that have been used this frame.
  92151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92152. */
  92153. checkInputs(): void;
  92154. /**
  92155. * Gets the class name of the current intput.
  92156. * @returns the class name
  92157. */
  92158. getClassName(): string;
  92159. /**
  92160. * Get the friendly name associated with the input class.
  92161. * @returns the input friendly name
  92162. */
  92163. getSimpleName(): string;
  92164. }
  92165. }
  92166. declare module BABYLON {
  92167. interface ArcRotateCameraInputsManager {
  92168. /**
  92169. * Add orientation input support to the input manager.
  92170. * @returns the current input manager
  92171. */
  92172. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92173. }
  92174. /**
  92175. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92177. */
  92178. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92179. /**
  92180. * Defines the camera the input is attached to.
  92181. */
  92182. camera: ArcRotateCamera;
  92183. /**
  92184. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92185. */
  92186. alphaCorrection: number;
  92187. /**
  92188. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92189. */
  92190. gammaCorrection: number;
  92191. private _alpha;
  92192. private _gamma;
  92193. private _dirty;
  92194. private _deviceOrientationHandler;
  92195. /**
  92196. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92197. */
  92198. constructor();
  92199. /**
  92200. * Attach the input controls to a specific dom element to get the input from.
  92201. * @param element Defines the element the controls should be listened from
  92202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92203. */
  92204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92205. /** @hidden */
  92206. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92207. /**
  92208. * Update the current camera state depending on the inputs that have been used this frame.
  92209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92210. */
  92211. checkInputs(): void;
  92212. /**
  92213. * Detach the current controls from the specified dom element.
  92214. * @param element Defines the element to stop listening the inputs from
  92215. */
  92216. detachControl(element: Nullable<HTMLElement>): void;
  92217. /**
  92218. * Gets the class name of the current intput.
  92219. * @returns the class name
  92220. */
  92221. getClassName(): string;
  92222. /**
  92223. * Get the friendly name associated with the input class.
  92224. * @returns the input friendly name
  92225. */
  92226. getSimpleName(): string;
  92227. }
  92228. }
  92229. declare module BABYLON {
  92230. /**
  92231. * Listen to mouse events to control the camera.
  92232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92233. */
  92234. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92235. /**
  92236. * Defines the camera the input is attached to.
  92237. */
  92238. camera: FlyCamera;
  92239. /**
  92240. * Defines if touch is enabled. (Default is true.)
  92241. */
  92242. touchEnabled: boolean;
  92243. /**
  92244. * Defines the buttons associated with the input to handle camera rotation.
  92245. */
  92246. buttons: number[];
  92247. /**
  92248. * Assign buttons for Yaw control.
  92249. */
  92250. buttonsYaw: number[];
  92251. /**
  92252. * Assign buttons for Pitch control.
  92253. */
  92254. buttonsPitch: number[];
  92255. /**
  92256. * Assign buttons for Roll control.
  92257. */
  92258. buttonsRoll: number[];
  92259. /**
  92260. * Detect if any button is being pressed while mouse is moved.
  92261. * -1 = Mouse locked.
  92262. * 0 = Left button.
  92263. * 1 = Middle Button.
  92264. * 2 = Right Button.
  92265. */
  92266. activeButton: number;
  92267. /**
  92268. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92269. * Higher values reduce its sensitivity.
  92270. */
  92271. angularSensibility: number;
  92272. private _mousemoveCallback;
  92273. private _observer;
  92274. private _rollObserver;
  92275. private previousPosition;
  92276. private noPreventDefault;
  92277. private element;
  92278. /**
  92279. * Listen to mouse events to control the camera.
  92280. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92282. */
  92283. constructor(touchEnabled?: boolean);
  92284. /**
  92285. * Attach the mouse control to the HTML DOM element.
  92286. * @param element Defines the element that listens to the input events.
  92287. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92288. */
  92289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92290. /**
  92291. * Detach the current controls from the specified dom element.
  92292. * @param element Defines the element to stop listening the inputs from
  92293. */
  92294. detachControl(element: Nullable<HTMLElement>): void;
  92295. /**
  92296. * Gets the class name of the current input.
  92297. * @returns the class name.
  92298. */
  92299. getClassName(): string;
  92300. /**
  92301. * Get the friendly name associated with the input class.
  92302. * @returns the input's friendly name.
  92303. */
  92304. getSimpleName(): string;
  92305. private _pointerInput;
  92306. private _onMouseMove;
  92307. /**
  92308. * Rotate camera by mouse offset.
  92309. */
  92310. private rotateCamera;
  92311. }
  92312. }
  92313. declare module BABYLON {
  92314. /**
  92315. * Default Inputs manager for the FlyCamera.
  92316. * It groups all the default supported inputs for ease of use.
  92317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92318. */
  92319. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92320. /**
  92321. * Instantiates a new FlyCameraInputsManager.
  92322. * @param camera Defines the camera the inputs belong to.
  92323. */
  92324. constructor(camera: FlyCamera);
  92325. /**
  92326. * Add keyboard input support to the input manager.
  92327. * @returns the new FlyCameraKeyboardMoveInput().
  92328. */
  92329. addKeyboard(): FlyCameraInputsManager;
  92330. /**
  92331. * Add mouse input support to the input manager.
  92332. * @param touchEnabled Enable touch screen support.
  92333. * @returns the new FlyCameraMouseInput().
  92334. */
  92335. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92336. }
  92337. }
  92338. declare module BABYLON {
  92339. /**
  92340. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92341. * such as in a 3D Space Shooter or a Flight Simulator.
  92342. */
  92343. export class FlyCamera extends TargetCamera {
  92344. /**
  92345. * Define the collision ellipsoid of the camera.
  92346. * This is helpful for simulating a camera body, like a player's body.
  92347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92348. */
  92349. ellipsoid: Vector3;
  92350. /**
  92351. * Define an offset for the position of the ellipsoid around the camera.
  92352. * This can be helpful if the camera is attached away from the player's body center,
  92353. * such as at its head.
  92354. */
  92355. ellipsoidOffset: Vector3;
  92356. /**
  92357. * Enable or disable collisions of the camera with the rest of the scene objects.
  92358. */
  92359. checkCollisions: boolean;
  92360. /**
  92361. * Enable or disable gravity on the camera.
  92362. */
  92363. applyGravity: boolean;
  92364. /**
  92365. * Define the current direction the camera is moving to.
  92366. */
  92367. cameraDirection: Vector3;
  92368. /**
  92369. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92370. * This overrides and empties cameraRotation.
  92371. */
  92372. rotationQuaternion: Quaternion;
  92373. /**
  92374. * Track Roll to maintain the wanted Rolling when looking around.
  92375. */
  92376. _trackRoll: number;
  92377. /**
  92378. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92379. */
  92380. rollCorrect: number;
  92381. /**
  92382. * Mimic a banked turn, Rolling the camera when Yawing.
  92383. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92384. */
  92385. bankedTurn: boolean;
  92386. /**
  92387. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92388. */
  92389. bankedTurnLimit: number;
  92390. /**
  92391. * Value of 0 disables the banked Roll.
  92392. * Value of 1 is equal to the Yaw angle in radians.
  92393. */
  92394. bankedTurnMultiplier: number;
  92395. /**
  92396. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92397. */
  92398. inputs: FlyCameraInputsManager;
  92399. /**
  92400. * Gets the input sensibility for mouse input.
  92401. * Higher values reduce sensitivity.
  92402. */
  92403. /**
  92404. * Sets the input sensibility for a mouse input.
  92405. * Higher values reduce sensitivity.
  92406. */
  92407. angularSensibility: number;
  92408. /**
  92409. * Get the keys for camera movement forward.
  92410. */
  92411. /**
  92412. * Set the keys for camera movement forward.
  92413. */
  92414. keysForward: number[];
  92415. /**
  92416. * Get the keys for camera movement backward.
  92417. */
  92418. keysBackward: number[];
  92419. /**
  92420. * Get the keys for camera movement up.
  92421. */
  92422. /**
  92423. * Set the keys for camera movement up.
  92424. */
  92425. keysUp: number[];
  92426. /**
  92427. * Get the keys for camera movement down.
  92428. */
  92429. /**
  92430. * Set the keys for camera movement down.
  92431. */
  92432. keysDown: number[];
  92433. /**
  92434. * Get the keys for camera movement left.
  92435. */
  92436. /**
  92437. * Set the keys for camera movement left.
  92438. */
  92439. keysLeft: number[];
  92440. /**
  92441. * Set the keys for camera movement right.
  92442. */
  92443. /**
  92444. * Set the keys for camera movement right.
  92445. */
  92446. keysRight: number[];
  92447. /**
  92448. * Event raised when the camera collides with a mesh in the scene.
  92449. */
  92450. onCollide: (collidedMesh: AbstractMesh) => void;
  92451. private _collider;
  92452. private _needMoveForGravity;
  92453. private _oldPosition;
  92454. private _diffPosition;
  92455. private _newPosition;
  92456. /** @hidden */
  92457. _localDirection: Vector3;
  92458. /** @hidden */
  92459. _transformedDirection: Vector3;
  92460. /**
  92461. * Instantiates a FlyCamera.
  92462. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92463. * such as in a 3D Space Shooter or a Flight Simulator.
  92464. * @param name Define the name of the camera in the scene.
  92465. * @param position Define the starting position of the camera in the scene.
  92466. * @param scene Define the scene the camera belongs to.
  92467. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92468. */
  92469. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92470. /**
  92471. * Attach a control to the HTML DOM element.
  92472. * @param element Defines the element that listens to the input events.
  92473. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92474. */
  92475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92476. /**
  92477. * Detach a control from the HTML DOM element.
  92478. * The camera will stop reacting to that input.
  92479. * @param element Defines the element that listens to the input events.
  92480. */
  92481. detachControl(element: HTMLElement): void;
  92482. private _collisionMask;
  92483. /**
  92484. * Get the mask that the camera ignores in collision events.
  92485. */
  92486. /**
  92487. * Set the mask that the camera ignores in collision events.
  92488. */
  92489. collisionMask: number;
  92490. /** @hidden */
  92491. _collideWithWorld(displacement: Vector3): void;
  92492. /** @hidden */
  92493. private _onCollisionPositionChange;
  92494. /** @hidden */
  92495. _checkInputs(): void;
  92496. /** @hidden */
  92497. _decideIfNeedsToMove(): boolean;
  92498. /** @hidden */
  92499. _updatePosition(): void;
  92500. /**
  92501. * Restore the Roll to its target value at the rate specified.
  92502. * @param rate - Higher means slower restoring.
  92503. * @hidden
  92504. */
  92505. restoreRoll(rate: number): void;
  92506. /**
  92507. * Destroy the camera and release the current resources held by it.
  92508. */
  92509. dispose(): void;
  92510. /**
  92511. * Get the current object class name.
  92512. * @returns the class name.
  92513. */
  92514. getClassName(): string;
  92515. }
  92516. }
  92517. declare module BABYLON {
  92518. /**
  92519. * Listen to keyboard events to control the camera.
  92520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92521. */
  92522. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  92523. /**
  92524. * Defines the camera the input is attached to.
  92525. */
  92526. camera: FlyCamera;
  92527. /**
  92528. * The list of keyboard keys used to control the forward move of the camera.
  92529. */
  92530. keysForward: number[];
  92531. /**
  92532. * The list of keyboard keys used to control the backward move of the camera.
  92533. */
  92534. keysBackward: number[];
  92535. /**
  92536. * The list of keyboard keys used to control the forward move of the camera.
  92537. */
  92538. keysUp: number[];
  92539. /**
  92540. * The list of keyboard keys used to control the backward move of the camera.
  92541. */
  92542. keysDown: number[];
  92543. /**
  92544. * The list of keyboard keys used to control the right strafe move of the camera.
  92545. */
  92546. keysRight: number[];
  92547. /**
  92548. * The list of keyboard keys used to control the left strafe move of the camera.
  92549. */
  92550. keysLeft: number[];
  92551. private _keys;
  92552. private _onCanvasBlurObserver;
  92553. private _onKeyboardObserver;
  92554. private _engine;
  92555. private _scene;
  92556. /**
  92557. * Attach the input controls to a specific dom element to get the input from.
  92558. * @param element Defines the element the controls should be listened from
  92559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92560. */
  92561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92562. /**
  92563. * Detach the current controls from the specified dom element.
  92564. * @param element Defines the element to stop listening the inputs from
  92565. */
  92566. detachControl(element: Nullable<HTMLElement>): void;
  92567. /**
  92568. * Gets the class name of the current intput.
  92569. * @returns the class name
  92570. */
  92571. getClassName(): string;
  92572. /** @hidden */
  92573. _onLostFocus(e: FocusEvent): void;
  92574. /**
  92575. * Get the friendly name associated with the input class.
  92576. * @returns the input friendly name
  92577. */
  92578. getSimpleName(): string;
  92579. /**
  92580. * Update the current camera state depending on the inputs that have been used this frame.
  92581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92582. */
  92583. checkInputs(): void;
  92584. }
  92585. }
  92586. declare module BABYLON {
  92587. interface FreeCameraInputsManager {
  92588. /**
  92589. * Add orientation input support to the input manager.
  92590. * @returns the current input manager
  92591. */
  92592. addDeviceOrientation(): FreeCameraInputsManager;
  92593. }
  92594. /**
  92595. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  92596. * Screen rotation is taken into account.
  92597. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92598. */
  92599. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  92600. private _camera;
  92601. private _screenOrientationAngle;
  92602. private _constantTranform;
  92603. private _screenQuaternion;
  92604. private _alpha;
  92605. private _beta;
  92606. private _gamma;
  92607. /**
  92608. * Instantiates a new input
  92609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92610. */
  92611. constructor();
  92612. /**
  92613. * Define the camera controlled by the input.
  92614. */
  92615. camera: FreeCamera;
  92616. /**
  92617. * Attach the input controls to a specific dom element to get the input from.
  92618. * @param element Defines the element the controls should be listened from
  92619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92620. */
  92621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92622. private _orientationChanged;
  92623. private _deviceOrientation;
  92624. /**
  92625. * Detach the current controls from the specified dom element.
  92626. * @param element Defines the element to stop listening the inputs from
  92627. */
  92628. detachControl(element: Nullable<HTMLElement>): void;
  92629. /**
  92630. * Update the current camera state depending on the inputs that have been used this frame.
  92631. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92632. */
  92633. checkInputs(): void;
  92634. /**
  92635. * Gets the class name of the current intput.
  92636. * @returns the class name
  92637. */
  92638. getClassName(): string;
  92639. /**
  92640. * Get the friendly name associated with the input class.
  92641. * @returns the input friendly name
  92642. */
  92643. getSimpleName(): string;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * Manage the gamepad inputs to control a free camera.
  92649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92650. */
  92651. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92652. /**
  92653. * Define the camera the input is attached to.
  92654. */
  92655. camera: FreeCamera;
  92656. /**
  92657. * Define the Gamepad controlling the input
  92658. */
  92659. gamepad: Nullable<Gamepad>;
  92660. /**
  92661. * Defines the gamepad rotation sensiblity.
  92662. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92663. */
  92664. gamepadAngularSensibility: number;
  92665. /**
  92666. * Defines the gamepad move sensiblity.
  92667. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92668. */
  92669. gamepadMoveSensibility: number;
  92670. private _onGamepadConnectedObserver;
  92671. private _onGamepadDisconnectedObserver;
  92672. private _cameraTransform;
  92673. private _deltaTransform;
  92674. private _vector3;
  92675. private _vector2;
  92676. /**
  92677. * Attach the input controls to a specific dom element to get the input from.
  92678. * @param element Defines the element the controls should be listened from
  92679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92680. */
  92681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92682. /**
  92683. * Detach the current controls from the specified dom element.
  92684. * @param element Defines the element to stop listening the inputs from
  92685. */
  92686. detachControl(element: Nullable<HTMLElement>): void;
  92687. /**
  92688. * Update the current camera state depending on the inputs that have been used this frame.
  92689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92690. */
  92691. checkInputs(): void;
  92692. /**
  92693. * Gets the class name of the current intput.
  92694. * @returns the class name
  92695. */
  92696. getClassName(): string;
  92697. /**
  92698. * Get the friendly name associated with the input class.
  92699. * @returns the input friendly name
  92700. */
  92701. getSimpleName(): string;
  92702. }
  92703. }
  92704. declare module BABYLON {
  92705. /**
  92706. * Defines the potential axis of a Joystick
  92707. */
  92708. export enum JoystickAxis {
  92709. /** X axis */
  92710. X = 0,
  92711. /** Y axis */
  92712. Y = 1,
  92713. /** Z axis */
  92714. Z = 2
  92715. }
  92716. /**
  92717. * Class used to define virtual joystick (used in touch mode)
  92718. */
  92719. export class VirtualJoystick {
  92720. /**
  92721. * Gets or sets a boolean indicating that left and right values must be inverted
  92722. */
  92723. reverseLeftRight: boolean;
  92724. /**
  92725. * Gets or sets a boolean indicating that up and down values must be inverted
  92726. */
  92727. reverseUpDown: boolean;
  92728. /**
  92729. * Gets the offset value for the position (ie. the change of the position value)
  92730. */
  92731. deltaPosition: Vector3;
  92732. /**
  92733. * Gets a boolean indicating if the virtual joystick was pressed
  92734. */
  92735. pressed: boolean;
  92736. /**
  92737. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92738. */
  92739. static Canvas: Nullable<HTMLCanvasElement>;
  92740. private static _globalJoystickIndex;
  92741. private static vjCanvasContext;
  92742. private static vjCanvasWidth;
  92743. private static vjCanvasHeight;
  92744. private static halfWidth;
  92745. private _action;
  92746. private _axisTargetedByLeftAndRight;
  92747. private _axisTargetedByUpAndDown;
  92748. private _joystickSensibility;
  92749. private _inversedSensibility;
  92750. private _joystickPointerID;
  92751. private _joystickColor;
  92752. private _joystickPointerPos;
  92753. private _joystickPreviousPointerPos;
  92754. private _joystickPointerStartPos;
  92755. private _deltaJoystickVector;
  92756. private _leftJoystick;
  92757. private _touches;
  92758. private _onPointerDownHandlerRef;
  92759. private _onPointerMoveHandlerRef;
  92760. private _onPointerUpHandlerRef;
  92761. private _onResize;
  92762. /**
  92763. * Creates a new virtual joystick
  92764. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92765. */
  92766. constructor(leftJoystick?: boolean);
  92767. /**
  92768. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92769. * @param newJoystickSensibility defines the new sensibility
  92770. */
  92771. setJoystickSensibility(newJoystickSensibility: number): void;
  92772. private _onPointerDown;
  92773. private _onPointerMove;
  92774. private _onPointerUp;
  92775. /**
  92776. * Change the color of the virtual joystick
  92777. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92778. */
  92779. setJoystickColor(newColor: string): void;
  92780. /**
  92781. * Defines a callback to call when the joystick is touched
  92782. * @param action defines the callback
  92783. */
  92784. setActionOnTouch(action: () => any): void;
  92785. /**
  92786. * Defines which axis you'd like to control for left & right
  92787. * @param axis defines the axis to use
  92788. */
  92789. setAxisForLeftRight(axis: JoystickAxis): void;
  92790. /**
  92791. * Defines which axis you'd like to control for up & down
  92792. * @param axis defines the axis to use
  92793. */
  92794. setAxisForUpDown(axis: JoystickAxis): void;
  92795. private _drawVirtualJoystick;
  92796. /**
  92797. * Release internal HTML canvas
  92798. */
  92799. releaseCanvas(): void;
  92800. }
  92801. }
  92802. declare module BABYLON {
  92803. interface FreeCameraInputsManager {
  92804. /**
  92805. * Add virtual joystick input support to the input manager.
  92806. * @returns the current input manager
  92807. */
  92808. addVirtualJoystick(): FreeCameraInputsManager;
  92809. }
  92810. /**
  92811. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92813. */
  92814. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92815. /**
  92816. * Defines the camera the input is attached to.
  92817. */
  92818. camera: FreeCamera;
  92819. private _leftjoystick;
  92820. private _rightjoystick;
  92821. /**
  92822. * Gets the left stick of the virtual joystick.
  92823. * @returns The virtual Joystick
  92824. */
  92825. getLeftJoystick(): VirtualJoystick;
  92826. /**
  92827. * Gets the right stick of the virtual joystick.
  92828. * @returns The virtual Joystick
  92829. */
  92830. getRightJoystick(): VirtualJoystick;
  92831. /**
  92832. * Update the current camera state depending on the inputs that have been used this frame.
  92833. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92834. */
  92835. checkInputs(): void;
  92836. /**
  92837. * Attach the input controls to a specific dom element to get the input from.
  92838. * @param element Defines the element the controls should be listened from
  92839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92840. */
  92841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92842. /**
  92843. * Detach the current controls from the specified dom element.
  92844. * @param element Defines the element to stop listening the inputs from
  92845. */
  92846. detachControl(element: Nullable<HTMLElement>): void;
  92847. /**
  92848. * Gets the class name of the current intput.
  92849. * @returns the class name
  92850. */
  92851. getClassName(): string;
  92852. /**
  92853. * Get the friendly name associated with the input class.
  92854. * @returns the input friendly name
  92855. */
  92856. getSimpleName(): string;
  92857. }
  92858. }
  92859. declare module BABYLON {
  92860. /**
  92861. * This represents a FPS type of camera controlled by touch.
  92862. * This is like a universal camera minus the Gamepad controls.
  92863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92864. */
  92865. export class TouchCamera extends FreeCamera {
  92866. /**
  92867. * Defines the touch sensibility for rotation.
  92868. * The higher the faster.
  92869. */
  92870. touchAngularSensibility: number;
  92871. /**
  92872. * Defines the touch sensibility for move.
  92873. * The higher the faster.
  92874. */
  92875. touchMoveSensibility: number;
  92876. /**
  92877. * Instantiates a new touch camera.
  92878. * This represents a FPS type of camera controlled by touch.
  92879. * This is like a universal camera minus the Gamepad controls.
  92880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92881. * @param name Define the name of the camera in the scene
  92882. * @param position Define the start position of the camera in the scene
  92883. * @param scene Define the scene the camera belongs to
  92884. */
  92885. constructor(name: string, position: Vector3, scene: Scene);
  92886. /**
  92887. * Gets the current object class name.
  92888. * @return the class name
  92889. */
  92890. getClassName(): string;
  92891. /** @hidden */
  92892. _setupInputs(): void;
  92893. }
  92894. }
  92895. declare module BABYLON {
  92896. /**
  92897. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92898. * being tilted forward or back and left or right.
  92899. */
  92900. export class DeviceOrientationCamera extends FreeCamera {
  92901. private _initialQuaternion;
  92902. private _quaternionCache;
  92903. /**
  92904. * Creates a new device orientation camera
  92905. * @param name The name of the camera
  92906. * @param position The start position camera
  92907. * @param scene The scene the camera belongs to
  92908. */
  92909. constructor(name: string, position: Vector3, scene: Scene);
  92910. /**
  92911. * Gets the current instance class name ("DeviceOrientationCamera").
  92912. * This helps avoiding instanceof at run time.
  92913. * @returns the class name
  92914. */
  92915. getClassName(): string;
  92916. /**
  92917. * @hidden
  92918. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92919. */
  92920. _checkInputs(): void;
  92921. /**
  92922. * Reset the camera to its default orientation on the specified axis only.
  92923. * @param axis The axis to reset
  92924. */
  92925. resetToCurrentRotation(axis?: Axis): void;
  92926. }
  92927. }
  92928. declare module BABYLON {
  92929. /**
  92930. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92932. */
  92933. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92934. /**
  92935. * Defines the camera the input is attached to.
  92936. */
  92937. camera: FollowCamera;
  92938. /**
  92939. * Defines the list of key codes associated with the up action (increase heightOffset)
  92940. */
  92941. keysUp: number[];
  92942. /**
  92943. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92944. */
  92945. keysDown: number[];
  92946. /**
  92947. * Defines the list of key codes associated with the left action (increase rotation)
  92948. */
  92949. keysLeft: number[];
  92950. /**
  92951. * Defines the list of key codes associated with the right action (decrease rotation)
  92952. */
  92953. keysRight: number[];
  92954. /**
  92955. * Defines the rate of change of heightOffset.
  92956. */
  92957. heightSensibility: number;
  92958. /**
  92959. * Defines the rate of change of rotationOffset.
  92960. */
  92961. rotationSensibility: number;
  92962. /**
  92963. * Defines the rate of change of radius.
  92964. */
  92965. radiusSensibility: number;
  92966. /**
  92967. * Defines the minimum heightOffset value.
  92968. */
  92969. minHeightOffset: number;
  92970. /**
  92971. * Defines the minimum radius value.
  92972. */
  92973. minRadius: number;
  92974. private _keys;
  92975. private _altPressed;
  92976. private _onCanvasBlurObserver;
  92977. private _onKeyboardObserver;
  92978. private _engine;
  92979. private _scene;
  92980. /**
  92981. * Attach the input controls to a specific dom element to get the input from.
  92982. * @param element Defines the element the controls should be listened from
  92983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92984. */
  92985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92986. /**
  92987. * Detach the current controls from the specified dom element.
  92988. * @param element Defines the element to stop listening the inputs from
  92989. */
  92990. detachControl(element: Nullable<HTMLElement>): void;
  92991. /**
  92992. * Update the current camera state depending on the inputs that have been used this frame.
  92993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92994. */
  92995. checkInputs(): void;
  92996. /**
  92997. * Gets the class name of the current intput.
  92998. * @returns the class name
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Get the friendly name associated with the input class.
  93003. * @returns the input friendly name
  93004. */
  93005. getSimpleName(): string;
  93006. }
  93007. }
  93008. declare module BABYLON {
  93009. /**
  93010. * Manage the mouse wheel inputs to control a follow camera.
  93011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93012. */
  93013. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93014. /**
  93015. * Defines the camera the input is attached to.
  93016. */
  93017. camera: FollowCamera;
  93018. /**
  93019. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  93020. */
  93021. axisControlRadius: boolean;
  93022. /**
  93023. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  93024. */
  93025. axisControlHeight: boolean;
  93026. /**
  93027. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  93028. */
  93029. axisControlRotation: boolean;
  93030. /**
  93031. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93032. * relation to mouseWheel events.
  93033. */
  93034. wheelPrecision: number;
  93035. /**
  93036. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93037. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93038. */
  93039. wheelDeltaPercentage: number;
  93040. private _wheel;
  93041. private _observer;
  93042. /**
  93043. * Attach the input controls to a specific dom element to get the input from.
  93044. * @param element Defines the element the controls should be listened from
  93045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93046. */
  93047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93048. /**
  93049. * Detach the current controls from the specified dom element.
  93050. * @param element Defines the element to stop listening the inputs from
  93051. */
  93052. detachControl(element: Nullable<HTMLElement>): void;
  93053. /**
  93054. * Gets the class name of the current intput.
  93055. * @returns the class name
  93056. */
  93057. getClassName(): string;
  93058. /**
  93059. * Get the friendly name associated with the input class.
  93060. * @returns the input friendly name
  93061. */
  93062. getSimpleName(): string;
  93063. }
  93064. }
  93065. declare module BABYLON {
  93066. /**
  93067. * Default Inputs manager for the FollowCamera.
  93068. * It groups all the default supported inputs for ease of use.
  93069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93070. */
  93071. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93072. /**
  93073. * Instantiates a new FollowCameraInputsManager.
  93074. * @param camera Defines the camera the inputs belong to
  93075. */
  93076. constructor(camera: FollowCamera);
  93077. /**
  93078. * Add keyboard input support to the input manager.
  93079. * @returns the current input manager
  93080. */
  93081. addKeyboard(): FollowCameraInputsManager;
  93082. /**
  93083. * Add mouse wheel input support to the input manager.
  93084. * @returns the current input manager
  93085. */
  93086. addMouseWheel(): FollowCameraInputsManager;
  93087. /**
  93088. * Add pointers input support to the input manager.
  93089. * @returns the current input manager
  93090. */
  93091. addPointers(): FollowCameraInputsManager;
  93092. /**
  93093. * Add orientation input support to the input manager.
  93094. * @returns the current input manager
  93095. */
  93096. addVRDeviceOrientation(): FollowCameraInputsManager;
  93097. }
  93098. }
  93099. declare module BABYLON {
  93100. /**
  93101. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93102. * an arc rotate version arcFollowCamera are available.
  93103. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93104. */
  93105. export class FollowCamera extends TargetCamera {
  93106. /**
  93107. * Distance the follow camera should follow an object at
  93108. */
  93109. radius: number;
  93110. /**
  93111. * Define a rotation offset between the camera and the object it follows
  93112. */
  93113. rotationOffset: number;
  93114. /**
  93115. * Define a height offset between the camera and the object it follows.
  93116. * It can help following an object from the top (like a car chaing a plane)
  93117. */
  93118. heightOffset: number;
  93119. /**
  93120. * Define how fast the camera can accelerate to follow it s target.
  93121. */
  93122. cameraAcceleration: number;
  93123. /**
  93124. * Define the speed limit of the camera following an object.
  93125. */
  93126. maxCameraSpeed: number;
  93127. /**
  93128. * Define the target of the camera.
  93129. */
  93130. lockedTarget: Nullable<AbstractMesh>;
  93131. /**
  93132. * Defines the input associated with the camera.
  93133. */
  93134. inputs: FollowCameraInputsManager;
  93135. /**
  93136. * Instantiates the follow camera.
  93137. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93138. * @param name Define the name of the camera in the scene
  93139. * @param position Define the position of the camera
  93140. * @param scene Define the scene the camera belong to
  93141. * @param lockedTarget Define the target of the camera
  93142. */
  93143. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93144. private _follow;
  93145. /**
  93146. * Attached controls to the current camera.
  93147. * @param element Defines the element the controls should be listened from
  93148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93149. */
  93150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93151. /**
  93152. * Detach the current controls from the camera.
  93153. * The camera will stop reacting to inputs.
  93154. * @param element Defines the element to stop listening the inputs from
  93155. */
  93156. detachControl(element: HTMLElement): void;
  93157. /** @hidden */
  93158. _checkInputs(): void;
  93159. /**
  93160. * Gets the camera class name.
  93161. * @returns the class name
  93162. */
  93163. getClassName(): string;
  93164. }
  93165. /**
  93166. * Arc Rotate version of the follow camera.
  93167. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93168. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93169. */
  93170. export class ArcFollowCamera extends TargetCamera {
  93171. /** The longitudinal angle of the camera */
  93172. alpha: number;
  93173. /** The latitudinal angle of the camera */
  93174. beta: number;
  93175. /** The radius of the camera from its target */
  93176. radius: number;
  93177. /** Define the camera target (the messh it should follow) */
  93178. target: Nullable<AbstractMesh>;
  93179. private _cartesianCoordinates;
  93180. /**
  93181. * Instantiates a new ArcFollowCamera
  93182. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93183. * @param name Define the name of the camera
  93184. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93185. * @param beta Define the rotation angle of the camera around the elevation axis
  93186. * @param radius Define the radius of the camera from its target point
  93187. * @param target Define the target of the camera
  93188. * @param scene Define the scene the camera belongs to
  93189. */
  93190. constructor(name: string,
  93191. /** The longitudinal angle of the camera */
  93192. alpha: number,
  93193. /** The latitudinal angle of the camera */
  93194. beta: number,
  93195. /** The radius of the camera from its target */
  93196. radius: number,
  93197. /** Define the camera target (the messh it should follow) */
  93198. target: Nullable<AbstractMesh>, scene: Scene);
  93199. private _follow;
  93200. /** @hidden */
  93201. _checkInputs(): void;
  93202. /**
  93203. * Returns the class name of the object.
  93204. * It is mostly used internally for serialization purposes.
  93205. */
  93206. getClassName(): string;
  93207. }
  93208. }
  93209. declare module BABYLON {
  93210. /**
  93211. * 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,
  93212. * which still works and will still be found in many Playgrounds.
  93213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93214. */
  93215. export class UniversalCamera extends TouchCamera {
  93216. /**
  93217. * Defines the gamepad rotation sensiblity.
  93218. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93219. */
  93220. gamepadAngularSensibility: number;
  93221. /**
  93222. * Defines the gamepad move sensiblity.
  93223. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93224. */
  93225. gamepadMoveSensibility: number;
  93226. /**
  93227. * 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,
  93228. * which still works and will still be found in many Playgrounds.
  93229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93230. * @param name Define the name of the camera in the scene
  93231. * @param position Define the start position of the camera in the scene
  93232. * @param scene Define the scene the camera belongs to
  93233. */
  93234. constructor(name: string, position: Vector3, scene: Scene);
  93235. /**
  93236. * Gets the current object class name.
  93237. * @return the class name
  93238. */
  93239. getClassName(): string;
  93240. }
  93241. }
  93242. declare module BABYLON {
  93243. /**
  93244. * This represents a FPS type of camera. This is only here for back compat purpose.
  93245. * Please use the UniversalCamera instead as both are identical.
  93246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93247. */
  93248. export class GamepadCamera extends UniversalCamera {
  93249. /**
  93250. * Instantiates a new Gamepad Camera
  93251. * This represents a FPS type of camera. This is only here for back compat purpose.
  93252. * Please use the UniversalCamera instead as both are identical.
  93253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93254. * @param name Define the name of the camera in the scene
  93255. * @param position Define the start position of the camera in the scene
  93256. * @param scene Define the scene the camera belongs to
  93257. */
  93258. constructor(name: string, position: Vector3, scene: Scene);
  93259. /**
  93260. * Gets the current object class name.
  93261. * @return the class name
  93262. */
  93263. getClassName(): string;
  93264. }
  93265. }
  93266. declare module BABYLON {
  93267. /** @hidden */
  93268. export var passPixelShader: {
  93269. name: string;
  93270. shader: string;
  93271. };
  93272. }
  93273. declare module BABYLON {
  93274. /** @hidden */
  93275. export var passCubePixelShader: {
  93276. name: string;
  93277. shader: string;
  93278. };
  93279. }
  93280. declare module BABYLON {
  93281. /**
  93282. * PassPostProcess which produces an output the same as it's input
  93283. */
  93284. export class PassPostProcess extends PostProcess {
  93285. /**
  93286. * Creates the PassPostProcess
  93287. * @param name The name of the effect.
  93288. * @param options The required width/height ratio to downsize to before computing the render pass.
  93289. * @param camera The camera to apply the render pass to.
  93290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93291. * @param engine The engine which the post process will be applied. (default: current engine)
  93292. * @param reusable If the post process can be reused on the same frame. (default: false)
  93293. * @param textureType The type of texture to be used when performing the post processing.
  93294. * @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)
  93295. */
  93296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93297. }
  93298. /**
  93299. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93300. */
  93301. export class PassCubePostProcess extends PostProcess {
  93302. private _face;
  93303. /**
  93304. * Gets or sets the cube face to display.
  93305. * * 0 is +X
  93306. * * 1 is -X
  93307. * * 2 is +Y
  93308. * * 3 is -Y
  93309. * * 4 is +Z
  93310. * * 5 is -Z
  93311. */
  93312. face: number;
  93313. /**
  93314. * Creates the PassCubePostProcess
  93315. * @param name The name of the effect.
  93316. * @param options The required width/height ratio to downsize to before computing the render pass.
  93317. * @param camera The camera to apply the render pass to.
  93318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93319. * @param engine The engine which the post process will be applied. (default: current engine)
  93320. * @param reusable If the post process can be reused on the same frame. (default: false)
  93321. * @param textureType The type of texture to be used when performing the post processing.
  93322. * @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)
  93323. */
  93324. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93325. }
  93326. }
  93327. declare module BABYLON {
  93328. /** @hidden */
  93329. export var anaglyphPixelShader: {
  93330. name: string;
  93331. shader: string;
  93332. };
  93333. }
  93334. declare module BABYLON {
  93335. /**
  93336. * Postprocess used to generate anaglyphic rendering
  93337. */
  93338. export class AnaglyphPostProcess extends PostProcess {
  93339. private _passedProcess;
  93340. /**
  93341. * Creates a new AnaglyphPostProcess
  93342. * @param name defines postprocess name
  93343. * @param options defines creation options or target ratio scale
  93344. * @param rigCameras defines cameras using this postprocess
  93345. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  93346. * @param engine defines hosting engine
  93347. * @param reusable defines if the postprocess will be reused multiple times per frame
  93348. */
  93349. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  93350. }
  93351. }
  93352. declare module BABYLON {
  93353. /**
  93354. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  93355. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93356. */
  93357. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  93358. /**
  93359. * Creates a new AnaglyphArcRotateCamera
  93360. * @param name defines camera name
  93361. * @param alpha defines alpha angle (in radians)
  93362. * @param beta defines beta angle (in radians)
  93363. * @param radius defines radius
  93364. * @param target defines camera target
  93365. * @param interaxialDistance defines distance between each color axis
  93366. * @param scene defines the hosting scene
  93367. */
  93368. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  93369. /**
  93370. * Gets camera class name
  93371. * @returns AnaglyphArcRotateCamera
  93372. */
  93373. getClassName(): string;
  93374. }
  93375. }
  93376. declare module BABYLON {
  93377. /**
  93378. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  93379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93380. */
  93381. export class AnaglyphFreeCamera extends FreeCamera {
  93382. /**
  93383. * Creates a new AnaglyphFreeCamera
  93384. * @param name defines camera name
  93385. * @param position defines initial position
  93386. * @param interaxialDistance defines distance between each color axis
  93387. * @param scene defines the hosting scene
  93388. */
  93389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93390. /**
  93391. * Gets camera class name
  93392. * @returns AnaglyphFreeCamera
  93393. */
  93394. getClassName(): string;
  93395. }
  93396. }
  93397. declare module BABYLON {
  93398. /**
  93399. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  93400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93401. */
  93402. export class AnaglyphGamepadCamera extends GamepadCamera {
  93403. /**
  93404. * Creates a new AnaglyphGamepadCamera
  93405. * @param name defines camera name
  93406. * @param position defines initial position
  93407. * @param interaxialDistance defines distance between each color axis
  93408. * @param scene defines the hosting scene
  93409. */
  93410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93411. /**
  93412. * Gets camera class name
  93413. * @returns AnaglyphGamepadCamera
  93414. */
  93415. getClassName(): string;
  93416. }
  93417. }
  93418. declare module BABYLON {
  93419. /**
  93420. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  93421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93422. */
  93423. export class AnaglyphUniversalCamera extends UniversalCamera {
  93424. /**
  93425. * Creates a new AnaglyphUniversalCamera
  93426. * @param name defines camera name
  93427. * @param position defines initial position
  93428. * @param interaxialDistance defines distance between each color axis
  93429. * @param scene defines the hosting scene
  93430. */
  93431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93432. /**
  93433. * Gets camera class name
  93434. * @returns AnaglyphUniversalCamera
  93435. */
  93436. getClassName(): string;
  93437. }
  93438. }
  93439. declare module BABYLON {
  93440. /** @hidden */
  93441. export var stereoscopicInterlacePixelShader: {
  93442. name: string;
  93443. shader: string;
  93444. };
  93445. }
  93446. declare module BABYLON {
  93447. /**
  93448. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  93449. */
  93450. export class StereoscopicInterlacePostProcess extends PostProcess {
  93451. private _stepSize;
  93452. private _passedProcess;
  93453. /**
  93454. * Initializes a StereoscopicInterlacePostProcess
  93455. * @param name The name of the effect.
  93456. * @param rigCameras The rig cameras to be appled to the post process
  93457. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  93458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93459. * @param engine The engine which the post process will be applied. (default: current engine)
  93460. * @param reusable If the post process can be reused on the same frame. (default: false)
  93461. */
  93462. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  93463. }
  93464. }
  93465. declare module BABYLON {
  93466. /**
  93467. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  93468. * @see http://doc.babylonjs.com/features/cameras
  93469. */
  93470. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  93471. /**
  93472. * Creates a new StereoscopicArcRotateCamera
  93473. * @param name defines camera name
  93474. * @param alpha defines alpha angle (in radians)
  93475. * @param beta defines beta angle (in radians)
  93476. * @param radius defines radius
  93477. * @param target defines camera target
  93478. * @param interaxialDistance defines distance between each color axis
  93479. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93480. * @param scene defines the hosting scene
  93481. */
  93482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93483. /**
  93484. * Gets camera class name
  93485. * @returns StereoscopicArcRotateCamera
  93486. */
  93487. getClassName(): string;
  93488. }
  93489. }
  93490. declare module BABYLON {
  93491. /**
  93492. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  93493. * @see http://doc.babylonjs.com/features/cameras
  93494. */
  93495. export class StereoscopicFreeCamera extends FreeCamera {
  93496. /**
  93497. * Creates a new StereoscopicFreeCamera
  93498. * @param name defines camera name
  93499. * @param position defines initial position
  93500. * @param interaxialDistance defines distance between each color axis
  93501. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93502. * @param scene defines the hosting scene
  93503. */
  93504. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93505. /**
  93506. * Gets camera class name
  93507. * @returns StereoscopicFreeCamera
  93508. */
  93509. getClassName(): string;
  93510. }
  93511. }
  93512. declare module BABYLON {
  93513. /**
  93514. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  93515. * @see http://doc.babylonjs.com/features/cameras
  93516. */
  93517. export class StereoscopicGamepadCamera extends GamepadCamera {
  93518. /**
  93519. * Creates a new StereoscopicGamepadCamera
  93520. * @param name defines camera name
  93521. * @param position defines initial position
  93522. * @param interaxialDistance defines distance between each color axis
  93523. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93524. * @param scene defines the hosting scene
  93525. */
  93526. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93527. /**
  93528. * Gets camera class name
  93529. * @returns StereoscopicGamepadCamera
  93530. */
  93531. getClassName(): string;
  93532. }
  93533. }
  93534. declare module BABYLON {
  93535. /**
  93536. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  93537. * @see http://doc.babylonjs.com/features/cameras
  93538. */
  93539. export class StereoscopicUniversalCamera extends UniversalCamera {
  93540. /**
  93541. * Creates a new StereoscopicUniversalCamera
  93542. * @param name defines camera name
  93543. * @param position defines initial position
  93544. * @param interaxialDistance defines distance between each color axis
  93545. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93546. * @param scene defines the hosting scene
  93547. */
  93548. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93549. /**
  93550. * Gets camera class name
  93551. * @returns StereoscopicUniversalCamera
  93552. */
  93553. getClassName(): string;
  93554. }
  93555. }
  93556. declare module BABYLON {
  93557. /**
  93558. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93559. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93560. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93561. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93562. */
  93563. export class VirtualJoysticksCamera extends FreeCamera {
  93564. /**
  93565. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93566. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93567. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93568. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93569. * @param name Define the name of the camera in the scene
  93570. * @param position Define the start position of the camera in the scene
  93571. * @param scene Define the scene the camera belongs to
  93572. */
  93573. constructor(name: string, position: Vector3, scene: Scene);
  93574. /**
  93575. * Gets the current object class name.
  93576. * @return the class name
  93577. */
  93578. getClassName(): string;
  93579. }
  93580. }
  93581. declare module BABYLON {
  93582. /**
  93583. * This represents all the required metrics to create a VR camera.
  93584. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93585. */
  93586. export class VRCameraMetrics {
  93587. /**
  93588. * Define the horizontal resolution off the screen.
  93589. */
  93590. hResolution: number;
  93591. /**
  93592. * Define the vertical resolution off the screen.
  93593. */
  93594. vResolution: number;
  93595. /**
  93596. * Define the horizontal screen size.
  93597. */
  93598. hScreenSize: number;
  93599. /**
  93600. * Define the vertical screen size.
  93601. */
  93602. vScreenSize: number;
  93603. /**
  93604. * Define the vertical screen center position.
  93605. */
  93606. vScreenCenter: number;
  93607. /**
  93608. * Define the distance of the eyes to the screen.
  93609. */
  93610. eyeToScreenDistance: number;
  93611. /**
  93612. * Define the distance between both lenses
  93613. */
  93614. lensSeparationDistance: number;
  93615. /**
  93616. * Define the distance between both viewer's eyes.
  93617. */
  93618. interpupillaryDistance: number;
  93619. /**
  93620. * Define the distortion factor of the VR postprocess.
  93621. * Please, touch with care.
  93622. */
  93623. distortionK: number[];
  93624. /**
  93625. * Define the chromatic aberration correction factors for the VR post process.
  93626. */
  93627. chromaAbCorrection: number[];
  93628. /**
  93629. * Define the scale factor of the post process.
  93630. * The smaller the better but the slower.
  93631. */
  93632. postProcessScaleFactor: number;
  93633. /**
  93634. * Define an offset for the lens center.
  93635. */
  93636. lensCenterOffset: number;
  93637. /**
  93638. * Define if the current vr camera should compensate the distortion of the lense or not.
  93639. */
  93640. compensateDistortion: boolean;
  93641. /**
  93642. * Gets the rendering aspect ratio based on the provided resolutions.
  93643. */
  93644. readonly aspectRatio: number;
  93645. /**
  93646. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93647. */
  93648. readonly aspectRatioFov: number;
  93649. /**
  93650. * @hidden
  93651. */
  93652. readonly leftHMatrix: Matrix;
  93653. /**
  93654. * @hidden
  93655. */
  93656. readonly rightHMatrix: Matrix;
  93657. /**
  93658. * @hidden
  93659. */
  93660. readonly leftPreViewMatrix: Matrix;
  93661. /**
  93662. * @hidden
  93663. */
  93664. readonly rightPreViewMatrix: Matrix;
  93665. /**
  93666. * Get the default VRMetrics based on the most generic setup.
  93667. * @returns the default vr metrics
  93668. */
  93669. static GetDefault(): VRCameraMetrics;
  93670. }
  93671. }
  93672. declare module BABYLON {
  93673. /** @hidden */
  93674. export var vrDistortionCorrectionPixelShader: {
  93675. name: string;
  93676. shader: string;
  93677. };
  93678. }
  93679. declare module BABYLON {
  93680. /**
  93681. * VRDistortionCorrectionPostProcess used for mobile VR
  93682. */
  93683. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93684. private _isRightEye;
  93685. private _distortionFactors;
  93686. private _postProcessScaleFactor;
  93687. private _lensCenterOffset;
  93688. private _scaleIn;
  93689. private _scaleFactor;
  93690. private _lensCenter;
  93691. /**
  93692. * Initializes the VRDistortionCorrectionPostProcess
  93693. * @param name The name of the effect.
  93694. * @param camera The camera to apply the render pass to.
  93695. * @param isRightEye If this is for the right eye distortion
  93696. * @param vrMetrics All the required metrics for the VR camera
  93697. */
  93698. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93699. }
  93700. }
  93701. declare module BABYLON {
  93702. /**
  93703. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93704. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93705. */
  93706. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93707. /**
  93708. * Creates a new VRDeviceOrientationArcRotateCamera
  93709. * @param name defines camera name
  93710. * @param alpha defines the camera rotation along the logitudinal axis
  93711. * @param beta defines the camera rotation along the latitudinal axis
  93712. * @param radius defines the camera distance from its target
  93713. * @param target defines the camera target
  93714. * @param scene defines the scene the camera belongs to
  93715. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93716. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93717. */
  93718. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93719. /**
  93720. * Gets camera class name
  93721. * @returns VRDeviceOrientationArcRotateCamera
  93722. */
  93723. getClassName(): string;
  93724. }
  93725. }
  93726. declare module BABYLON {
  93727. /**
  93728. * Camera used to simulate VR rendering (based on FreeCamera)
  93729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93730. */
  93731. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93732. /**
  93733. * Creates a new VRDeviceOrientationFreeCamera
  93734. * @param name defines camera name
  93735. * @param position defines the start position of the camera
  93736. * @param scene defines the scene the camera belongs to
  93737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93739. */
  93740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93741. /**
  93742. * Gets camera class name
  93743. * @returns VRDeviceOrientationFreeCamera
  93744. */
  93745. getClassName(): string;
  93746. }
  93747. }
  93748. declare module BABYLON {
  93749. /**
  93750. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93752. */
  93753. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93754. /**
  93755. * Creates a new VRDeviceOrientationGamepadCamera
  93756. * @param name defines camera name
  93757. * @param position defines the start position of the camera
  93758. * @param scene defines the scene the camera belongs to
  93759. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93760. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93761. */
  93762. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93763. /**
  93764. * Gets camera class name
  93765. * @returns VRDeviceOrientationGamepadCamera
  93766. */
  93767. getClassName(): string;
  93768. }
  93769. }
  93770. declare module BABYLON {
  93771. /**
  93772. * Defines supported buttons for XBox360 compatible gamepads
  93773. */
  93774. export enum Xbox360Button {
  93775. /** A */
  93776. A = 0,
  93777. /** B */
  93778. B = 1,
  93779. /** X */
  93780. X = 2,
  93781. /** Y */
  93782. Y = 3,
  93783. /** Start */
  93784. Start = 4,
  93785. /** Back */
  93786. Back = 5,
  93787. /** Left button */
  93788. LB = 6,
  93789. /** Right button */
  93790. RB = 7,
  93791. /** Left stick */
  93792. LeftStick = 8,
  93793. /** Right stick */
  93794. RightStick = 9
  93795. }
  93796. /** Defines values for XBox360 DPad */
  93797. export enum Xbox360Dpad {
  93798. /** Up */
  93799. Up = 0,
  93800. /** Down */
  93801. Down = 1,
  93802. /** Left */
  93803. Left = 2,
  93804. /** Right */
  93805. Right = 3
  93806. }
  93807. /**
  93808. * Defines a XBox360 gamepad
  93809. */
  93810. export class Xbox360Pad extends Gamepad {
  93811. private _leftTrigger;
  93812. private _rightTrigger;
  93813. private _onlefttriggerchanged;
  93814. private _onrighttriggerchanged;
  93815. private _onbuttondown;
  93816. private _onbuttonup;
  93817. private _ondpaddown;
  93818. private _ondpadup;
  93819. /** Observable raised when a button is pressed */
  93820. onButtonDownObservable: Observable<Xbox360Button>;
  93821. /** Observable raised when a button is released */
  93822. onButtonUpObservable: Observable<Xbox360Button>;
  93823. /** Observable raised when a pad is pressed */
  93824. onPadDownObservable: Observable<Xbox360Dpad>;
  93825. /** Observable raised when a pad is released */
  93826. onPadUpObservable: Observable<Xbox360Dpad>;
  93827. private _buttonA;
  93828. private _buttonB;
  93829. private _buttonX;
  93830. private _buttonY;
  93831. private _buttonBack;
  93832. private _buttonStart;
  93833. private _buttonLB;
  93834. private _buttonRB;
  93835. private _buttonLeftStick;
  93836. private _buttonRightStick;
  93837. private _dPadUp;
  93838. private _dPadDown;
  93839. private _dPadLeft;
  93840. private _dPadRight;
  93841. private _isXboxOnePad;
  93842. /**
  93843. * Creates a new XBox360 gamepad object
  93844. * @param id defines the id of this gamepad
  93845. * @param index defines its index
  93846. * @param gamepad defines the internal HTML gamepad object
  93847. * @param xboxOne defines if it is a XBox One gamepad
  93848. */
  93849. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93850. /**
  93851. * Defines the callback to call when left trigger is pressed
  93852. * @param callback defines the callback to use
  93853. */
  93854. onlefttriggerchanged(callback: (value: number) => void): void;
  93855. /**
  93856. * Defines the callback to call when right trigger is pressed
  93857. * @param callback defines the callback to use
  93858. */
  93859. onrighttriggerchanged(callback: (value: number) => void): void;
  93860. /**
  93861. * Gets the left trigger value
  93862. */
  93863. /**
  93864. * Sets the left trigger value
  93865. */
  93866. leftTrigger: number;
  93867. /**
  93868. * Gets the right trigger value
  93869. */
  93870. /**
  93871. * Sets the right trigger value
  93872. */
  93873. rightTrigger: number;
  93874. /**
  93875. * Defines the callback to call when a button is pressed
  93876. * @param callback defines the callback to use
  93877. */
  93878. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93879. /**
  93880. * Defines the callback to call when a button is released
  93881. * @param callback defines the callback to use
  93882. */
  93883. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93884. /**
  93885. * Defines the callback to call when a pad is pressed
  93886. * @param callback defines the callback to use
  93887. */
  93888. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93889. /**
  93890. * Defines the callback to call when a pad is released
  93891. * @param callback defines the callback to use
  93892. */
  93893. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93894. private _setButtonValue;
  93895. private _setDPadValue;
  93896. /**
  93897. * Gets the value of the `A` button
  93898. */
  93899. /**
  93900. * Sets the value of the `A` button
  93901. */
  93902. buttonA: number;
  93903. /**
  93904. * Gets the value of the `B` button
  93905. */
  93906. /**
  93907. * Sets the value of the `B` button
  93908. */
  93909. buttonB: number;
  93910. /**
  93911. * Gets the value of the `X` button
  93912. */
  93913. /**
  93914. * Sets the value of the `X` button
  93915. */
  93916. buttonX: number;
  93917. /**
  93918. * Gets the value of the `Y` button
  93919. */
  93920. /**
  93921. * Sets the value of the `Y` button
  93922. */
  93923. buttonY: number;
  93924. /**
  93925. * Gets the value of the `Start` button
  93926. */
  93927. /**
  93928. * Sets the value of the `Start` button
  93929. */
  93930. buttonStart: number;
  93931. /**
  93932. * Gets the value of the `Back` button
  93933. */
  93934. /**
  93935. * Sets the value of the `Back` button
  93936. */
  93937. buttonBack: number;
  93938. /**
  93939. * Gets the value of the `Left` button
  93940. */
  93941. /**
  93942. * Sets the value of the `Left` button
  93943. */
  93944. buttonLB: number;
  93945. /**
  93946. * Gets the value of the `Right` button
  93947. */
  93948. /**
  93949. * Sets the value of the `Right` button
  93950. */
  93951. buttonRB: number;
  93952. /**
  93953. * Gets the value of the Left joystick
  93954. */
  93955. /**
  93956. * Sets the value of the Left joystick
  93957. */
  93958. buttonLeftStick: number;
  93959. /**
  93960. * Gets the value of the Right joystick
  93961. */
  93962. /**
  93963. * Sets the value of the Right joystick
  93964. */
  93965. buttonRightStick: number;
  93966. /**
  93967. * Gets the value of D-pad up
  93968. */
  93969. /**
  93970. * Sets the value of D-pad up
  93971. */
  93972. dPadUp: number;
  93973. /**
  93974. * Gets the value of D-pad down
  93975. */
  93976. /**
  93977. * Sets the value of D-pad down
  93978. */
  93979. dPadDown: number;
  93980. /**
  93981. * Gets the value of D-pad left
  93982. */
  93983. /**
  93984. * Sets the value of D-pad left
  93985. */
  93986. dPadLeft: number;
  93987. /**
  93988. * Gets the value of D-pad right
  93989. */
  93990. /**
  93991. * Sets the value of D-pad right
  93992. */
  93993. dPadRight: number;
  93994. /**
  93995. * Force the gamepad to synchronize with device values
  93996. */
  93997. update(): void;
  93998. /**
  93999. * Disposes the gamepad
  94000. */
  94001. dispose(): void;
  94002. }
  94003. }
  94004. declare module BABYLON {
  94005. /**
  94006. * Base class of materials working in push mode in babylon JS
  94007. * @hidden
  94008. */
  94009. export class PushMaterial extends Material {
  94010. protected _activeEffect: Effect;
  94011. protected _normalMatrix: Matrix;
  94012. /**
  94013. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94014. * This means that the material can keep using a previous shader while a new one is being compiled.
  94015. * This is mostly used when shader parallel compilation is supported (true by default)
  94016. */
  94017. allowShaderHotSwapping: boolean;
  94018. constructor(name: string, scene: Scene);
  94019. getEffect(): Effect;
  94020. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94021. /**
  94022. * Binds the given world matrix to the active effect
  94023. *
  94024. * @param world the matrix to bind
  94025. */
  94026. bindOnlyWorldMatrix(world: Matrix): void;
  94027. /**
  94028. * Binds the given normal matrix to the active effect
  94029. *
  94030. * @param normalMatrix the matrix to bind
  94031. */
  94032. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94033. bind(world: Matrix, mesh?: Mesh): void;
  94034. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94035. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94036. }
  94037. }
  94038. declare module BABYLON {
  94039. /**
  94040. * This groups all the flags used to control the materials channel.
  94041. */
  94042. export class MaterialFlags {
  94043. private static _DiffuseTextureEnabled;
  94044. /**
  94045. * Are diffuse textures enabled in the application.
  94046. */
  94047. static DiffuseTextureEnabled: boolean;
  94048. private static _AmbientTextureEnabled;
  94049. /**
  94050. * Are ambient textures enabled in the application.
  94051. */
  94052. static AmbientTextureEnabled: boolean;
  94053. private static _OpacityTextureEnabled;
  94054. /**
  94055. * Are opacity textures enabled in the application.
  94056. */
  94057. static OpacityTextureEnabled: boolean;
  94058. private static _ReflectionTextureEnabled;
  94059. /**
  94060. * Are reflection textures enabled in the application.
  94061. */
  94062. static ReflectionTextureEnabled: boolean;
  94063. private static _EmissiveTextureEnabled;
  94064. /**
  94065. * Are emissive textures enabled in the application.
  94066. */
  94067. static EmissiveTextureEnabled: boolean;
  94068. private static _SpecularTextureEnabled;
  94069. /**
  94070. * Are specular textures enabled in the application.
  94071. */
  94072. static SpecularTextureEnabled: boolean;
  94073. private static _BumpTextureEnabled;
  94074. /**
  94075. * Are bump textures enabled in the application.
  94076. */
  94077. static BumpTextureEnabled: boolean;
  94078. private static _LightmapTextureEnabled;
  94079. /**
  94080. * Are lightmap textures enabled in the application.
  94081. */
  94082. static LightmapTextureEnabled: boolean;
  94083. private static _RefractionTextureEnabled;
  94084. /**
  94085. * Are refraction textures enabled in the application.
  94086. */
  94087. static RefractionTextureEnabled: boolean;
  94088. private static _ColorGradingTextureEnabled;
  94089. /**
  94090. * Are color grading textures enabled in the application.
  94091. */
  94092. static ColorGradingTextureEnabled: boolean;
  94093. private static _FresnelEnabled;
  94094. /**
  94095. * Are fresnels enabled in the application.
  94096. */
  94097. static FresnelEnabled: boolean;
  94098. }
  94099. }
  94100. declare module BABYLON {
  94101. /** @hidden */
  94102. export var defaultFragmentDeclaration: {
  94103. name: string;
  94104. shader: string;
  94105. };
  94106. }
  94107. declare module BABYLON {
  94108. /** @hidden */
  94109. export var defaultUboDeclaration: {
  94110. name: string;
  94111. shader: string;
  94112. };
  94113. }
  94114. declare module BABYLON {
  94115. /** @hidden */
  94116. export var lightFragmentDeclaration: {
  94117. name: string;
  94118. shader: string;
  94119. };
  94120. }
  94121. declare module BABYLON {
  94122. /** @hidden */
  94123. export var lightUboDeclaration: {
  94124. name: string;
  94125. shader: string;
  94126. };
  94127. }
  94128. declare module BABYLON {
  94129. /** @hidden */
  94130. export var lightsFragmentFunctions: {
  94131. name: string;
  94132. shader: string;
  94133. };
  94134. }
  94135. declare module BABYLON {
  94136. /** @hidden */
  94137. export var shadowsFragmentFunctions: {
  94138. name: string;
  94139. shader: string;
  94140. };
  94141. }
  94142. declare module BABYLON {
  94143. /** @hidden */
  94144. export var fresnelFunction: {
  94145. name: string;
  94146. shader: string;
  94147. };
  94148. }
  94149. declare module BABYLON {
  94150. /** @hidden */
  94151. export var reflectionFunction: {
  94152. name: string;
  94153. shader: string;
  94154. };
  94155. }
  94156. declare module BABYLON {
  94157. /** @hidden */
  94158. export var bumpFragmentFunctions: {
  94159. name: string;
  94160. shader: string;
  94161. };
  94162. }
  94163. declare module BABYLON {
  94164. /** @hidden */
  94165. export var logDepthDeclaration: {
  94166. name: string;
  94167. shader: string;
  94168. };
  94169. }
  94170. declare module BABYLON {
  94171. /** @hidden */
  94172. export var bumpFragment: {
  94173. name: string;
  94174. shader: string;
  94175. };
  94176. }
  94177. declare module BABYLON {
  94178. /** @hidden */
  94179. export var depthPrePass: {
  94180. name: string;
  94181. shader: string;
  94182. };
  94183. }
  94184. declare module BABYLON {
  94185. /** @hidden */
  94186. export var lightFragment: {
  94187. name: string;
  94188. shader: string;
  94189. };
  94190. }
  94191. declare module BABYLON {
  94192. /** @hidden */
  94193. export var logDepthFragment: {
  94194. name: string;
  94195. shader: string;
  94196. };
  94197. }
  94198. declare module BABYLON {
  94199. /** @hidden */
  94200. export var defaultPixelShader: {
  94201. name: string;
  94202. shader: string;
  94203. };
  94204. }
  94205. declare module BABYLON {
  94206. /** @hidden */
  94207. export var defaultVertexDeclaration: {
  94208. name: string;
  94209. shader: string;
  94210. };
  94211. }
  94212. declare module BABYLON {
  94213. /** @hidden */
  94214. export var bumpVertexDeclaration: {
  94215. name: string;
  94216. shader: string;
  94217. };
  94218. }
  94219. declare module BABYLON {
  94220. /** @hidden */
  94221. export var bumpVertex: {
  94222. name: string;
  94223. shader: string;
  94224. };
  94225. }
  94226. declare module BABYLON {
  94227. /** @hidden */
  94228. export var fogVertex: {
  94229. name: string;
  94230. shader: string;
  94231. };
  94232. }
  94233. declare module BABYLON {
  94234. /** @hidden */
  94235. export var shadowsVertex: {
  94236. name: string;
  94237. shader: string;
  94238. };
  94239. }
  94240. declare module BABYLON {
  94241. /** @hidden */
  94242. export var pointCloudVertex: {
  94243. name: string;
  94244. shader: string;
  94245. };
  94246. }
  94247. declare module BABYLON {
  94248. /** @hidden */
  94249. export var logDepthVertex: {
  94250. name: string;
  94251. shader: string;
  94252. };
  94253. }
  94254. declare module BABYLON {
  94255. /** @hidden */
  94256. export var defaultVertexShader: {
  94257. name: string;
  94258. shader: string;
  94259. };
  94260. }
  94261. declare module BABYLON {
  94262. /** @hidden */
  94263. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94264. MAINUV1: boolean;
  94265. MAINUV2: boolean;
  94266. DIFFUSE: boolean;
  94267. DIFFUSEDIRECTUV: number;
  94268. AMBIENT: boolean;
  94269. AMBIENTDIRECTUV: number;
  94270. OPACITY: boolean;
  94271. OPACITYDIRECTUV: number;
  94272. OPACITYRGB: boolean;
  94273. REFLECTION: boolean;
  94274. EMISSIVE: boolean;
  94275. EMISSIVEDIRECTUV: number;
  94276. SPECULAR: boolean;
  94277. SPECULARDIRECTUV: number;
  94278. BUMP: boolean;
  94279. BUMPDIRECTUV: number;
  94280. PARALLAX: boolean;
  94281. PARALLAXOCCLUSION: boolean;
  94282. SPECULAROVERALPHA: boolean;
  94283. CLIPPLANE: boolean;
  94284. CLIPPLANE2: boolean;
  94285. CLIPPLANE3: boolean;
  94286. CLIPPLANE4: boolean;
  94287. ALPHATEST: boolean;
  94288. DEPTHPREPASS: boolean;
  94289. ALPHAFROMDIFFUSE: boolean;
  94290. POINTSIZE: boolean;
  94291. FOG: boolean;
  94292. SPECULARTERM: boolean;
  94293. DIFFUSEFRESNEL: boolean;
  94294. OPACITYFRESNEL: boolean;
  94295. REFLECTIONFRESNEL: boolean;
  94296. REFRACTIONFRESNEL: boolean;
  94297. EMISSIVEFRESNEL: boolean;
  94298. FRESNEL: boolean;
  94299. NORMAL: boolean;
  94300. UV1: boolean;
  94301. UV2: boolean;
  94302. VERTEXCOLOR: boolean;
  94303. VERTEXALPHA: boolean;
  94304. NUM_BONE_INFLUENCERS: number;
  94305. BonesPerMesh: number;
  94306. BONETEXTURE: boolean;
  94307. INSTANCES: boolean;
  94308. GLOSSINESS: boolean;
  94309. ROUGHNESS: boolean;
  94310. EMISSIVEASILLUMINATION: boolean;
  94311. LINKEMISSIVEWITHDIFFUSE: boolean;
  94312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94313. LIGHTMAP: boolean;
  94314. LIGHTMAPDIRECTUV: number;
  94315. OBJECTSPACE_NORMALMAP: boolean;
  94316. USELIGHTMAPASSHADOWMAP: boolean;
  94317. REFLECTIONMAP_3D: boolean;
  94318. REFLECTIONMAP_SPHERICAL: boolean;
  94319. REFLECTIONMAP_PLANAR: boolean;
  94320. REFLECTIONMAP_CUBIC: boolean;
  94321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94322. REFLECTIONMAP_PROJECTION: boolean;
  94323. REFLECTIONMAP_SKYBOX: boolean;
  94324. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94325. REFLECTIONMAP_EXPLICIT: boolean;
  94326. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94327. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94328. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94329. INVERTCUBICMAP: boolean;
  94330. LOGARITHMICDEPTH: boolean;
  94331. REFRACTION: boolean;
  94332. REFRACTIONMAP_3D: boolean;
  94333. REFLECTIONOVERALPHA: boolean;
  94334. TWOSIDEDLIGHTING: boolean;
  94335. SHADOWFLOAT: boolean;
  94336. MORPHTARGETS: boolean;
  94337. MORPHTARGETS_NORMAL: boolean;
  94338. MORPHTARGETS_TANGENT: boolean;
  94339. NUM_MORPH_INFLUENCERS: number;
  94340. NONUNIFORMSCALING: boolean;
  94341. PREMULTIPLYALPHA: boolean;
  94342. IMAGEPROCESSING: boolean;
  94343. VIGNETTE: boolean;
  94344. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94345. VIGNETTEBLENDMODEOPAQUE: boolean;
  94346. TONEMAPPING: boolean;
  94347. TONEMAPPING_ACES: boolean;
  94348. CONTRAST: boolean;
  94349. COLORCURVES: boolean;
  94350. COLORGRADING: boolean;
  94351. COLORGRADING3D: boolean;
  94352. SAMPLER3DGREENDEPTH: boolean;
  94353. SAMPLER3DBGRMAP: boolean;
  94354. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94355. /**
  94356. * If the reflection texture on this material is in linear color space
  94357. * @hidden
  94358. */
  94359. IS_REFLECTION_LINEAR: boolean;
  94360. /**
  94361. * If the refraction texture on this material is in linear color space
  94362. * @hidden
  94363. */
  94364. IS_REFRACTION_LINEAR: boolean;
  94365. EXPOSURE: boolean;
  94366. constructor();
  94367. setReflectionMode(modeToEnable: string): void;
  94368. }
  94369. /**
  94370. * This is the default material used in Babylon. It is the best trade off between quality
  94371. * and performances.
  94372. * @see http://doc.babylonjs.com/babylon101/materials
  94373. */
  94374. export class StandardMaterial extends PushMaterial {
  94375. private _diffuseTexture;
  94376. /**
  94377. * The basic texture of the material as viewed under a light.
  94378. */
  94379. diffuseTexture: Nullable<BaseTexture>;
  94380. private _ambientTexture;
  94381. /**
  94382. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94383. */
  94384. ambientTexture: Nullable<BaseTexture>;
  94385. private _opacityTexture;
  94386. /**
  94387. * Define the transparency of the material from a texture.
  94388. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94389. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94390. */
  94391. opacityTexture: Nullable<BaseTexture>;
  94392. private _reflectionTexture;
  94393. /**
  94394. * Define the texture used to display the reflection.
  94395. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94396. */
  94397. reflectionTexture: Nullable<BaseTexture>;
  94398. private _emissiveTexture;
  94399. /**
  94400. * Define texture of the material as if self lit.
  94401. * This will be mixed in the final result even in the absence of light.
  94402. */
  94403. emissiveTexture: Nullable<BaseTexture>;
  94404. private _specularTexture;
  94405. /**
  94406. * Define how the color and intensity of the highlight given by the light in the material.
  94407. */
  94408. specularTexture: Nullable<BaseTexture>;
  94409. private _bumpTexture;
  94410. /**
  94411. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94412. * 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.
  94413. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94414. */
  94415. bumpTexture: Nullable<BaseTexture>;
  94416. private _lightmapTexture;
  94417. /**
  94418. * Complex lighting can be computationally expensive to compute at runtime.
  94419. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94420. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94421. */
  94422. lightmapTexture: Nullable<BaseTexture>;
  94423. private _refractionTexture;
  94424. /**
  94425. * Define the texture used to display the refraction.
  94426. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94427. */
  94428. refractionTexture: Nullable<BaseTexture>;
  94429. /**
  94430. * The color of the material lit by the environmental background lighting.
  94431. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94432. */
  94433. ambientColor: Color3;
  94434. /**
  94435. * The basic color of the material as viewed under a light.
  94436. */
  94437. diffuseColor: Color3;
  94438. /**
  94439. * Define how the color and intensity of the highlight given by the light in the material.
  94440. */
  94441. specularColor: Color3;
  94442. /**
  94443. * Define the color of the material as if self lit.
  94444. * This will be mixed in the final result even in the absence of light.
  94445. */
  94446. emissiveColor: Color3;
  94447. /**
  94448. * Defines how sharp are the highlights in the material.
  94449. * The bigger the value the sharper giving a more glossy feeling to the result.
  94450. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94451. */
  94452. specularPower: number;
  94453. private _useAlphaFromDiffuseTexture;
  94454. /**
  94455. * Does the transparency come from the diffuse texture alpha channel.
  94456. */
  94457. useAlphaFromDiffuseTexture: boolean;
  94458. private _useEmissiveAsIllumination;
  94459. /**
  94460. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94461. */
  94462. useEmissiveAsIllumination: boolean;
  94463. private _linkEmissiveWithDiffuse;
  94464. /**
  94465. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94466. * the emissive level when the final color is close to one.
  94467. */
  94468. linkEmissiveWithDiffuse: boolean;
  94469. private _useSpecularOverAlpha;
  94470. /**
  94471. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94472. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94473. */
  94474. useSpecularOverAlpha: boolean;
  94475. private _useReflectionOverAlpha;
  94476. /**
  94477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94479. */
  94480. useReflectionOverAlpha: boolean;
  94481. private _disableLighting;
  94482. /**
  94483. * Does lights from the scene impacts this material.
  94484. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94485. */
  94486. disableLighting: boolean;
  94487. private _useObjectSpaceNormalMap;
  94488. /**
  94489. * Allows using an object space normal map (instead of tangent space).
  94490. */
  94491. useObjectSpaceNormalMap: boolean;
  94492. private _useParallax;
  94493. /**
  94494. * Is parallax enabled or not.
  94495. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94496. */
  94497. useParallax: boolean;
  94498. private _useParallaxOcclusion;
  94499. /**
  94500. * Is parallax occlusion enabled or not.
  94501. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  94502. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94503. */
  94504. useParallaxOcclusion: boolean;
  94505. /**
  94506. * 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.
  94507. */
  94508. parallaxScaleBias: number;
  94509. private _roughness;
  94510. /**
  94511. * Helps to define how blurry the reflections should appears in the material.
  94512. */
  94513. roughness: number;
  94514. /**
  94515. * In case of refraction, define the value of the indice of refraction.
  94516. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94517. */
  94518. indexOfRefraction: number;
  94519. /**
  94520. * Invert the refraction texture alongside the y axis.
  94521. * It can be useful with procedural textures or probe for instance.
  94522. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94523. */
  94524. invertRefractionY: boolean;
  94525. /**
  94526. * Defines the alpha limits in alpha test mode.
  94527. */
  94528. alphaCutOff: number;
  94529. private _useLightmapAsShadowmap;
  94530. /**
  94531. * In case of light mapping, define whether the map contains light or shadow informations.
  94532. */
  94533. useLightmapAsShadowmap: boolean;
  94534. private _diffuseFresnelParameters;
  94535. /**
  94536. * Define the diffuse fresnel parameters of the material.
  94537. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94538. */
  94539. diffuseFresnelParameters: FresnelParameters;
  94540. private _opacityFresnelParameters;
  94541. /**
  94542. * Define the opacity fresnel parameters of the material.
  94543. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94544. */
  94545. opacityFresnelParameters: FresnelParameters;
  94546. private _reflectionFresnelParameters;
  94547. /**
  94548. * Define the reflection fresnel parameters of the material.
  94549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94550. */
  94551. reflectionFresnelParameters: FresnelParameters;
  94552. private _refractionFresnelParameters;
  94553. /**
  94554. * Define the refraction fresnel parameters of the material.
  94555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94556. */
  94557. refractionFresnelParameters: FresnelParameters;
  94558. private _emissiveFresnelParameters;
  94559. /**
  94560. * Define the emissive fresnel parameters of the material.
  94561. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94562. */
  94563. emissiveFresnelParameters: FresnelParameters;
  94564. private _useReflectionFresnelFromSpecular;
  94565. /**
  94566. * If true automatically deducts the fresnels values from the material specularity.
  94567. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94568. */
  94569. useReflectionFresnelFromSpecular: boolean;
  94570. private _useGlossinessFromSpecularMapAlpha;
  94571. /**
  94572. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94573. */
  94574. useGlossinessFromSpecularMapAlpha: boolean;
  94575. private _maxSimultaneousLights;
  94576. /**
  94577. * Defines the maximum number of lights that can be used in the material
  94578. */
  94579. maxSimultaneousLights: number;
  94580. private _invertNormalMapX;
  94581. /**
  94582. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94583. */
  94584. invertNormalMapX: boolean;
  94585. private _invertNormalMapY;
  94586. /**
  94587. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94588. */
  94589. invertNormalMapY: boolean;
  94590. private _twoSidedLighting;
  94591. /**
  94592. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94593. */
  94594. twoSidedLighting: boolean;
  94595. /**
  94596. * Default configuration related to image processing available in the standard Material.
  94597. */
  94598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94599. /**
  94600. * Gets the image processing configuration used either in this material.
  94601. */
  94602. /**
  94603. * Sets the Default image processing configuration used either in the this material.
  94604. *
  94605. * If sets to null, the scene one is in use.
  94606. */
  94607. imageProcessingConfiguration: ImageProcessingConfiguration;
  94608. /**
  94609. * Keep track of the image processing observer to allow dispose and replace.
  94610. */
  94611. private _imageProcessingObserver;
  94612. /**
  94613. * Attaches a new image processing configuration to the Standard Material.
  94614. * @param configuration
  94615. */
  94616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94617. /**
  94618. * Gets wether the color curves effect is enabled.
  94619. */
  94620. /**
  94621. * Sets wether the color curves effect is enabled.
  94622. */
  94623. cameraColorCurvesEnabled: boolean;
  94624. /**
  94625. * Gets wether the color grading effect is enabled.
  94626. */
  94627. /**
  94628. * Gets wether the color grading effect is enabled.
  94629. */
  94630. cameraColorGradingEnabled: boolean;
  94631. /**
  94632. * Gets wether tonemapping is enabled or not.
  94633. */
  94634. /**
  94635. * Sets wether tonemapping is enabled or not
  94636. */
  94637. cameraToneMappingEnabled: boolean;
  94638. /**
  94639. * The camera exposure used on this material.
  94640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94641. * This corresponds to a photographic exposure.
  94642. */
  94643. /**
  94644. * The camera exposure used on this material.
  94645. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94646. * This corresponds to a photographic exposure.
  94647. */
  94648. cameraExposure: number;
  94649. /**
  94650. * Gets The camera contrast used on this material.
  94651. */
  94652. /**
  94653. * Sets The camera contrast used on this material.
  94654. */
  94655. cameraContrast: number;
  94656. /**
  94657. * Gets the Color Grading 2D Lookup Texture.
  94658. */
  94659. /**
  94660. * Sets the Color Grading 2D Lookup Texture.
  94661. */
  94662. cameraColorGradingTexture: Nullable<BaseTexture>;
  94663. /**
  94664. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94665. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94666. * 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;
  94667. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94668. */
  94669. /**
  94670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94672. * 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;
  94673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94674. */
  94675. cameraColorCurves: Nullable<ColorCurves>;
  94676. /**
  94677. * Custom callback helping to override the default shader used in the material.
  94678. */
  94679. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94680. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94681. protected _worldViewProjectionMatrix: Matrix;
  94682. protected _globalAmbientColor: Color3;
  94683. protected _useLogarithmicDepth: boolean;
  94684. /**
  94685. * Instantiates a new standard material.
  94686. * This is the default material used in Babylon. It is the best trade off between quality
  94687. * and performances.
  94688. * @see http://doc.babylonjs.com/babylon101/materials
  94689. * @param name Define the name of the material in the scene
  94690. * @param scene Define the scene the material belong to
  94691. */
  94692. constructor(name: string, scene: Scene);
  94693. /**
  94694. * Gets a boolean indicating that current material needs to register RTT
  94695. */
  94696. readonly hasRenderTargetTextures: boolean;
  94697. /**
  94698. * Gets the current class name of the material e.g. "StandardMaterial"
  94699. * Mainly use in serialization.
  94700. * @returns the class name
  94701. */
  94702. getClassName(): string;
  94703. /**
  94704. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94705. * You can try switching to logarithmic depth.
  94706. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94707. */
  94708. useLogarithmicDepth: boolean;
  94709. /**
  94710. * Specifies if the material will require alpha blending
  94711. * @returns a boolean specifying if alpha blending is needed
  94712. */
  94713. needAlphaBlending(): boolean;
  94714. /**
  94715. * Specifies if this material should be rendered in alpha test mode
  94716. * @returns a boolean specifying if an alpha test is needed.
  94717. */
  94718. needAlphaTesting(): boolean;
  94719. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94720. /**
  94721. * Get the texture used for alpha test purpose.
  94722. * @returns the diffuse texture in case of the standard material.
  94723. */
  94724. getAlphaTestTexture(): Nullable<BaseTexture>;
  94725. /**
  94726. * Get if the submesh is ready to be used and all its information available.
  94727. * Child classes can use it to update shaders
  94728. * @param mesh defines the mesh to check
  94729. * @param subMesh defines which submesh to check
  94730. * @param useInstances specifies that instances should be used
  94731. * @returns a boolean indicating that the submesh is ready or not
  94732. */
  94733. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94734. /**
  94735. * Builds the material UBO layouts.
  94736. * Used internally during the effect preparation.
  94737. */
  94738. buildUniformLayout(): void;
  94739. /**
  94740. * Unbinds the material from the mesh
  94741. */
  94742. unbind(): void;
  94743. /**
  94744. * Binds the submesh to this material by preparing the effect and shader to draw
  94745. * @param world defines the world transformation matrix
  94746. * @param mesh defines the mesh containing the submesh
  94747. * @param subMesh defines the submesh to bind the material to
  94748. */
  94749. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94750. /**
  94751. * Get the list of animatables in the material.
  94752. * @returns the list of animatables object used in the material
  94753. */
  94754. getAnimatables(): IAnimatable[];
  94755. /**
  94756. * Gets the active textures from the material
  94757. * @returns an array of textures
  94758. */
  94759. getActiveTextures(): BaseTexture[];
  94760. /**
  94761. * Specifies if the material uses a texture
  94762. * @param texture defines the texture to check against the material
  94763. * @returns a boolean specifying if the material uses the texture
  94764. */
  94765. hasTexture(texture: BaseTexture): boolean;
  94766. /**
  94767. * Disposes the material
  94768. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94769. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94770. */
  94771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94772. /**
  94773. * Makes a duplicate of the material, and gives it a new name
  94774. * @param name defines the new name for the duplicated material
  94775. * @returns the cloned material
  94776. */
  94777. clone(name: string): StandardMaterial;
  94778. /**
  94779. * Serializes this material in a JSON representation
  94780. * @returns the serialized material object
  94781. */
  94782. serialize(): any;
  94783. /**
  94784. * Creates a standard material from parsed material data
  94785. * @param source defines the JSON representation of the material
  94786. * @param scene defines the hosting scene
  94787. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94788. * @returns a new standard material
  94789. */
  94790. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94791. /**
  94792. * Are diffuse textures enabled in the application.
  94793. */
  94794. static DiffuseTextureEnabled: boolean;
  94795. /**
  94796. * Are ambient textures enabled in the application.
  94797. */
  94798. static AmbientTextureEnabled: boolean;
  94799. /**
  94800. * Are opacity textures enabled in the application.
  94801. */
  94802. static OpacityTextureEnabled: boolean;
  94803. /**
  94804. * Are reflection textures enabled in the application.
  94805. */
  94806. static ReflectionTextureEnabled: boolean;
  94807. /**
  94808. * Are emissive textures enabled in the application.
  94809. */
  94810. static EmissiveTextureEnabled: boolean;
  94811. /**
  94812. * Are specular textures enabled in the application.
  94813. */
  94814. static SpecularTextureEnabled: boolean;
  94815. /**
  94816. * Are bump textures enabled in the application.
  94817. */
  94818. static BumpTextureEnabled: boolean;
  94819. /**
  94820. * Are lightmap textures enabled in the application.
  94821. */
  94822. static LightmapTextureEnabled: boolean;
  94823. /**
  94824. * Are refraction textures enabled in the application.
  94825. */
  94826. static RefractionTextureEnabled: boolean;
  94827. /**
  94828. * Are color grading textures enabled in the application.
  94829. */
  94830. static ColorGradingTextureEnabled: boolean;
  94831. /**
  94832. * Are fresnels enabled in the application.
  94833. */
  94834. static FresnelEnabled: boolean;
  94835. }
  94836. }
  94837. declare module BABYLON {
  94838. /**
  94839. * A class extending Texture allowing drawing on a texture
  94840. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94841. */
  94842. export class DynamicTexture extends Texture {
  94843. private _generateMipMaps;
  94844. private _canvas;
  94845. private _context;
  94846. private _engine;
  94847. /**
  94848. * Creates a DynamicTexture
  94849. * @param name defines the name of the texture
  94850. * @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
  94851. * @param scene defines the scene where you want the texture
  94852. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94853. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94854. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94855. */
  94856. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94857. /**
  94858. * Get the current class name of the texture useful for serialization or dynamic coding.
  94859. * @returns "DynamicTexture"
  94860. */
  94861. getClassName(): string;
  94862. /**
  94863. * Gets the current state of canRescale
  94864. */
  94865. readonly canRescale: boolean;
  94866. private _recreate;
  94867. /**
  94868. * Scales the texture
  94869. * @param ratio the scale factor to apply to both width and height
  94870. */
  94871. scale(ratio: number): void;
  94872. /**
  94873. * Resizes the texture
  94874. * @param width the new width
  94875. * @param height the new height
  94876. */
  94877. scaleTo(width: number, height: number): void;
  94878. /**
  94879. * Gets the context of the canvas used by the texture
  94880. * @returns the canvas context of the dynamic texture
  94881. */
  94882. getContext(): CanvasRenderingContext2D;
  94883. /**
  94884. * Clears the texture
  94885. */
  94886. clear(): void;
  94887. /**
  94888. * Updates the texture
  94889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94890. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94891. */
  94892. update(invertY?: boolean, premulAlpha?: boolean): void;
  94893. /**
  94894. * Draws text onto the texture
  94895. * @param text defines the text to be drawn
  94896. * @param x defines the placement of the text from the left
  94897. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94898. * @param font defines the font to be used with font-style, font-size, font-name
  94899. * @param color defines the color used for the text
  94900. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94901. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94902. * @param update defines whether texture is immediately update (default is true)
  94903. */
  94904. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94905. /**
  94906. * Clones the texture
  94907. * @returns the clone of the texture.
  94908. */
  94909. clone(): DynamicTexture;
  94910. /**
  94911. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94912. * @returns a serialized dynamic texture object
  94913. */
  94914. serialize(): any;
  94915. /** @hidden */
  94916. _rebuild(): void;
  94917. }
  94918. }
  94919. declare module BABYLON {
  94920. /** @hidden */
  94921. export var imageProcessingPixelShader: {
  94922. name: string;
  94923. shader: string;
  94924. };
  94925. }
  94926. declare module BABYLON {
  94927. /**
  94928. * ImageProcessingPostProcess
  94929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94930. */
  94931. export class ImageProcessingPostProcess extends PostProcess {
  94932. /**
  94933. * Default configuration related to image processing available in the PBR Material.
  94934. */
  94935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94936. /**
  94937. * Gets the image processing configuration used either in this material.
  94938. */
  94939. /**
  94940. * Sets the Default image processing configuration used either in the this material.
  94941. *
  94942. * If sets to null, the scene one is in use.
  94943. */
  94944. imageProcessingConfiguration: ImageProcessingConfiguration;
  94945. /**
  94946. * Keep track of the image processing observer to allow dispose and replace.
  94947. */
  94948. private _imageProcessingObserver;
  94949. /**
  94950. * Attaches a new image processing configuration to the PBR Material.
  94951. * @param configuration
  94952. */
  94953. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94954. /**
  94955. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94956. */
  94957. /**
  94958. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94959. */
  94960. colorCurves: Nullable<ColorCurves>;
  94961. /**
  94962. * Gets wether the color curves effect is enabled.
  94963. */
  94964. /**
  94965. * Sets wether the color curves effect is enabled.
  94966. */
  94967. colorCurvesEnabled: boolean;
  94968. /**
  94969. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94970. */
  94971. /**
  94972. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94973. */
  94974. colorGradingTexture: Nullable<BaseTexture>;
  94975. /**
  94976. * Gets wether the color grading effect is enabled.
  94977. */
  94978. /**
  94979. * Gets wether the color grading effect is enabled.
  94980. */
  94981. colorGradingEnabled: boolean;
  94982. /**
  94983. * Gets exposure used in the effect.
  94984. */
  94985. /**
  94986. * Sets exposure used in the effect.
  94987. */
  94988. exposure: number;
  94989. /**
  94990. * Gets wether tonemapping is enabled or not.
  94991. */
  94992. /**
  94993. * Sets wether tonemapping is enabled or not
  94994. */
  94995. toneMappingEnabled: boolean;
  94996. /**
  94997. * Gets contrast used in the effect.
  94998. */
  94999. /**
  95000. * Sets contrast used in the effect.
  95001. */
  95002. contrast: number;
  95003. /**
  95004. * Gets Vignette stretch size.
  95005. */
  95006. /**
  95007. * Sets Vignette stretch size.
  95008. */
  95009. vignetteStretch: number;
  95010. /**
  95011. * Gets Vignette centre X Offset.
  95012. */
  95013. /**
  95014. * Sets Vignette centre X Offset.
  95015. */
  95016. vignetteCentreX: number;
  95017. /**
  95018. * Gets Vignette centre Y Offset.
  95019. */
  95020. /**
  95021. * Sets Vignette centre Y Offset.
  95022. */
  95023. vignetteCentreY: number;
  95024. /**
  95025. * Gets Vignette weight or intensity of the vignette effect.
  95026. */
  95027. /**
  95028. * Sets Vignette weight or intensity of the vignette effect.
  95029. */
  95030. vignetteWeight: number;
  95031. /**
  95032. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95033. * if vignetteEnabled is set to true.
  95034. */
  95035. /**
  95036. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95037. * if vignetteEnabled is set to true.
  95038. */
  95039. vignetteColor: Color4;
  95040. /**
  95041. * Gets Camera field of view used by the Vignette effect.
  95042. */
  95043. /**
  95044. * Sets Camera field of view used by the Vignette effect.
  95045. */
  95046. vignetteCameraFov: number;
  95047. /**
  95048. * Gets the vignette blend mode allowing different kind of effect.
  95049. */
  95050. /**
  95051. * Sets the vignette blend mode allowing different kind of effect.
  95052. */
  95053. vignetteBlendMode: number;
  95054. /**
  95055. * Gets wether the vignette effect is enabled.
  95056. */
  95057. /**
  95058. * Sets wether the vignette effect is enabled.
  95059. */
  95060. vignetteEnabled: boolean;
  95061. private _fromLinearSpace;
  95062. /**
  95063. * Gets wether the input of the processing is in Gamma or Linear Space.
  95064. */
  95065. /**
  95066. * Sets wether the input of the processing is in Gamma or Linear Space.
  95067. */
  95068. fromLinearSpace: boolean;
  95069. /**
  95070. * Defines cache preventing GC.
  95071. */
  95072. private _defines;
  95073. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95074. /**
  95075. * "ImageProcessingPostProcess"
  95076. * @returns "ImageProcessingPostProcess"
  95077. */
  95078. getClassName(): string;
  95079. protected _updateParameters(): void;
  95080. dispose(camera?: Camera): void;
  95081. }
  95082. }
  95083. declare module BABYLON {
  95084. /**
  95085. * Options to modify the vr teleportation behavior.
  95086. */
  95087. export interface VRTeleportationOptions {
  95088. /**
  95089. * The name of the mesh which should be used as the teleportation floor. (default: null)
  95090. */
  95091. floorMeshName?: string;
  95092. /**
  95093. * A list of meshes to be used as the teleportation floor. (default: empty)
  95094. */
  95095. floorMeshes?: Mesh[];
  95096. }
  95097. /**
  95098. * Options to modify the vr experience helper's behavior.
  95099. */
  95100. export interface VRExperienceHelperOptions extends WebVROptions {
  95101. /**
  95102. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  95103. */
  95104. createDeviceOrientationCamera?: boolean;
  95105. /**
  95106. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  95107. */
  95108. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  95109. /**
  95110. * Uses the main button on the controller to toggle the laser casted. (default: true)
  95111. */
  95112. laserToggle?: boolean;
  95113. /**
  95114. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  95115. */
  95116. floorMeshes?: Mesh[];
  95117. }
  95118. /**
  95119. * Helps to quickly add VR support to an existing scene.
  95120. * See http://doc.babylonjs.com/how_to/webvr_helper
  95121. */
  95122. export class VRExperienceHelper {
  95123. /** Options to modify the vr experience helper's behavior. */
  95124. webVROptions: VRExperienceHelperOptions;
  95125. private _scene;
  95126. private _position;
  95127. private _btnVR;
  95128. private _btnVRDisplayed;
  95129. private _webVRsupported;
  95130. private _webVRready;
  95131. private _webVRrequesting;
  95132. private _webVRpresenting;
  95133. private _hasEnteredVR;
  95134. private _fullscreenVRpresenting;
  95135. private _canvas;
  95136. private _webVRCamera;
  95137. private _vrDeviceOrientationCamera;
  95138. private _deviceOrientationCamera;
  95139. private _existingCamera;
  95140. private _onKeyDown;
  95141. private _onVrDisplayPresentChange;
  95142. private _onVRDisplayChanged;
  95143. private _onVRRequestPresentStart;
  95144. private _onVRRequestPresentComplete;
  95145. /**
  95146. * Observable raised when entering VR.
  95147. */
  95148. onEnteringVRObservable: Observable<VRExperienceHelper>;
  95149. /**
  95150. * Observable raised when exiting VR.
  95151. */
  95152. onExitingVRObservable: Observable<VRExperienceHelper>;
  95153. /**
  95154. * Observable raised when controller mesh is loaded.
  95155. */
  95156. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95157. /** Return this.onEnteringVRObservable
  95158. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  95159. */
  95160. readonly onEnteringVR: Observable<VRExperienceHelper>;
  95161. /** Return this.onExitingVRObservable
  95162. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  95163. */
  95164. readonly onExitingVR: Observable<VRExperienceHelper>;
  95165. /** Return this.onControllerMeshLoadedObservable
  95166. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  95167. */
  95168. readonly onControllerMeshLoaded: Observable<WebVRController>;
  95169. private _rayLength;
  95170. private _useCustomVRButton;
  95171. private _teleportationRequested;
  95172. private _teleportActive;
  95173. private _floorMeshName;
  95174. private _floorMeshesCollection;
  95175. private _rotationAllowed;
  95176. private _teleportBackwardsVector;
  95177. private _teleportationTarget;
  95178. private _isDefaultTeleportationTarget;
  95179. private _postProcessMove;
  95180. private _teleportationFillColor;
  95181. private _teleportationBorderColor;
  95182. private _rotationAngle;
  95183. private _haloCenter;
  95184. private _cameraGazer;
  95185. private _padSensibilityUp;
  95186. private _padSensibilityDown;
  95187. private _leftController;
  95188. private _rightController;
  95189. /**
  95190. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  95191. */
  95192. onNewMeshSelected: Observable<AbstractMesh>;
  95193. /**
  95194. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  95195. */
  95196. onNewMeshPicked: Observable<PickingInfo>;
  95197. private _circleEase;
  95198. /**
  95199. * Observable raised before camera teleportation
  95200. */
  95201. onBeforeCameraTeleport: Observable<Vector3>;
  95202. /**
  95203. * Observable raised after camera teleportation
  95204. */
  95205. onAfterCameraTeleport: Observable<Vector3>;
  95206. /**
  95207. * Observable raised when current selected mesh gets unselected
  95208. */
  95209. onSelectedMeshUnselected: Observable<AbstractMesh>;
  95210. private _raySelectionPredicate;
  95211. /**
  95212. * To be optionaly changed by user to define custom ray selection
  95213. */
  95214. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  95215. /**
  95216. * To be optionaly changed by user to define custom selection logic (after ray selection)
  95217. */
  95218. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  95219. /**
  95220. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  95221. */
  95222. teleportationEnabled: boolean;
  95223. private _defaultHeight;
  95224. private _teleportationInitialized;
  95225. private _interactionsEnabled;
  95226. private _interactionsRequested;
  95227. private _displayGaze;
  95228. private _displayLaserPointer;
  95229. /**
  95230. * The mesh used to display where the user is going to teleport.
  95231. */
  95232. /**
  95233. * Sets the mesh to be used to display where the user is going to teleport.
  95234. */
  95235. teleportationTarget: Mesh;
  95236. /**
  95237. * 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
  95238. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  95239. * See http://doc.babylonjs.com/resources/baking_transformations
  95240. */
  95241. gazeTrackerMesh: Mesh;
  95242. /**
  95243. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  95244. */
  95245. updateGazeTrackerScale: boolean;
  95246. /**
  95247. * If the gaze trackers color should be updated when selecting meshes
  95248. */
  95249. updateGazeTrackerColor: boolean;
  95250. /**
  95251. * The gaze tracking mesh corresponding to the left controller
  95252. */
  95253. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  95254. /**
  95255. * The gaze tracking mesh corresponding to the right controller
  95256. */
  95257. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  95258. /**
  95259. * If the ray of the gaze should be displayed.
  95260. */
  95261. /**
  95262. * Sets if the ray of the gaze should be displayed.
  95263. */
  95264. displayGaze: boolean;
  95265. /**
  95266. * If the ray of the LaserPointer should be displayed.
  95267. */
  95268. /**
  95269. * Sets if the ray of the LaserPointer should be displayed.
  95270. */
  95271. displayLaserPointer: boolean;
  95272. /**
  95273. * The deviceOrientationCamera used as the camera when not in VR.
  95274. */
  95275. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95276. /**
  95277. * Based on the current WebVR support, returns the current VR camera used.
  95278. */
  95279. readonly currentVRCamera: Nullable<Camera>;
  95280. /**
  95281. * The webVRCamera which is used when in VR.
  95282. */
  95283. readonly webVRCamera: WebVRFreeCamera;
  95284. /**
  95285. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95286. */
  95287. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95288. private readonly _teleportationRequestInitiated;
  95289. /**
  95290. * Instantiates a VRExperienceHelper.
  95291. * Helps to quickly add VR support to an existing scene.
  95292. * @param scene The scene the VRExperienceHelper belongs to.
  95293. * @param webVROptions Options to modify the vr experience helper's behavior.
  95294. */
  95295. constructor(scene: Scene,
  95296. /** Options to modify the vr experience helper's behavior. */
  95297. webVROptions?: VRExperienceHelperOptions);
  95298. private _onDefaultMeshLoaded;
  95299. private _onResize;
  95300. private _onFullscreenChange;
  95301. /**
  95302. * Gets a value indicating if we are currently in VR mode.
  95303. */
  95304. readonly isInVRMode: boolean;
  95305. private onVrDisplayPresentChange;
  95306. private onVRDisplayChanged;
  95307. private moveButtonToBottomRight;
  95308. private displayVRButton;
  95309. private updateButtonVisibility;
  95310. private _cachedAngularSensibility;
  95311. /**
  95312. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95313. * Otherwise, will use the fullscreen API.
  95314. */
  95315. enterVR(): void;
  95316. /**
  95317. * Attempt to exit VR, or fullscreen.
  95318. */
  95319. exitVR(): void;
  95320. /**
  95321. * The position of the vr experience helper.
  95322. */
  95323. /**
  95324. * Sets the position of the vr experience helper.
  95325. */
  95326. position: Vector3;
  95327. /**
  95328. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95329. */
  95330. enableInteractions(): void;
  95331. private readonly _noControllerIsActive;
  95332. private beforeRender;
  95333. private _isTeleportationFloor;
  95334. /**
  95335. * Adds a floor mesh to be used for teleportation.
  95336. * @param floorMesh the mesh to be used for teleportation.
  95337. */
  95338. addFloorMesh(floorMesh: Mesh): void;
  95339. /**
  95340. * Removes a floor mesh from being used for teleportation.
  95341. * @param floorMesh the mesh to be removed.
  95342. */
  95343. removeFloorMesh(floorMesh: Mesh): void;
  95344. /**
  95345. * Enables interactions and teleportation using the VR controllers and gaze.
  95346. * @param vrTeleportationOptions options to modify teleportation behavior.
  95347. */
  95348. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95349. private _onNewGamepadConnected;
  95350. private _tryEnableInteractionOnController;
  95351. private _onNewGamepadDisconnected;
  95352. private _enableInteractionOnController;
  95353. private _checkTeleportWithRay;
  95354. private _checkRotate;
  95355. private _checkTeleportBackwards;
  95356. private _enableTeleportationOnController;
  95357. private _createTeleportationCircles;
  95358. private _displayTeleportationTarget;
  95359. private _hideTeleportationTarget;
  95360. private _rotateCamera;
  95361. private _moveTeleportationSelectorTo;
  95362. private _workingVector;
  95363. private _workingQuaternion;
  95364. private _workingMatrix;
  95365. /**
  95366. * Teleports the users feet to the desired location
  95367. * @param location The location where the user's feet should be placed
  95368. */
  95369. teleportCamera(location: Vector3): void;
  95370. private _convertNormalToDirectionOfRay;
  95371. private _castRayAndSelectObject;
  95372. private _notifySelectedMeshUnselected;
  95373. /**
  95374. * Sets the color of the laser ray from the vr controllers.
  95375. * @param color new color for the ray.
  95376. */
  95377. changeLaserColor(color: Color3): void;
  95378. /**
  95379. * Sets the color of the ray from the vr headsets gaze.
  95380. * @param color new color for the ray.
  95381. */
  95382. changeGazeColor(color: Color3): void;
  95383. /**
  95384. * Exits VR and disposes of the vr experience helper
  95385. */
  95386. dispose(): void;
  95387. /**
  95388. * Gets the name of the VRExperienceHelper class
  95389. * @returns "VRExperienceHelper"
  95390. */
  95391. getClassName(): string;
  95392. }
  95393. }
  95394. declare module BABYLON {
  95395. /**
  95396. * Manages an XRSession
  95397. * @see https://doc.babylonjs.com/how_to/webxr
  95398. */
  95399. export class WebXRSessionManager implements IDisposable {
  95400. private scene;
  95401. /**
  95402. * Fires every time a new xrFrame arrives which can be used to update the camera
  95403. */
  95404. onXRFrameObservable: Observable<any>;
  95405. /**
  95406. * Fires when the xr session is ended either by the device or manually done
  95407. */
  95408. onXRSessionEnded: Observable<any>;
  95409. /** @hidden */
  95410. _xrSession: XRSession;
  95411. /** @hidden */
  95412. _frameOfReference: XRFrameOfReference;
  95413. /** @hidden */
  95414. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95415. /** @hidden */
  95416. _currentXRFrame: Nullable<XRFrame>;
  95417. private _xrNavigator;
  95418. private _xrDevice;
  95419. private _tmpMatrix;
  95420. /**
  95421. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95422. * @param scene The scene which the session should be created for
  95423. */
  95424. constructor(scene: Scene);
  95425. /**
  95426. * Initializes the manager
  95427. * After initialization enterXR can be called to start an XR session
  95428. * @returns Promise which resolves after it is initialized
  95429. */
  95430. initializeAsync(): Promise<void>;
  95431. /**
  95432. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95433. * @param sessionCreationOptions xr options to create the session with
  95434. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95435. * @returns Promise which resolves after it enters XR
  95436. */
  95437. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95438. /**
  95439. * Stops the xrSession and restores the renderloop
  95440. * @returns Promise which resolves after it exits XR
  95441. */
  95442. exitXRAsync(): Promise<void>;
  95443. /**
  95444. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95445. * @param ray ray to cast into the environment
  95446. * @returns Promise which resolves with a collision point in the environment if it exists
  95447. */
  95448. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95449. /**
  95450. * Checks if a session would be supported for the creation options specified
  95451. * @param options creation options to check if they are supported
  95452. * @returns true if supported
  95453. */
  95454. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95455. /**
  95456. * @hidden
  95457. * Converts the render layer of xrSession to a render target
  95458. * @param session session to create render target for
  95459. * @param scene scene the new render target should be created for
  95460. */
  95461. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95462. /**
  95463. * Disposes of the session manager
  95464. */
  95465. dispose(): void;
  95466. }
  95467. }
  95468. declare module BABYLON {
  95469. /**
  95470. * WebXR Camera which holds the views for the xrSession
  95471. * @see https://doc.babylonjs.com/how_to/webxr
  95472. */
  95473. export class WebXRCamera extends FreeCamera {
  95474. private static _TmpMatrix;
  95475. /**
  95476. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95477. * @param name the name of the camera
  95478. * @param scene the scene to add the camera to
  95479. */
  95480. constructor(name: string, scene: Scene);
  95481. private _updateNumberOfRigCameras;
  95482. /** @hidden */
  95483. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95484. /**
  95485. * Updates the cameras position from the current pose information of the XR session
  95486. * @param xrSessionManager the session containing pose information
  95487. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95488. */
  95489. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95490. }
  95491. }
  95492. declare module BABYLON {
  95493. /**
  95494. * States of the webXR experience
  95495. */
  95496. export enum WebXRState {
  95497. /**
  95498. * Transitioning to being in XR mode
  95499. */
  95500. ENTERING_XR = 0,
  95501. /**
  95502. * Transitioning to non XR mode
  95503. */
  95504. EXITING_XR = 1,
  95505. /**
  95506. * In XR mode and presenting
  95507. */
  95508. IN_XR = 2,
  95509. /**
  95510. * Not entered XR mode
  95511. */
  95512. NOT_IN_XR = 3
  95513. }
  95514. /**
  95515. * Helper class used to enable XR
  95516. * @see https://doc.babylonjs.com/how_to/webxr
  95517. */
  95518. export class WebXRExperienceHelper implements IDisposable {
  95519. private scene;
  95520. /**
  95521. * 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
  95522. */
  95523. container: AbstractMesh;
  95524. /**
  95525. * Camera used to render xr content
  95526. */
  95527. camera: WebXRCamera;
  95528. /**
  95529. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95530. */
  95531. state: WebXRState;
  95532. private _setState;
  95533. private static _TmpVector;
  95534. /**
  95535. * Fires when the state of the experience helper has changed
  95536. */
  95537. onStateChangedObservable: Observable<WebXRState>;
  95538. /** @hidden */
  95539. _sessionManager: WebXRSessionManager;
  95540. private _nonVRCamera;
  95541. private _originalSceneAutoClear;
  95542. private _supported;
  95543. /**
  95544. * Creates the experience helper
  95545. * @param scene the scene to attach the experience helper to
  95546. * @returns a promise for the experience helper
  95547. */
  95548. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95549. /**
  95550. * Creates a WebXRExperienceHelper
  95551. * @param scene The scene the helper should be created in
  95552. */
  95553. private constructor();
  95554. /**
  95555. * Exits XR mode and returns the scene to its original state
  95556. * @returns promise that resolves after xr mode has exited
  95557. */
  95558. exitXRAsync(): Promise<void>;
  95559. /**
  95560. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95561. * @param sessionCreationOptions options for the XR session
  95562. * @param frameOfReference frame of reference of the XR session
  95563. * @returns promise that resolves after xr mode has entered
  95564. */
  95565. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95566. /**
  95567. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95568. * @param ray ray to cast into the environment
  95569. * @returns Promise which resolves with a collision point in the environment if it exists
  95570. */
  95571. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95572. /**
  95573. * Updates the global position of the camera by moving the camera's container
  95574. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95575. * @param position The desired global position of the camera
  95576. */
  95577. setPositionOfCameraUsingContainer(position: Vector3): void;
  95578. /**
  95579. * Rotates the xr camera by rotating the camera's container around the camera's position
  95580. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95581. * @param rotation the desired quaternion rotation to apply to the camera
  95582. */
  95583. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95584. /**
  95585. * Checks if the creation options are supported by the xr session
  95586. * @param options creation options
  95587. * @returns true if supported
  95588. */
  95589. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95590. /**
  95591. * Disposes of the experience helper
  95592. */
  95593. dispose(): void;
  95594. }
  95595. }
  95596. declare module BABYLON {
  95597. /**
  95598. * Button which can be used to enter a different mode of XR
  95599. */
  95600. export class WebXREnterExitUIButton {
  95601. /** button element */
  95602. element: HTMLElement;
  95603. /** XR initialization options for the button */
  95604. initializationOptions: XRSessionCreationOptions;
  95605. /**
  95606. * Creates a WebXREnterExitUIButton
  95607. * @param element button element
  95608. * @param initializationOptions XR initialization options for the button
  95609. */
  95610. constructor(
  95611. /** button element */
  95612. element: HTMLElement,
  95613. /** XR initialization options for the button */
  95614. initializationOptions: XRSessionCreationOptions);
  95615. /**
  95616. * Overwritable function which can be used to update the button's visuals when the state changes
  95617. * @param activeButton the current active button in the UI
  95618. */
  95619. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95620. }
  95621. /**
  95622. * Options to create the webXR UI
  95623. */
  95624. export class WebXREnterExitUIOptions {
  95625. /**
  95626. * Context to enter xr with
  95627. */
  95628. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95629. /**
  95630. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95631. */
  95632. customButtons?: Array<WebXREnterExitUIButton>;
  95633. }
  95634. /**
  95635. * UI to allow the user to enter/exit XR mode
  95636. */
  95637. export class WebXREnterExitUI implements IDisposable {
  95638. private scene;
  95639. private _overlay;
  95640. private _buttons;
  95641. private _activeButton;
  95642. /**
  95643. * Fired every time the active button is changed.
  95644. *
  95645. * When xr is entered via a button that launches xr that button will be the callback parameter
  95646. *
  95647. * When exiting xr the callback parameter will be null)
  95648. */
  95649. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95650. /**
  95651. * Creates UI to allow the user to enter/exit XR mode
  95652. * @param scene the scene to add the ui to
  95653. * @param helper the xr experience helper to enter/exit xr with
  95654. * @param options options to configure the UI
  95655. * @returns the created ui
  95656. */
  95657. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95658. private constructor();
  95659. private _updateButtons;
  95660. /**
  95661. * Disposes of the object
  95662. */
  95663. dispose(): void;
  95664. }
  95665. }
  95666. declare module BABYLON {
  95667. /**
  95668. * Represents an XR input
  95669. */
  95670. export class WebXRController {
  95671. /**
  95672. * 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
  95673. */
  95674. grip?: AbstractMesh;
  95675. /**
  95676. * Pointer which can be used to select objects or attach a visible laser to
  95677. */
  95678. pointer: AbstractMesh;
  95679. /**
  95680. * Creates the controller
  95681. * @see https://doc.babylonjs.com/how_to/webxr
  95682. * @param scene the scene which the controller should be associated to
  95683. */
  95684. constructor(scene: Scene);
  95685. /**
  95686. * Disposes of the object
  95687. */
  95688. dispose(): void;
  95689. }
  95690. /**
  95691. * XR input used to track XR inputs such as controllers/rays
  95692. */
  95693. export class WebXRInput implements IDisposable {
  95694. private helper;
  95695. /**
  95696. * XR controllers being tracked
  95697. */
  95698. controllers: Array<WebXRController>;
  95699. private _tmpMatrix;
  95700. private _frameObserver;
  95701. /**
  95702. * Initializes the WebXRInput
  95703. * @param helper experience helper which the input should be created for
  95704. */
  95705. constructor(helper: WebXRExperienceHelper);
  95706. /**
  95707. * Disposes of the object
  95708. */
  95709. dispose(): void;
  95710. }
  95711. }
  95712. declare module BABYLON {
  95713. /**
  95714. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95715. */
  95716. export class WebXRManagedOutputCanvas implements IDisposable {
  95717. private _canvas;
  95718. /**
  95719. * xrpresent context of the canvas which can be used to display/mirror xr content
  95720. */
  95721. canvasContext: Nullable<WebGLRenderingContext>;
  95722. /**
  95723. * Initializes the canvas to be added/removed upon entering/exiting xr
  95724. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95725. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95726. */
  95727. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95728. /**
  95729. * Disposes of the object
  95730. */
  95731. dispose(): void;
  95732. private _setManagedOutputCanvas;
  95733. private _addCanvas;
  95734. private _removeCanvas;
  95735. }
  95736. }
  95737. declare module BABYLON {
  95738. /**
  95739. * Contains an array of blocks representing the octree
  95740. */
  95741. export interface IOctreeContainer<T> {
  95742. /**
  95743. * Blocks within the octree
  95744. */
  95745. blocks: Array<OctreeBlock<T>>;
  95746. }
  95747. /**
  95748. * Class used to store a cell in an octree
  95749. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95750. */
  95751. export class OctreeBlock<T> {
  95752. /**
  95753. * Gets the content of the current block
  95754. */
  95755. entries: T[];
  95756. /**
  95757. * Gets the list of block children
  95758. */
  95759. blocks: Array<OctreeBlock<T>>;
  95760. private _depth;
  95761. private _maxDepth;
  95762. private _capacity;
  95763. private _minPoint;
  95764. private _maxPoint;
  95765. private _boundingVectors;
  95766. private _creationFunc;
  95767. /**
  95768. * Creates a new block
  95769. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95770. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95771. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95772. * @param depth defines the current depth of this block in the octree
  95773. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95774. * @param creationFunc defines a callback to call when an element is added to the block
  95775. */
  95776. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95777. /**
  95778. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95779. */
  95780. readonly capacity: number;
  95781. /**
  95782. * Gets the minimum vector (in world space) of the block's bounding box
  95783. */
  95784. readonly minPoint: Vector3;
  95785. /**
  95786. * Gets the maximum vector (in world space) of the block's bounding box
  95787. */
  95788. readonly maxPoint: Vector3;
  95789. /**
  95790. * Add a new element to this block
  95791. * @param entry defines the element to add
  95792. */
  95793. addEntry(entry: T): void;
  95794. /**
  95795. * Remove an element from this block
  95796. * @param entry defines the element to remove
  95797. */
  95798. removeEntry(entry: T): void;
  95799. /**
  95800. * Add an array of elements to this block
  95801. * @param entries defines the array of elements to add
  95802. */
  95803. addEntries(entries: T[]): void;
  95804. /**
  95805. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95806. * @param frustumPlanes defines the frustum planes to test
  95807. * @param selection defines the array to store current content if selection is positive
  95808. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95809. */
  95810. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95811. /**
  95812. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95813. * @param sphereCenter defines the bounding sphere center
  95814. * @param sphereRadius defines the bounding sphere radius
  95815. * @param selection defines the array to store current content if selection is positive
  95816. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95817. */
  95818. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95819. /**
  95820. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95821. * @param ray defines the ray to test with
  95822. * @param selection defines the array to store current content if selection is positive
  95823. */
  95824. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95825. /**
  95826. * Subdivide the content into child blocks (this block will then be empty)
  95827. */
  95828. createInnerBlocks(): void;
  95829. /**
  95830. * @hidden
  95831. */
  95832. 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;
  95833. }
  95834. }
  95835. declare module BABYLON {
  95836. /**
  95837. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95839. */
  95840. export class Octree<T> {
  95841. /** 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.) */
  95842. maxDepth: number;
  95843. /**
  95844. * Blocks within the octree containing objects
  95845. */
  95846. blocks: Array<OctreeBlock<T>>;
  95847. /**
  95848. * Content stored in the octree
  95849. */
  95850. dynamicContent: T[];
  95851. private _maxBlockCapacity;
  95852. private _selectionContent;
  95853. private _creationFunc;
  95854. /**
  95855. * Creates a octree
  95856. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95857. * @param creationFunc function to be used to instatiate the octree
  95858. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95859. * @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.)
  95860. */
  95861. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95862. /** 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.) */
  95863. maxDepth?: number);
  95864. /**
  95865. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95866. * @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);
  95867. * @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);
  95868. * @param entries meshes to be added to the octree blocks
  95869. */
  95870. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95871. /**
  95872. * Adds a mesh to the octree
  95873. * @param entry Mesh to add to the octree
  95874. */
  95875. addMesh(entry: T): void;
  95876. /**
  95877. * Remove an element from the octree
  95878. * @param entry defines the element to remove
  95879. */
  95880. removeMesh(entry: T): void;
  95881. /**
  95882. * Selects an array of meshes within the frustum
  95883. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95884. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95885. * @returns array of meshes within the frustum
  95886. */
  95887. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95888. /**
  95889. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95890. * @param sphereCenter defines the bounding sphere center
  95891. * @param sphereRadius defines the bounding sphere radius
  95892. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95893. * @returns an array of objects that intersect the sphere
  95894. */
  95895. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95896. /**
  95897. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95898. * @param ray defines the ray to test with
  95899. * @returns array of intersected objects
  95900. */
  95901. intersectsRay(ray: Ray): SmartArray<T>;
  95902. /**
  95903. * Adds a mesh into the octree block if it intersects the block
  95904. */
  95905. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95906. /**
  95907. * Adds a submesh into the octree block if it intersects the block
  95908. */
  95909. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95910. }
  95911. }
  95912. declare module BABYLON {
  95913. interface Scene {
  95914. /**
  95915. * @hidden
  95916. * Backing Filed
  95917. */
  95918. _selectionOctree: Octree<AbstractMesh>;
  95919. /**
  95920. * Gets the octree used to boost mesh selection (picking)
  95921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95922. */
  95923. selectionOctree: Octree<AbstractMesh>;
  95924. /**
  95925. * Creates or updates the octree used to boost selection (picking)
  95926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95927. * @param maxCapacity defines the maximum capacity per leaf
  95928. * @param maxDepth defines the maximum depth of the octree
  95929. * @returns an octree of AbstractMesh
  95930. */
  95931. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95932. }
  95933. interface AbstractMesh {
  95934. /**
  95935. * @hidden
  95936. * Backing Field
  95937. */
  95938. _submeshesOctree: Octree<SubMesh>;
  95939. /**
  95940. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95941. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95942. * @param maxCapacity defines the maximum size of each block (64 by default)
  95943. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95944. * @returns the new octree
  95945. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95947. */
  95948. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95949. }
  95950. /**
  95951. * Defines the octree scene component responsible to manage any octrees
  95952. * in a given scene.
  95953. */
  95954. export class OctreeSceneComponent {
  95955. /**
  95956. * The component name helpfull to identify the component in the list of scene components.
  95957. */
  95958. readonly name: string;
  95959. /**
  95960. * The scene the component belongs to.
  95961. */
  95962. scene: Scene;
  95963. /**
  95964. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95965. */
  95966. readonly checksIsEnabled: boolean;
  95967. /**
  95968. * Creates a new instance of the component for the given scene
  95969. * @param scene Defines the scene to register the component in
  95970. */
  95971. constructor(scene: Scene);
  95972. /**
  95973. * Registers the component in a given scene
  95974. */
  95975. register(): void;
  95976. /**
  95977. * Return the list of active meshes
  95978. * @returns the list of active meshes
  95979. */
  95980. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95981. /**
  95982. * Return the list of active sub meshes
  95983. * @param mesh The mesh to get the candidates sub meshes from
  95984. * @returns the list of active sub meshes
  95985. */
  95986. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95987. private _tempRay;
  95988. /**
  95989. * Return the list of sub meshes intersecting with a given local ray
  95990. * @param mesh defines the mesh to find the submesh for
  95991. * @param localRay defines the ray in local space
  95992. * @returns the list of intersecting sub meshes
  95993. */
  95994. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95995. /**
  95996. * Return the list of sub meshes colliding with a collider
  95997. * @param mesh defines the mesh to find the submesh for
  95998. * @param collider defines the collider to evaluate the collision against
  95999. * @returns the list of colliding sub meshes
  96000. */
  96001. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96002. /**
  96003. * Rebuilds the elements related to this component in case of
  96004. * context lost for instance.
  96005. */
  96006. rebuild(): void;
  96007. /**
  96008. * Disposes the component and the associated ressources.
  96009. */
  96010. dispose(): void;
  96011. }
  96012. }
  96013. declare module BABYLON {
  96014. /**
  96015. * Renders a layer on top of an existing scene
  96016. */
  96017. export class UtilityLayerRenderer implements IDisposable {
  96018. /** the original scene that will be rendered on top of */
  96019. originalScene: Scene;
  96020. private _pointerCaptures;
  96021. private _lastPointerEvents;
  96022. private static _DefaultUtilityLayer;
  96023. private static _DefaultKeepDepthUtilityLayer;
  96024. /**
  96025. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  96026. */
  96027. pickUtilitySceneFirst: boolean;
  96028. /**
  96029. * 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)
  96030. */
  96031. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  96032. /**
  96033. * 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)
  96034. */
  96035. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  96036. /**
  96037. * The scene that is rendered on top of the original scene
  96038. */
  96039. utilityLayerScene: Scene;
  96040. /**
  96041. * If the utility layer should automatically be rendered on top of existing scene
  96042. */
  96043. shouldRender: boolean;
  96044. /**
  96045. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  96046. */
  96047. onlyCheckPointerDownEvents: boolean;
  96048. /**
  96049. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  96050. */
  96051. processAllEvents: boolean;
  96052. /**
  96053. * Observable raised when the pointer move from the utility layer scene to the main scene
  96054. */
  96055. onPointerOutObservable: Observable<number>;
  96056. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  96057. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  96058. private _afterRenderObserver;
  96059. private _sceneDisposeObserver;
  96060. private _originalPointerObserver;
  96061. /**
  96062. * Instantiates a UtilityLayerRenderer
  96063. * @param originalScene the original scene that will be rendered on top of
  96064. * @param handleEvents boolean indicating if the utility layer should handle events
  96065. */
  96066. constructor(
  96067. /** the original scene that will be rendered on top of */
  96068. originalScene: Scene, handleEvents?: boolean);
  96069. private _notifyObservers;
  96070. /**
  96071. * Renders the utility layers scene on top of the original scene
  96072. */
  96073. render(): void;
  96074. /**
  96075. * Disposes of the renderer
  96076. */
  96077. dispose(): void;
  96078. private _updateCamera;
  96079. }
  96080. }
  96081. declare module BABYLON {
  96082. /**
  96083. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  96084. */
  96085. export class Gizmo implements IDisposable {
  96086. /** The utility layer the gizmo will be added to */
  96087. gizmoLayer: UtilityLayerRenderer;
  96088. /**
  96089. * The root mesh of the gizmo
  96090. */
  96091. protected _rootMesh: Mesh;
  96092. private _attachedMesh;
  96093. /**
  96094. * Ratio for the scale of the gizmo (Default: 1)
  96095. */
  96096. scaleRatio: number;
  96097. private _tmpMatrix;
  96098. /**
  96099. * If a custom mesh has been set (Default: false)
  96100. */
  96101. protected _customMeshSet: boolean;
  96102. /**
  96103. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  96104. * * When set, interactions will be enabled
  96105. */
  96106. attachedMesh: Nullable<AbstractMesh>;
  96107. /**
  96108. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  96109. * @param mesh The mesh to replace the default mesh of the gizmo
  96110. */
  96111. setCustomMesh(mesh: Mesh): void;
  96112. /**
  96113. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  96114. */
  96115. updateGizmoRotationToMatchAttachedMesh: boolean;
  96116. /**
  96117. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  96118. */
  96119. updateGizmoPositionToMatchAttachedMesh: boolean;
  96120. /**
  96121. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  96122. */
  96123. protected _updateScale: boolean;
  96124. protected _interactionsEnabled: boolean;
  96125. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96126. private _beforeRenderObserver;
  96127. /**
  96128. * Creates a gizmo
  96129. * @param gizmoLayer The utility layer the gizmo will be added to
  96130. */
  96131. constructor(
  96132. /** The utility layer the gizmo will be added to */
  96133. gizmoLayer?: UtilityLayerRenderer);
  96134. private _tempVector;
  96135. /**
  96136. * @hidden
  96137. * Updates the gizmo to match the attached mesh's position/rotation
  96138. */
  96139. protected _update(): void;
  96140. /**
  96141. * Disposes of the gizmo
  96142. */
  96143. dispose(): void;
  96144. }
  96145. }
  96146. declare module BABYLON {
  96147. /**
  96148. * Single axis drag gizmo
  96149. */
  96150. export class AxisDragGizmo extends Gizmo {
  96151. /**
  96152. * Drag behavior responsible for the gizmos dragging interactions
  96153. */
  96154. dragBehavior: PointerDragBehavior;
  96155. private _pointerObserver;
  96156. /**
  96157. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  96158. */
  96159. snapDistance: number;
  96160. /**
  96161. * Event that fires each time the gizmo snaps to a new location.
  96162. * * snapDistance is the the change in distance
  96163. */
  96164. onSnapObservable: Observable<{
  96165. snapDistance: number;
  96166. }>;
  96167. /** @hidden */
  96168. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  96169. /** @hidden */
  96170. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  96171. /**
  96172. * Creates an AxisDragGizmo
  96173. * @param gizmoLayer The utility layer the gizmo will be added to
  96174. * @param dragAxis The axis which the gizmo will be able to drag on
  96175. * @param color The color of the gizmo
  96176. */
  96177. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96178. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96179. /**
  96180. * Disposes of the gizmo
  96181. */
  96182. dispose(): void;
  96183. }
  96184. }
  96185. declare module BABYLON.Debug {
  96186. /**
  96187. * The Axes viewer will show 3 axes in a specific point in space
  96188. */
  96189. export class AxesViewer {
  96190. private _xAxis;
  96191. private _yAxis;
  96192. private _zAxis;
  96193. private _scaleLinesFactor;
  96194. private _instanced;
  96195. /**
  96196. * Gets the hosting scene
  96197. */
  96198. scene: Scene;
  96199. /**
  96200. * Gets or sets a number used to scale line length
  96201. */
  96202. scaleLines: number;
  96203. /** Gets the node hierarchy used to render x-axis */
  96204. readonly xAxis: TransformNode;
  96205. /** Gets the node hierarchy used to render y-axis */
  96206. readonly yAxis: TransformNode;
  96207. /** Gets the node hierarchy used to render z-axis */
  96208. readonly zAxis: TransformNode;
  96209. /**
  96210. * Creates a new AxesViewer
  96211. * @param scene defines the hosting scene
  96212. * @param scaleLines defines a number used to scale line length (1 by default)
  96213. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96214. * @param xAxis defines the node hierarchy used to render the x-axis
  96215. * @param yAxis defines the node hierarchy used to render the y-axis
  96216. * @param zAxis defines the node hierarchy used to render the z-axis
  96217. */
  96218. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96219. /**
  96220. * Force the viewer to update
  96221. * @param position defines the position of the viewer
  96222. * @param xaxis defines the x axis of the viewer
  96223. * @param yaxis defines the y axis of the viewer
  96224. * @param zaxis defines the z axis of the viewer
  96225. */
  96226. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96227. /**
  96228. * Creates an instance of this axes viewer.
  96229. * @returns a new axes viewer with instanced meshes
  96230. */
  96231. createInstance(): AxesViewer;
  96232. /** Releases resources */
  96233. dispose(): void;
  96234. private static _SetRenderingGroupId;
  96235. }
  96236. }
  96237. declare module BABYLON.Debug {
  96238. /**
  96239. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96240. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96241. */
  96242. export class BoneAxesViewer extends AxesViewer {
  96243. /**
  96244. * Gets or sets the target mesh where to display the axes viewer
  96245. */
  96246. mesh: Nullable<Mesh>;
  96247. /**
  96248. * Gets or sets the target bone where to display the axes viewer
  96249. */
  96250. bone: Nullable<Bone>;
  96251. /** Gets current position */
  96252. pos: Vector3;
  96253. /** Gets direction of X axis */
  96254. xaxis: Vector3;
  96255. /** Gets direction of Y axis */
  96256. yaxis: Vector3;
  96257. /** Gets direction of Z axis */
  96258. zaxis: Vector3;
  96259. /**
  96260. * Creates a new BoneAxesViewer
  96261. * @param scene defines the hosting scene
  96262. * @param bone defines the target bone
  96263. * @param mesh defines the target mesh
  96264. * @param scaleLines defines a scaling factor for line length (1 by default)
  96265. */
  96266. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96267. /**
  96268. * Force the viewer to update
  96269. */
  96270. update(): void;
  96271. /** Releases resources */
  96272. dispose(): void;
  96273. }
  96274. }
  96275. declare module BABYLON {
  96276. /**
  96277. * Interface used to define scene explorer extensibility option
  96278. */
  96279. export interface IExplorerExtensibilityOption {
  96280. /**
  96281. * Define the option label
  96282. */
  96283. label: string;
  96284. /**
  96285. * Defines the action to execute on click
  96286. */
  96287. action: (entity: any) => void;
  96288. }
  96289. /**
  96290. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96291. */
  96292. export interface IExplorerExtensibilityGroup {
  96293. /**
  96294. * Defines a predicate to test if a given type mut be extended
  96295. */
  96296. predicate: (entity: any) => boolean;
  96297. /**
  96298. * Gets the list of options added to a type
  96299. */
  96300. entries: IExplorerExtensibilityOption[];
  96301. }
  96302. /**
  96303. * Interface used to define the options to use to create the Inspector
  96304. */
  96305. export interface IInspectorOptions {
  96306. /**
  96307. * Display in overlay mode (default: false)
  96308. */
  96309. overlay?: boolean;
  96310. /**
  96311. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96312. */
  96313. globalRoot?: HTMLElement;
  96314. /**
  96315. * Display the Scene explorer
  96316. */
  96317. showExplorer?: boolean;
  96318. /**
  96319. * Display the property inspector
  96320. */
  96321. showInspector?: boolean;
  96322. /**
  96323. * Display in embed mode (both panes on the right)
  96324. */
  96325. embedMode?: boolean;
  96326. /**
  96327. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96328. */
  96329. handleResize?: boolean;
  96330. /**
  96331. * Allow the panes to popup (default: true)
  96332. */
  96333. enablePopup?: boolean;
  96334. /**
  96335. * Allow the panes to be closed by users (default: true)
  96336. */
  96337. enableClose?: boolean;
  96338. /**
  96339. * Optional list of extensibility entries
  96340. */
  96341. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96342. }
  96343. interface Scene {
  96344. /**
  96345. * @hidden
  96346. * Backing field
  96347. */
  96348. _debugLayer: DebugLayer;
  96349. /**
  96350. * Gets the debug layer (aka Inspector) associated with the scene
  96351. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96352. */
  96353. debugLayer: DebugLayer;
  96354. }
  96355. /**
  96356. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96357. * what is happening in your scene
  96358. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96359. */
  96360. export class DebugLayer {
  96361. /**
  96362. * Define the url to get the inspector script from.
  96363. * By default it uses the babylonjs CDN.
  96364. * @ignoreNaming
  96365. */
  96366. static InspectorURL: string;
  96367. private _scene;
  96368. private BJSINSPECTOR;
  96369. /**
  96370. * Observable triggered when a property is changed through the inspector.
  96371. */
  96372. onPropertyChangedObservable: Observable<{
  96373. object: any;
  96374. property: string;
  96375. value: any;
  96376. initialValue: any;
  96377. }>;
  96378. /**
  96379. * Instantiates a new debug layer.
  96380. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96381. * what is happening in your scene
  96382. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96383. * @param scene Defines the scene to inspect
  96384. */
  96385. constructor(scene: Scene);
  96386. /** Creates the inspector window. */
  96387. private _createInspector;
  96388. /** Get the inspector from bundle or global */
  96389. private _getGlobalInspector;
  96390. /**
  96391. * Get if the inspector is visible or not.
  96392. * @returns true if visible otherwise, false
  96393. */
  96394. isVisible(): boolean;
  96395. /**
  96396. * Hide the inspector and close its window.
  96397. */
  96398. hide(): void;
  96399. /**
  96400. * Launch the debugLayer.
  96401. * @param config Define the configuration of the inspector
  96402. */
  96403. show(config?: IInspectorOptions): void;
  96404. }
  96405. }
  96406. declare module BABYLON.Debug {
  96407. /**
  96408. * Used to show the physics impostor around the specific mesh
  96409. */
  96410. export class PhysicsViewer {
  96411. /** @hidden */
  96412. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96413. /** @hidden */
  96414. protected _meshes: Array<Nullable<AbstractMesh>>;
  96415. /** @hidden */
  96416. protected _scene: Nullable<Scene>;
  96417. /** @hidden */
  96418. protected _numMeshes: number;
  96419. /** @hidden */
  96420. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96421. private _renderFunction;
  96422. private _utilityLayer;
  96423. private _debugBoxMesh;
  96424. private _debugSphereMesh;
  96425. private _debugMaterial;
  96426. /**
  96427. * Creates a new PhysicsViewer
  96428. * @param scene defines the hosting scene
  96429. */
  96430. constructor(scene: Scene);
  96431. /** @hidden */
  96432. protected _updateDebugMeshes(): void;
  96433. /**
  96434. * Renders a specified physic impostor
  96435. * @param impostor defines the impostor to render
  96436. * @returns the new debug mesh used to render the impostor
  96437. */
  96438. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96439. /**
  96440. * Hides a specified physic impostor
  96441. * @param impostor defines the impostor to hide
  96442. */
  96443. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96444. private _getDebugMaterial;
  96445. private _getDebugBoxMesh;
  96446. private _getDebugSphereMesh;
  96447. private _getDebugMesh;
  96448. /** Releases all resources */
  96449. dispose(): void;
  96450. }
  96451. }
  96452. declare module BABYLON {
  96453. /**
  96454. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96455. * in order to better appreciate the issue one might have.
  96456. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96457. */
  96458. export class RayHelper {
  96459. /**
  96460. * Defines the ray we are currently tryin to visualize.
  96461. */
  96462. ray: Nullable<Ray>;
  96463. private _renderPoints;
  96464. private _renderLine;
  96465. private _renderFunction;
  96466. private _scene;
  96467. private _updateToMeshFunction;
  96468. private _attachedToMesh;
  96469. private _meshSpaceDirection;
  96470. private _meshSpaceOrigin;
  96471. /**
  96472. * Helper function to create a colored helper in a scene in one line.
  96473. * @param ray Defines the ray we are currently tryin to visualize
  96474. * @param scene Defines the scene the ray is used in
  96475. * @param color Defines the color we want to see the ray in
  96476. * @returns The newly created ray helper.
  96477. */
  96478. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96479. /**
  96480. * Instantiate a new ray helper.
  96481. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96482. * in order to better appreciate the issue one might have.
  96483. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96484. * @param ray Defines the ray we are currently tryin to visualize
  96485. */
  96486. constructor(ray: Ray);
  96487. /**
  96488. * Shows the ray we are willing to debug.
  96489. * @param scene Defines the scene the ray needs to be rendered in
  96490. * @param color Defines the color the ray needs to be rendered in
  96491. */
  96492. show(scene: Scene, color?: Color3): void;
  96493. /**
  96494. * Hides the ray we are debugging.
  96495. */
  96496. hide(): void;
  96497. private _render;
  96498. /**
  96499. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96500. * @param mesh Defines the mesh we want the helper attached to
  96501. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96502. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96503. * @param length Defines the length of the ray
  96504. */
  96505. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96506. /**
  96507. * Detach the ray helper from the mesh it has previously been attached to.
  96508. */
  96509. detachFromMesh(): void;
  96510. private _updateToMesh;
  96511. /**
  96512. * Dispose the helper and release its associated resources.
  96513. */
  96514. dispose(): void;
  96515. }
  96516. }
  96517. declare module BABYLON.Debug {
  96518. /**
  96519. * Class used to render a debug view of a given skeleton
  96520. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96521. */
  96522. export class SkeletonViewer {
  96523. /** defines the skeleton to render */
  96524. skeleton: Skeleton;
  96525. /** defines the mesh attached to the skeleton */
  96526. mesh: AbstractMesh;
  96527. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96528. autoUpdateBonesMatrices: boolean;
  96529. /** defines the rendering group id to use with the viewer */
  96530. renderingGroupId: number;
  96531. /** Gets or sets the color used to render the skeleton */
  96532. color: Color3;
  96533. private _scene;
  96534. private _debugLines;
  96535. private _debugMesh;
  96536. private _isEnabled;
  96537. private _renderFunction;
  96538. private _utilityLayer;
  96539. /**
  96540. * Returns the mesh used to render the bones
  96541. */
  96542. readonly debugMesh: Nullable<LinesMesh>;
  96543. /**
  96544. * Creates a new SkeletonViewer
  96545. * @param skeleton defines the skeleton to render
  96546. * @param mesh defines the mesh attached to the skeleton
  96547. * @param scene defines the hosting scene
  96548. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96549. * @param renderingGroupId defines the rendering group id to use with the viewer
  96550. */
  96551. constructor(
  96552. /** defines the skeleton to render */
  96553. skeleton: Skeleton,
  96554. /** defines the mesh attached to the skeleton */
  96555. mesh: AbstractMesh, scene: Scene,
  96556. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96557. autoUpdateBonesMatrices?: boolean,
  96558. /** defines the rendering group id to use with the viewer */
  96559. renderingGroupId?: number);
  96560. /** Gets or sets a boolean indicating if the viewer is enabled */
  96561. isEnabled: boolean;
  96562. private _getBonePosition;
  96563. private _getLinesForBonesWithLength;
  96564. private _getLinesForBonesNoLength;
  96565. /** Update the viewer to sync with current skeleton state */
  96566. update(): void;
  96567. /** Release associated resources */
  96568. dispose(): void;
  96569. }
  96570. }
  96571. declare module BABYLON {
  96572. /**
  96573. * Options to create the null engine
  96574. */
  96575. export class NullEngineOptions {
  96576. /**
  96577. * Render width (Default: 512)
  96578. */
  96579. renderWidth: number;
  96580. /**
  96581. * Render height (Default: 256)
  96582. */
  96583. renderHeight: number;
  96584. /**
  96585. * Texture size (Default: 512)
  96586. */
  96587. textureSize: number;
  96588. /**
  96589. * If delta time between frames should be constant
  96590. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96591. */
  96592. deterministicLockstep: boolean;
  96593. /**
  96594. * Maximum about of steps between frames (Default: 4)
  96595. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96596. */
  96597. lockstepMaxSteps: number;
  96598. }
  96599. /**
  96600. * The null engine class provides support for headless version of babylon.js.
  96601. * This can be used in server side scenario or for testing purposes
  96602. */
  96603. export class NullEngine extends Engine {
  96604. private _options;
  96605. /**
  96606. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96607. */
  96608. isDeterministicLockStep(): boolean;
  96609. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96610. getLockstepMaxSteps(): number;
  96611. /**
  96612. * Sets hardware scaling, used to save performance if needed
  96613. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96614. */
  96615. getHardwareScalingLevel(): number;
  96616. constructor(options?: NullEngineOptions);
  96617. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96618. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96619. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96620. getRenderWidth(useScreen?: boolean): number;
  96621. getRenderHeight(useScreen?: boolean): number;
  96622. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96623. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96624. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96625. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96626. bindSamplers(effect: Effect): void;
  96627. enableEffect(effect: Effect): void;
  96628. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96629. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96630. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96631. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96632. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96633. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96634. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96635. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96636. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96637. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96638. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96639. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96640. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96641. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96642. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96643. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96644. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96645. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96646. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96647. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96648. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96649. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96650. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96651. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96652. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96653. bindBuffers(vertexBuffers: {
  96654. [key: string]: VertexBuffer;
  96655. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96656. wipeCaches(bruteForce?: boolean): void;
  96657. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96658. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96659. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96660. /** @hidden */
  96661. _createTexture(): WebGLTexture;
  96662. /** @hidden */
  96663. _releaseTexture(texture: InternalTexture): void;
  96664. 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;
  96665. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96666. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96667. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96668. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96669. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96670. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96671. areAllEffectsReady(): boolean;
  96672. /**
  96673. * @hidden
  96674. * Get the current error code of the webGL context
  96675. * @returns the error code
  96676. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96677. */
  96678. getError(): number;
  96679. /** @hidden */
  96680. _getUnpackAlignement(): number;
  96681. /** @hidden */
  96682. _unpackFlipY(value: boolean): void;
  96683. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96684. /**
  96685. * Updates a dynamic vertex buffer.
  96686. * @param vertexBuffer the vertex buffer to update
  96687. * @param data the data used to update the vertex buffer
  96688. * @param byteOffset the byte offset of the data (optional)
  96689. * @param byteLength the byte length of the data (optional)
  96690. */
  96691. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96692. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96693. /** @hidden */
  96694. _bindTexture(channel: number, texture: InternalTexture): void;
  96695. /** @hidden */
  96696. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96697. releaseEffects(): void;
  96698. displayLoadingUI(): void;
  96699. hideLoadingUI(): void;
  96700. /** @hidden */
  96701. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96702. /** @hidden */
  96703. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96704. /** @hidden */
  96705. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96706. /** @hidden */
  96707. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96708. }
  96709. }
  96710. declare module BABYLON {
  96711. /** @hidden */
  96712. export class _OcclusionDataStorage {
  96713. /** @hidden */
  96714. occlusionInternalRetryCounter: number;
  96715. /** @hidden */
  96716. isOcclusionQueryInProgress: boolean;
  96717. /** @hidden */
  96718. isOccluded: boolean;
  96719. /** @hidden */
  96720. occlusionRetryCount: number;
  96721. /** @hidden */
  96722. occlusionType: number;
  96723. /** @hidden */
  96724. occlusionQueryAlgorithmType: number;
  96725. }
  96726. interface Engine {
  96727. /**
  96728. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96729. * @return the new query
  96730. */
  96731. createQuery(): WebGLQuery;
  96732. /**
  96733. * Delete and release a webGL query
  96734. * @param query defines the query to delete
  96735. * @return the current engine
  96736. */
  96737. deleteQuery(query: WebGLQuery): Engine;
  96738. /**
  96739. * Check if a given query has resolved and got its value
  96740. * @param query defines the query to check
  96741. * @returns true if the query got its value
  96742. */
  96743. isQueryResultAvailable(query: WebGLQuery): boolean;
  96744. /**
  96745. * Gets the value of a given query
  96746. * @param query defines the query to check
  96747. * @returns the value of the query
  96748. */
  96749. getQueryResult(query: WebGLQuery): number;
  96750. /**
  96751. * Initiates an occlusion query
  96752. * @param algorithmType defines the algorithm to use
  96753. * @param query defines the query to use
  96754. * @returns the current engine
  96755. * @see http://doc.babylonjs.com/features/occlusionquery
  96756. */
  96757. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96758. /**
  96759. * Ends an occlusion query
  96760. * @see http://doc.babylonjs.com/features/occlusionquery
  96761. * @param algorithmType defines the algorithm to use
  96762. * @returns the current engine
  96763. */
  96764. endOcclusionQuery(algorithmType: number): Engine;
  96765. /**
  96766. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96767. * Please note that only one query can be issued at a time
  96768. * @returns a time token used to track the time span
  96769. */
  96770. startTimeQuery(): Nullable<_TimeToken>;
  96771. /**
  96772. * Ends a time query
  96773. * @param token defines the token used to measure the time span
  96774. * @returns the time spent (in ns)
  96775. */
  96776. endTimeQuery(token: _TimeToken): int;
  96777. /** @hidden */
  96778. _currentNonTimestampToken: Nullable<_TimeToken>;
  96779. /** @hidden */
  96780. _createTimeQuery(): WebGLQuery;
  96781. /** @hidden */
  96782. _deleteTimeQuery(query: WebGLQuery): void;
  96783. /** @hidden */
  96784. _getGlAlgorithmType(algorithmType: number): number;
  96785. /** @hidden */
  96786. _getTimeQueryResult(query: WebGLQuery): any;
  96787. /** @hidden */
  96788. _getTimeQueryAvailability(query: WebGLQuery): any;
  96789. }
  96790. interface AbstractMesh {
  96791. /**
  96792. * Backing filed
  96793. * @hidden
  96794. */
  96795. __occlusionDataStorage: _OcclusionDataStorage;
  96796. /**
  96797. * Access property
  96798. * @hidden
  96799. */
  96800. _occlusionDataStorage: _OcclusionDataStorage;
  96801. /**
  96802. * 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.
  96803. * The default value is -1 which means don't break the query and wait till the result
  96804. * @see http://doc.babylonjs.com/features/occlusionquery
  96805. */
  96806. occlusionRetryCount: number;
  96807. /**
  96808. * 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:
  96809. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96810. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96811. * * 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.
  96812. * @see http://doc.babylonjs.com/features/occlusionquery
  96813. */
  96814. occlusionType: number;
  96815. /**
  96816. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96817. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96818. * * 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.
  96819. * @see http://doc.babylonjs.com/features/occlusionquery
  96820. */
  96821. occlusionQueryAlgorithmType: number;
  96822. /**
  96823. * 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
  96824. * @see http://doc.babylonjs.com/features/occlusionquery
  96825. */
  96826. isOccluded: boolean;
  96827. /**
  96828. * Flag to check the progress status of the query
  96829. * @see http://doc.babylonjs.com/features/occlusionquery
  96830. */
  96831. isOcclusionQueryInProgress: boolean;
  96832. }
  96833. }
  96834. declare module BABYLON {
  96835. /** @hidden */
  96836. export var _forceTransformFeedbackToBundle: boolean;
  96837. interface Engine {
  96838. /**
  96839. * Creates a webGL transform feedback object
  96840. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96841. * @returns the webGL transform feedback object
  96842. */
  96843. createTransformFeedback(): WebGLTransformFeedback;
  96844. /**
  96845. * Delete a webGL transform feedback object
  96846. * @param value defines the webGL transform feedback object to delete
  96847. */
  96848. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96849. /**
  96850. * Bind a webGL transform feedback object to the webgl context
  96851. * @param value defines the webGL transform feedback object to bind
  96852. */
  96853. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96854. /**
  96855. * Begins a transform feedback operation
  96856. * @param usePoints defines if points or triangles must be used
  96857. */
  96858. beginTransformFeedback(usePoints: boolean): void;
  96859. /**
  96860. * Ends a transform feedback operation
  96861. */
  96862. endTransformFeedback(): void;
  96863. /**
  96864. * Specify the varyings to use with transform feedback
  96865. * @param program defines the associated webGL program
  96866. * @param value defines the list of strings representing the varying names
  96867. */
  96868. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96869. /**
  96870. * Bind a webGL buffer for a transform feedback operation
  96871. * @param value defines the webGL buffer to bind
  96872. */
  96873. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96874. }
  96875. }
  96876. declare module BABYLON {
  96877. /**
  96878. * Gather the list of clipboard event types as constants.
  96879. */
  96880. export class ClipboardEventTypes {
  96881. /**
  96882. * The clipboard event is fired when a copy command is active (pressed).
  96883. */
  96884. static readonly COPY: number;
  96885. /**
  96886. * The clipboard event is fired when a cut command is active (pressed).
  96887. */
  96888. static readonly CUT: number;
  96889. /**
  96890. * The clipboard event is fired when a paste command is active (pressed).
  96891. */
  96892. static readonly PASTE: number;
  96893. }
  96894. /**
  96895. * This class is used to store clipboard related info for the onClipboardObservable event.
  96896. */
  96897. export class ClipboardInfo {
  96898. /**
  96899. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96900. */
  96901. type: number;
  96902. /**
  96903. * Defines the related dom event
  96904. */
  96905. event: ClipboardEvent;
  96906. /**
  96907. *Creates an instance of ClipboardInfo.
  96908. * @param {number} type
  96909. * @param {ClipboardEvent} event
  96910. */
  96911. constructor(
  96912. /**
  96913. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96914. */
  96915. type: number,
  96916. /**
  96917. * Defines the related dom event
  96918. */
  96919. event: ClipboardEvent);
  96920. /**
  96921. * Get the clipboard event's type from the keycode.
  96922. * @param keyCode Defines the keyCode for the current keyboard event.
  96923. * @return {number}
  96924. */
  96925. static GetTypeFromCharacter(keyCode: number): number;
  96926. }
  96927. }
  96928. declare module BABYLON {
  96929. /**
  96930. * Class used to represent data loading progression
  96931. */
  96932. export class SceneLoaderProgressEvent {
  96933. /** defines if data length to load can be evaluated */
  96934. readonly lengthComputable: boolean;
  96935. /** defines the loaded data length */
  96936. readonly loaded: number;
  96937. /** defines the data length to load */
  96938. readonly total: number;
  96939. /**
  96940. * Create a new progress event
  96941. * @param lengthComputable defines if data length to load can be evaluated
  96942. * @param loaded defines the loaded data length
  96943. * @param total defines the data length to load
  96944. */
  96945. constructor(
  96946. /** defines if data length to load can be evaluated */
  96947. lengthComputable: boolean,
  96948. /** defines the loaded data length */
  96949. loaded: number,
  96950. /** defines the data length to load */
  96951. total: number);
  96952. /**
  96953. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96954. * @param event defines the source event
  96955. * @returns a new SceneLoaderProgressEvent
  96956. */
  96957. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96958. }
  96959. /**
  96960. * Interface used by SceneLoader plugins to define supported file extensions
  96961. */
  96962. export interface ISceneLoaderPluginExtensions {
  96963. /**
  96964. * Defines the list of supported extensions
  96965. */
  96966. [extension: string]: {
  96967. isBinary: boolean;
  96968. };
  96969. }
  96970. /**
  96971. * Interface used by SceneLoader plugin factory
  96972. */
  96973. export interface ISceneLoaderPluginFactory {
  96974. /**
  96975. * Defines the name of the factory
  96976. */
  96977. name: string;
  96978. /**
  96979. * Function called to create a new plugin
  96980. * @return the new plugin
  96981. */
  96982. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96983. /**
  96984. * Boolean indicating if the plugin can direct load specific data
  96985. */
  96986. canDirectLoad?: (data: string) => boolean;
  96987. }
  96988. /**
  96989. * Interface used to define a SceneLoader plugin
  96990. */
  96991. export interface ISceneLoaderPlugin {
  96992. /**
  96993. * The friendly name of this plugin.
  96994. */
  96995. name: string;
  96996. /**
  96997. * The file extensions supported by this plugin.
  96998. */
  96999. extensions: string | ISceneLoaderPluginExtensions;
  97000. /**
  97001. * Import meshes into a scene.
  97002. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97003. * @param scene The scene to import into
  97004. * @param data The data to import
  97005. * @param rootUrl The root url for scene and resources
  97006. * @param meshes The meshes array to import into
  97007. * @param particleSystems The particle systems array to import into
  97008. * @param skeletons The skeletons array to import into
  97009. * @param onError The callback when import fails
  97010. * @returns True if successful or false otherwise
  97011. */
  97012. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  97013. /**
  97014. * Load into a scene.
  97015. * @param scene The scene to load into
  97016. * @param data The data to import
  97017. * @param rootUrl The root url for scene and resources
  97018. * @param onError The callback when import fails
  97019. * @returns true if successful or false otherwise
  97020. */
  97021. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  97022. /**
  97023. * The callback that returns true if the data can be directly loaded.
  97024. */
  97025. canDirectLoad?: (data: string) => boolean;
  97026. /**
  97027. * The callback that allows custom handling of the root url based on the response url.
  97028. */
  97029. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97030. /**
  97031. * Load into an asset container.
  97032. * @param scene The scene to load into
  97033. * @param data The data to import
  97034. * @param rootUrl The root url for scene and resources
  97035. * @param onError The callback when import fails
  97036. * @returns The loaded asset container
  97037. */
  97038. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  97039. }
  97040. /**
  97041. * Interface used to define an async SceneLoader plugin
  97042. */
  97043. export interface ISceneLoaderPluginAsync {
  97044. /**
  97045. * The friendly name of this plugin.
  97046. */
  97047. name: string;
  97048. /**
  97049. * The file extensions supported by this plugin.
  97050. */
  97051. extensions: string | ISceneLoaderPluginExtensions;
  97052. /**
  97053. * Import meshes into a scene.
  97054. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97055. * @param scene The scene to import into
  97056. * @param data The data to import
  97057. * @param rootUrl The root url for scene and resources
  97058. * @param onProgress The callback when the load progresses
  97059. * @param fileName Defines the name of the file to load
  97060. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  97061. */
  97062. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  97063. meshes: AbstractMesh[];
  97064. particleSystems: IParticleSystem[];
  97065. skeletons: Skeleton[];
  97066. animationGroups: AnimationGroup[];
  97067. }>;
  97068. /**
  97069. * Load into a scene.
  97070. * @param scene The scene to load into
  97071. * @param data The data to import
  97072. * @param rootUrl The root url for scene and resources
  97073. * @param onProgress The callback when the load progresses
  97074. * @param fileName Defines the name of the file to load
  97075. * @returns Nothing
  97076. */
  97077. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  97078. /**
  97079. * The callback that returns true if the data can be directly loaded.
  97080. */
  97081. canDirectLoad?: (data: string) => boolean;
  97082. /**
  97083. * The callback that allows custom handling of the root url based on the response url.
  97084. */
  97085. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97086. /**
  97087. * Load into an asset container.
  97088. * @param scene The scene to load into
  97089. * @param data The data to import
  97090. * @param rootUrl The root url for scene and resources
  97091. * @param onProgress The callback when the load progresses
  97092. * @param fileName Defines the name of the file to load
  97093. * @returns The loaded asset container
  97094. */
  97095. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  97096. }
  97097. /**
  97098. * Class used to load scene from various file formats using registered plugins
  97099. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  97100. */
  97101. export class SceneLoader {
  97102. /**
  97103. * No logging while loading
  97104. */
  97105. static readonly NO_LOGGING: number;
  97106. /**
  97107. * Minimal logging while loading
  97108. */
  97109. static readonly MINIMAL_LOGGING: number;
  97110. /**
  97111. * Summary logging while loading
  97112. */
  97113. static readonly SUMMARY_LOGGING: number;
  97114. /**
  97115. * Detailled logging while loading
  97116. */
  97117. static readonly DETAILED_LOGGING: number;
  97118. /**
  97119. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97120. */
  97121. static ForceFullSceneLoadingForIncremental: boolean;
  97122. /**
  97123. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97124. */
  97125. static ShowLoadingScreen: boolean;
  97126. /**
  97127. * Defines the current logging level (while loading the scene)
  97128. * @ignorenaming
  97129. */
  97130. static loggingLevel: number;
  97131. /**
  97132. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97133. */
  97134. static CleanBoneMatrixWeights: boolean;
  97135. /**
  97136. * Event raised when a plugin is used to load a scene
  97137. */
  97138. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97139. private static _registeredPlugins;
  97140. private static _getDefaultPlugin;
  97141. private static _getPluginForExtension;
  97142. private static _getPluginForDirectLoad;
  97143. private static _getPluginForFilename;
  97144. private static _getDirectLoad;
  97145. private static _loadData;
  97146. private static _getFileInfo;
  97147. /**
  97148. * Gets a plugin that can load the given extension
  97149. * @param extension defines the extension to load
  97150. * @returns a plugin or null if none works
  97151. */
  97152. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97153. /**
  97154. * Gets a boolean indicating that the given extension can be loaded
  97155. * @param extension defines the extension to load
  97156. * @returns true if the extension is supported
  97157. */
  97158. static IsPluginForExtensionAvailable(extension: string): boolean;
  97159. /**
  97160. * Adds a new plugin to the list of registered plugins
  97161. * @param plugin defines the plugin to add
  97162. */
  97163. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97164. /**
  97165. * Import meshes into a scene
  97166. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97167. * @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)
  97168. * @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)
  97169. * @param scene the instance of BABYLON.Scene to append to
  97170. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97171. * @param onProgress a callback with a progress event for each file being loaded
  97172. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97173. * @param pluginExtension the extension used to determine the plugin
  97174. * @returns The loaded plugin
  97175. */
  97176. 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>;
  97177. /**
  97178. * Import meshes into a scene
  97179. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97180. * @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)
  97181. * @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)
  97182. * @param scene the instance of BABYLON.Scene to append to
  97183. * @param onProgress a callback with a progress event for each file being loaded
  97184. * @param pluginExtension the extension used to determine the plugin
  97185. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97186. */
  97187. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97188. meshes: AbstractMesh[];
  97189. particleSystems: IParticleSystem[];
  97190. skeletons: Skeleton[];
  97191. animationGroups: AnimationGroup[];
  97192. }>;
  97193. /**
  97194. * Load a scene
  97195. * @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)
  97196. * @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)
  97197. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97198. * @param onSuccess a callback with the scene when import succeeds
  97199. * @param onProgress a callback with a progress event for each file being loaded
  97200. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97201. * @param pluginExtension the extension used to determine the plugin
  97202. * @returns The loaded plugin
  97203. */
  97204. 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>;
  97205. /**
  97206. * Load a scene
  97207. * @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)
  97208. * @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)
  97209. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97210. * @param onProgress a callback with a progress event for each file being loaded
  97211. * @param pluginExtension the extension used to determine the plugin
  97212. * @returns The loaded scene
  97213. */
  97214. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97215. /**
  97216. * Append a scene
  97217. * @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)
  97218. * @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)
  97219. * @param scene is the instance of BABYLON.Scene to append to
  97220. * @param onSuccess a callback with the scene when import succeeds
  97221. * @param onProgress a callback with a progress event for each file being loaded
  97222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97223. * @param pluginExtension the extension used to determine the plugin
  97224. * @returns The loaded plugin
  97225. */
  97226. 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>;
  97227. /**
  97228. * Append a scene
  97229. * @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)
  97230. * @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)
  97231. * @param scene is the instance of BABYLON.Scene to append to
  97232. * @param onProgress a callback with a progress event for each file being loaded
  97233. * @param pluginExtension the extension used to determine the plugin
  97234. * @returns The given scene
  97235. */
  97236. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97237. /**
  97238. * Load a scene into an asset container
  97239. * @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)
  97240. * @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)
  97241. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97242. * @param onSuccess a callback with the scene when import succeeds
  97243. * @param onProgress a callback with a progress event for each file being loaded
  97244. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97245. * @param pluginExtension the extension used to determine the plugin
  97246. * @returns The loaded plugin
  97247. */
  97248. 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>;
  97249. /**
  97250. * Load a scene into an asset container
  97251. * @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)
  97252. * @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)
  97253. * @param scene is the instance of Scene to append to
  97254. * @param onProgress a callback with a progress event for each file being loaded
  97255. * @param pluginExtension the extension used to determine the plugin
  97256. * @returns The loaded asset container
  97257. */
  97258. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97259. }
  97260. }
  97261. declare module BABYLON {
  97262. /**
  97263. * Google Daydream controller
  97264. */
  97265. export class DaydreamController extends WebVRController {
  97266. /**
  97267. * Base Url for the controller model.
  97268. */
  97269. static MODEL_BASE_URL: string;
  97270. /**
  97271. * File name for the controller model.
  97272. */
  97273. static MODEL_FILENAME: string;
  97274. /**
  97275. * Gamepad Id prefix used to identify Daydream Controller.
  97276. */
  97277. static readonly GAMEPAD_ID_PREFIX: string;
  97278. /**
  97279. * Creates a new DaydreamController from a gamepad
  97280. * @param vrGamepad the gamepad that the controller should be created from
  97281. */
  97282. constructor(vrGamepad: any);
  97283. /**
  97284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97285. * @param scene scene in which to add meshes
  97286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97287. */
  97288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97289. /**
  97290. * Called once for each button that changed state since the last frame
  97291. * @param buttonIdx Which button index changed
  97292. * @param state New state of the button
  97293. * @param changes Which properties on the state changed since last frame
  97294. */
  97295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97296. }
  97297. }
  97298. declare module BABYLON {
  97299. /**
  97300. * Gear VR Controller
  97301. */
  97302. export class GearVRController extends WebVRController {
  97303. /**
  97304. * Base Url for the controller model.
  97305. */
  97306. static MODEL_BASE_URL: string;
  97307. /**
  97308. * File name for the controller model.
  97309. */
  97310. static MODEL_FILENAME: string;
  97311. /**
  97312. * Gamepad Id prefix used to identify this controller.
  97313. */
  97314. static readonly GAMEPAD_ID_PREFIX: string;
  97315. private readonly _buttonIndexToObservableNameMap;
  97316. /**
  97317. * Creates a new GearVRController from a gamepad
  97318. * @param vrGamepad the gamepad that the controller should be created from
  97319. */
  97320. constructor(vrGamepad: any);
  97321. /**
  97322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97323. * @param scene scene in which to add meshes
  97324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97325. */
  97326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97327. /**
  97328. * Called once for each button that changed state since the last frame
  97329. * @param buttonIdx Which button index changed
  97330. * @param state New state of the button
  97331. * @param changes Which properties on the state changed since last frame
  97332. */
  97333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97334. }
  97335. }
  97336. declare module BABYLON {
  97337. /**
  97338. * Generic Controller
  97339. */
  97340. export class GenericController extends WebVRController {
  97341. /**
  97342. * Base Url for the controller model.
  97343. */
  97344. static readonly MODEL_BASE_URL: string;
  97345. /**
  97346. * File name for the controller model.
  97347. */
  97348. static readonly MODEL_FILENAME: string;
  97349. /**
  97350. * Creates a new GenericController from a gamepad
  97351. * @param vrGamepad the gamepad that the controller should be created from
  97352. */
  97353. constructor(vrGamepad: any);
  97354. /**
  97355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97356. * @param scene scene in which to add meshes
  97357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97358. */
  97359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97360. /**
  97361. * Called once for each button that changed state since the last frame
  97362. * @param buttonIdx Which button index changed
  97363. * @param state New state of the button
  97364. * @param changes Which properties on the state changed since last frame
  97365. */
  97366. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97367. }
  97368. }
  97369. declare module BABYLON {
  97370. /**
  97371. * Oculus Touch Controller
  97372. */
  97373. export class OculusTouchController extends WebVRController {
  97374. /**
  97375. * Base Url for the controller model.
  97376. */
  97377. static MODEL_BASE_URL: string;
  97378. /**
  97379. * File name for the left controller model.
  97380. */
  97381. static MODEL_LEFT_FILENAME: string;
  97382. /**
  97383. * File name for the right controller model.
  97384. */
  97385. static MODEL_RIGHT_FILENAME: string;
  97386. /**
  97387. * Fired when the secondary trigger on this controller is modified
  97388. */
  97389. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97390. /**
  97391. * Fired when the thumb rest on this controller is modified
  97392. */
  97393. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97394. /**
  97395. * Creates a new OculusTouchController from a gamepad
  97396. * @param vrGamepad the gamepad that the controller should be created from
  97397. */
  97398. constructor(vrGamepad: any);
  97399. /**
  97400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97401. * @param scene scene in which to add meshes
  97402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97403. */
  97404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97405. /**
  97406. * Fired when the A button on this controller is modified
  97407. */
  97408. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97409. /**
  97410. * Fired when the B button on this controller is modified
  97411. */
  97412. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97413. /**
  97414. * Fired when the X button on this controller is modified
  97415. */
  97416. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97417. /**
  97418. * Fired when the Y button on this controller is modified
  97419. */
  97420. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97421. /**
  97422. * Called once for each button that changed state since the last frame
  97423. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97424. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97425. * 2) secondary trigger (same)
  97426. * 3) A (right) X (left), touch, pressed = value
  97427. * 4) B / Y
  97428. * 5) thumb rest
  97429. * @param buttonIdx Which button index changed
  97430. * @param state New state of the button
  97431. * @param changes Which properties on the state changed since last frame
  97432. */
  97433. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97434. }
  97435. }
  97436. declare module BABYLON {
  97437. /**
  97438. * Vive Controller
  97439. */
  97440. export class ViveController extends WebVRController {
  97441. /**
  97442. * Base Url for the controller model.
  97443. */
  97444. static MODEL_BASE_URL: string;
  97445. /**
  97446. * File name for the controller model.
  97447. */
  97448. static MODEL_FILENAME: string;
  97449. /**
  97450. * Creates a new ViveController from a gamepad
  97451. * @param vrGamepad the gamepad that the controller should be created from
  97452. */
  97453. constructor(vrGamepad: any);
  97454. /**
  97455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97456. * @param scene scene in which to add meshes
  97457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97458. */
  97459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97460. /**
  97461. * Fired when the left button on this controller is modified
  97462. */
  97463. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97464. /**
  97465. * Fired when the right button on this controller is modified
  97466. */
  97467. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97468. /**
  97469. * Fired when the menu button on this controller is modified
  97470. */
  97471. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97472. /**
  97473. * Called once for each button that changed state since the last frame
  97474. * Vive mapping:
  97475. * 0: touchpad
  97476. * 1: trigger
  97477. * 2: left AND right buttons
  97478. * 3: menu button
  97479. * @param buttonIdx Which button index changed
  97480. * @param state New state of the button
  97481. * @param changes Which properties on the state changed since last frame
  97482. */
  97483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97484. }
  97485. }
  97486. declare module BABYLON {
  97487. /**
  97488. * Defines the WindowsMotionController object that the state of the windows motion controller
  97489. */
  97490. export class WindowsMotionController extends WebVRController {
  97491. /**
  97492. * The base url used to load the left and right controller models
  97493. */
  97494. static MODEL_BASE_URL: string;
  97495. /**
  97496. * The name of the left controller model file
  97497. */
  97498. static MODEL_LEFT_FILENAME: string;
  97499. /**
  97500. * The name of the right controller model file
  97501. */
  97502. static MODEL_RIGHT_FILENAME: string;
  97503. /**
  97504. * The controller name prefix for this controller type
  97505. */
  97506. static readonly GAMEPAD_ID_PREFIX: string;
  97507. /**
  97508. * The controller id pattern for this controller type
  97509. */
  97510. private static readonly GAMEPAD_ID_PATTERN;
  97511. private _loadedMeshInfo;
  97512. private readonly _mapping;
  97513. /**
  97514. * Fired when the trackpad on this controller is clicked
  97515. */
  97516. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97517. /**
  97518. * Fired when the trackpad on this controller is modified
  97519. */
  97520. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97521. /**
  97522. * The current x and y values of this controller's trackpad
  97523. */
  97524. trackpad: StickValues;
  97525. /**
  97526. * Creates a new WindowsMotionController from a gamepad
  97527. * @param vrGamepad the gamepad that the controller should be created from
  97528. */
  97529. constructor(vrGamepad: any);
  97530. /**
  97531. * Fired when the trigger on this controller is modified
  97532. */
  97533. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97534. /**
  97535. * Fired when the menu button on this controller is modified
  97536. */
  97537. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97538. /**
  97539. * Fired when the grip button on this controller is modified
  97540. */
  97541. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97542. /**
  97543. * Fired when the thumbstick button on this controller is modified
  97544. */
  97545. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97546. /**
  97547. * Fired when the touchpad button on this controller is modified
  97548. */
  97549. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97550. /**
  97551. * Fired when the touchpad values on this controller are modified
  97552. */
  97553. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97554. private _updateTrackpad;
  97555. /**
  97556. * Called once per frame by the engine.
  97557. */
  97558. update(): void;
  97559. /**
  97560. * Called once for each button that changed state since the last frame
  97561. * @param buttonIdx Which button index changed
  97562. * @param state New state of the button
  97563. * @param changes Which properties on the state changed since last frame
  97564. */
  97565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97566. /**
  97567. * Moves the buttons on the controller mesh based on their current state
  97568. * @param buttonName the name of the button to move
  97569. * @param buttonValue the value of the button which determines the buttons new position
  97570. */
  97571. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97572. /**
  97573. * Moves the axis on the controller mesh based on its current state
  97574. * @param axis the index of the axis
  97575. * @param axisValue the value of the axis which determines the meshes new position
  97576. * @hidden
  97577. */
  97578. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97579. /**
  97580. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97581. * @param scene scene in which to add meshes
  97582. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97583. */
  97584. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97585. /**
  97586. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97587. * can be transformed by button presses and axes values, based on this._mapping.
  97588. *
  97589. * @param scene scene in which the meshes exist
  97590. * @param meshes list of meshes that make up the controller model to process
  97591. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97592. */
  97593. private processModel;
  97594. private createMeshInfo;
  97595. /**
  97596. * Gets the ray of the controller in the direction the controller is pointing
  97597. * @param length the length the resulting ray should be
  97598. * @returns a ray in the direction the controller is pointing
  97599. */
  97600. getForwardRay(length?: number): Ray;
  97601. /**
  97602. * Disposes of the controller
  97603. */
  97604. dispose(): void;
  97605. }
  97606. }
  97607. declare module BABYLON {
  97608. /**
  97609. * Manager for handling gamepads
  97610. */
  97611. export class GamepadManager {
  97612. private _scene?;
  97613. private _babylonGamepads;
  97614. private _oneGamepadConnected;
  97615. /** @hidden */
  97616. _isMonitoring: boolean;
  97617. private _gamepadEventSupported;
  97618. private _gamepadSupport;
  97619. /**
  97620. * observable to be triggered when the gamepad controller has been connected
  97621. */
  97622. onGamepadConnectedObservable: Observable<Gamepad>;
  97623. /**
  97624. * observable to be triggered when the gamepad controller has been disconnected
  97625. */
  97626. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97627. private _onGamepadConnectedEvent;
  97628. private _onGamepadDisconnectedEvent;
  97629. /**
  97630. * Initializes the gamepad manager
  97631. * @param _scene BabylonJS scene
  97632. */
  97633. constructor(_scene?: Scene | undefined);
  97634. /**
  97635. * The gamepads in the game pad manager
  97636. */
  97637. readonly gamepads: Gamepad[];
  97638. /**
  97639. * Get the gamepad controllers based on type
  97640. * @param type The type of gamepad controller
  97641. * @returns Nullable gamepad
  97642. */
  97643. getGamepadByType(type?: number): Nullable<Gamepad>;
  97644. /**
  97645. * Disposes the gamepad manager
  97646. */
  97647. dispose(): void;
  97648. private _addNewGamepad;
  97649. private _startMonitoringGamepads;
  97650. private _stopMonitoringGamepads;
  97651. /** @hidden */
  97652. _checkGamepadsStatus(): void;
  97653. private _updateGamepadObjects;
  97654. }
  97655. }
  97656. declare module BABYLON {
  97657. interface Scene {
  97658. /** @hidden */
  97659. _gamepadManager: Nullable<GamepadManager>;
  97660. /**
  97661. * Gets the gamepad manager associated with the scene
  97662. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97663. */
  97664. gamepadManager: GamepadManager;
  97665. }
  97666. /**
  97667. * Interface representing a free camera inputs manager
  97668. */
  97669. interface FreeCameraInputsManager {
  97670. /**
  97671. * Adds gamepad input support to the FreeCameraInputsManager.
  97672. * @returns the FreeCameraInputsManager
  97673. */
  97674. addGamepad(): FreeCameraInputsManager;
  97675. }
  97676. /**
  97677. * Interface representing an arc rotate camera inputs manager
  97678. */
  97679. interface ArcRotateCameraInputsManager {
  97680. /**
  97681. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97682. * @returns the camera inputs manager
  97683. */
  97684. addGamepad(): ArcRotateCameraInputsManager;
  97685. }
  97686. /**
  97687. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97688. */
  97689. export class GamepadSystemSceneComponent implements ISceneComponent {
  97690. /**
  97691. * The component name helpfull to identify the component in the list of scene components.
  97692. */
  97693. readonly name: string;
  97694. /**
  97695. * The scene the component belongs to.
  97696. */
  97697. scene: Scene;
  97698. /**
  97699. * Creates a new instance of the component for the given scene
  97700. * @param scene Defines the scene to register the component in
  97701. */
  97702. constructor(scene: Scene);
  97703. /**
  97704. * Registers the component in a given scene
  97705. */
  97706. register(): void;
  97707. /**
  97708. * Rebuilds the elements related to this component in case of
  97709. * context lost for instance.
  97710. */
  97711. rebuild(): void;
  97712. /**
  97713. * Disposes the component and the associated ressources
  97714. */
  97715. dispose(): void;
  97716. private _beforeCameraUpdate;
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * Single axis scale gizmo
  97722. */
  97723. export class AxisScaleGizmo extends Gizmo {
  97724. private _coloredMaterial;
  97725. /**
  97726. * Drag behavior responsible for the gizmos dragging interactions
  97727. */
  97728. dragBehavior: PointerDragBehavior;
  97729. private _pointerObserver;
  97730. /**
  97731. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97732. */
  97733. snapDistance: number;
  97734. /**
  97735. * Event that fires each time the gizmo snaps to a new location.
  97736. * * snapDistance is the the change in distance
  97737. */
  97738. onSnapObservable: Observable<{
  97739. snapDistance: number;
  97740. }>;
  97741. /**
  97742. * If the scaling operation should be done on all axis (default: false)
  97743. */
  97744. uniformScaling: boolean;
  97745. /**
  97746. * Creates an AxisScaleGizmo
  97747. * @param gizmoLayer The utility layer the gizmo will be added to
  97748. * @param dragAxis The axis which the gizmo will be able to scale on
  97749. * @param color The color of the gizmo
  97750. */
  97751. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97752. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97753. /**
  97754. * Disposes of the gizmo
  97755. */
  97756. dispose(): void;
  97757. /**
  97758. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97759. * @param mesh The mesh to replace the default mesh of the gizmo
  97760. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97761. */
  97762. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97763. }
  97764. }
  97765. declare module BABYLON {
  97766. /**
  97767. * Bounding box gizmo
  97768. */
  97769. export class BoundingBoxGizmo extends Gizmo {
  97770. private _lineBoundingBox;
  97771. private _rotateSpheresParent;
  97772. private _scaleBoxesParent;
  97773. private _boundingDimensions;
  97774. private _renderObserver;
  97775. private _pointerObserver;
  97776. private _scaleDragSpeed;
  97777. private _tmpQuaternion;
  97778. private _tmpVector;
  97779. private _tmpRotationMatrix;
  97780. /**
  97781. * 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)
  97782. */
  97783. ignoreChildren: boolean;
  97784. /**
  97785. * 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)
  97786. */
  97787. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97788. /**
  97789. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97790. */
  97791. rotationSphereSize: number;
  97792. /**
  97793. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97794. */
  97795. scaleBoxSize: number;
  97796. /**
  97797. * 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)
  97798. */
  97799. fixedDragMeshScreenSize: boolean;
  97800. /**
  97801. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97802. */
  97803. fixedDragMeshScreenSizeDistanceFactor: number;
  97804. /**
  97805. * Fired when a rotation sphere or scale box is dragged
  97806. */
  97807. onDragStartObservable: Observable<{}>;
  97808. /**
  97809. * Fired when a scale box is dragged
  97810. */
  97811. onScaleBoxDragObservable: Observable<{}>;
  97812. /**
  97813. * Fired when a scale box drag is ended
  97814. */
  97815. onScaleBoxDragEndObservable: Observable<{}>;
  97816. /**
  97817. * Fired when a rotation sphere is dragged
  97818. */
  97819. onRotationSphereDragObservable: Observable<{}>;
  97820. /**
  97821. * Fired when a rotation sphere drag is ended
  97822. */
  97823. onRotationSphereDragEndObservable: Observable<{}>;
  97824. /**
  97825. * 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)
  97826. */
  97827. scalePivot: Nullable<Vector3>;
  97828. private _anchorMesh;
  97829. private _existingMeshScale;
  97830. private _dragMesh;
  97831. private pointerDragBehavior;
  97832. /**
  97833. * Creates an BoundingBoxGizmo
  97834. * @param gizmoLayer The utility layer the gizmo will be added to
  97835. * @param color The color of the gizmo
  97836. */
  97837. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97838. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97839. private _selectNode;
  97840. /**
  97841. * Updates the bounding box information for the Gizmo
  97842. */
  97843. updateBoundingBox(): void;
  97844. private _updateRotationSpheres;
  97845. private _updateScaleBoxes;
  97846. /**
  97847. * Enables rotation on the specified axis and disables rotation on the others
  97848. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97849. */
  97850. setEnabledRotationAxis(axis: string): void;
  97851. /**
  97852. * Enables/disables scaling
  97853. * @param enable if scaling should be enabled
  97854. */
  97855. setEnabledScaling(enable: boolean): void;
  97856. private _updateDummy;
  97857. /**
  97858. * Enables a pointer drag behavior on the bounding box of the gizmo
  97859. */
  97860. enableDragBehavior(): void;
  97861. /**
  97862. * Disposes of the gizmo
  97863. */
  97864. dispose(): void;
  97865. /**
  97866. * 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)
  97867. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97868. * @returns the bounding box mesh with the passed in mesh as a child
  97869. */
  97870. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97871. /**
  97872. * CustomMeshes are not supported by this gizmo
  97873. * @param mesh The mesh to replace the default mesh of the gizmo
  97874. */
  97875. setCustomMesh(mesh: Mesh): void;
  97876. }
  97877. }
  97878. declare module BABYLON {
  97879. /**
  97880. * Single plane rotation gizmo
  97881. */
  97882. export class PlaneRotationGizmo extends Gizmo {
  97883. /**
  97884. * Drag behavior responsible for the gizmos dragging interactions
  97885. */
  97886. dragBehavior: PointerDragBehavior;
  97887. private _pointerObserver;
  97888. /**
  97889. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97890. */
  97891. snapDistance: number;
  97892. /**
  97893. * Event that fires each time the gizmo snaps to a new location.
  97894. * * snapDistance is the the change in distance
  97895. */
  97896. onSnapObservable: Observable<{
  97897. snapDistance: number;
  97898. }>;
  97899. /**
  97900. * Creates a PlaneRotationGizmo
  97901. * @param gizmoLayer The utility layer the gizmo will be added to
  97902. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97903. * @param color The color of the gizmo
  97904. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97905. */
  97906. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97907. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97908. /**
  97909. * Disposes of the gizmo
  97910. */
  97911. dispose(): void;
  97912. }
  97913. }
  97914. declare module BABYLON {
  97915. /**
  97916. * Gizmo that enables rotating a mesh along 3 axis
  97917. */
  97918. export class RotationGizmo extends Gizmo {
  97919. /**
  97920. * Internal gizmo used for interactions on the x axis
  97921. */
  97922. xGizmo: PlaneRotationGizmo;
  97923. /**
  97924. * Internal gizmo used for interactions on the y axis
  97925. */
  97926. yGizmo: PlaneRotationGizmo;
  97927. /**
  97928. * Internal gizmo used for interactions on the z axis
  97929. */
  97930. zGizmo: PlaneRotationGizmo;
  97931. /** Fires an event when any of it's sub gizmos are dragged */
  97932. onDragStartObservable: Observable<{}>;
  97933. /** Fires an event when any of it's sub gizmos are released from dragging */
  97934. onDragEndObservable: Observable<{}>;
  97935. attachedMesh: Nullable<AbstractMesh>;
  97936. /**
  97937. * Creates a RotationGizmo
  97938. * @param gizmoLayer The utility layer the gizmo will be added to
  97939. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97940. */
  97941. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97942. updateGizmoRotationToMatchAttachedMesh: boolean;
  97943. /**
  97944. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97945. */
  97946. snapDistance: number;
  97947. /**
  97948. * Ratio for the scale of the gizmo (Default: 1)
  97949. */
  97950. scaleRatio: number;
  97951. /**
  97952. * Disposes of the gizmo
  97953. */
  97954. dispose(): void;
  97955. /**
  97956. * CustomMeshes are not supported by this gizmo
  97957. * @param mesh The mesh to replace the default mesh of the gizmo
  97958. */
  97959. setCustomMesh(mesh: Mesh): void;
  97960. }
  97961. }
  97962. declare module BABYLON {
  97963. /**
  97964. * Gizmo that enables dragging a mesh along 3 axis
  97965. */
  97966. export class PositionGizmo extends Gizmo {
  97967. /**
  97968. * Internal gizmo used for interactions on the x axis
  97969. */
  97970. xGizmo: AxisDragGizmo;
  97971. /**
  97972. * Internal gizmo used for interactions on the y axis
  97973. */
  97974. yGizmo: AxisDragGizmo;
  97975. /**
  97976. * Internal gizmo used for interactions on the z axis
  97977. */
  97978. zGizmo: AxisDragGizmo;
  97979. /** Fires an event when any of it's sub gizmos are dragged */
  97980. onDragStartObservable: Observable<{}>;
  97981. /** Fires an event when any of it's sub gizmos are released from dragging */
  97982. onDragEndObservable: Observable<{}>;
  97983. attachedMesh: Nullable<AbstractMesh>;
  97984. /**
  97985. * Creates a PositionGizmo
  97986. * @param gizmoLayer The utility layer the gizmo will be added to
  97987. */
  97988. constructor(gizmoLayer?: UtilityLayerRenderer);
  97989. updateGizmoRotationToMatchAttachedMesh: boolean;
  97990. /**
  97991. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97992. */
  97993. snapDistance: number;
  97994. /**
  97995. * Ratio for the scale of the gizmo (Default: 1)
  97996. */
  97997. scaleRatio: number;
  97998. /**
  97999. * Disposes of the gizmo
  98000. */
  98001. dispose(): void;
  98002. /**
  98003. * CustomMeshes are not supported by this gizmo
  98004. * @param mesh The mesh to replace the default mesh of the gizmo
  98005. */
  98006. setCustomMesh(mesh: Mesh): void;
  98007. }
  98008. }
  98009. declare module BABYLON {
  98010. /**
  98011. * Gizmo that enables scaling a mesh along 3 axis
  98012. */
  98013. export class ScaleGizmo extends Gizmo {
  98014. /**
  98015. * Internal gizmo used for interactions on the x axis
  98016. */
  98017. xGizmo: AxisScaleGizmo;
  98018. /**
  98019. * Internal gizmo used for interactions on the y axis
  98020. */
  98021. yGizmo: AxisScaleGizmo;
  98022. /**
  98023. * Internal gizmo used for interactions on the z axis
  98024. */
  98025. zGizmo: AxisScaleGizmo;
  98026. /**
  98027. * Internal gizmo used to scale all axis equally
  98028. */
  98029. uniformScaleGizmo: AxisScaleGizmo;
  98030. /** Fires an event when any of it's sub gizmos are dragged */
  98031. onDragStartObservable: Observable<{}>;
  98032. /** Fires an event when any of it's sub gizmos are released from dragging */
  98033. onDragEndObservable: Observable<{}>;
  98034. attachedMesh: Nullable<AbstractMesh>;
  98035. /**
  98036. * Creates a ScaleGizmo
  98037. * @param gizmoLayer The utility layer the gizmo will be added to
  98038. */
  98039. constructor(gizmoLayer?: UtilityLayerRenderer);
  98040. updateGizmoRotationToMatchAttachedMesh: boolean;
  98041. /**
  98042. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98043. */
  98044. snapDistance: number;
  98045. /**
  98046. * Ratio for the scale of the gizmo (Default: 1)
  98047. */
  98048. scaleRatio: number;
  98049. /**
  98050. * Disposes of the gizmo
  98051. */
  98052. dispose(): void;
  98053. }
  98054. }
  98055. declare module BABYLON {
  98056. /**
  98057. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  98058. */
  98059. export class GizmoManager implements IDisposable {
  98060. private scene;
  98061. /**
  98062. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  98063. */
  98064. gizmos: {
  98065. positionGizmo: Nullable<PositionGizmo>;
  98066. rotationGizmo: Nullable<RotationGizmo>;
  98067. scaleGizmo: Nullable<ScaleGizmo>;
  98068. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  98069. };
  98070. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  98071. clearGizmoOnEmptyPointerEvent: boolean;
  98072. /** Fires an event when the manager is attached to a mesh */
  98073. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  98074. private _gizmosEnabled;
  98075. private _pointerObserver;
  98076. private _attachedMesh;
  98077. private _boundingBoxColor;
  98078. private _defaultUtilityLayer;
  98079. private _defaultKeepDepthUtilityLayer;
  98080. /**
  98081. * When bounding box gizmo is enabled, this can be used to track drag/end events
  98082. */
  98083. boundingBoxDragBehavior: SixDofDragBehavior;
  98084. /**
  98085. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  98086. */
  98087. attachableMeshes: Nullable<Array<AbstractMesh>>;
  98088. /**
  98089. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  98090. */
  98091. usePointerToAttachGizmos: boolean;
  98092. /**
  98093. * Instatiates a gizmo manager
  98094. * @param scene the scene to overlay the gizmos on top of
  98095. */
  98096. constructor(scene: Scene);
  98097. /**
  98098. * Attaches a set of gizmos to the specified mesh
  98099. * @param mesh The mesh the gizmo's should be attached to
  98100. */
  98101. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  98102. /**
  98103. * If the position gizmo is enabled
  98104. */
  98105. positionGizmoEnabled: boolean;
  98106. /**
  98107. * If the rotation gizmo is enabled
  98108. */
  98109. rotationGizmoEnabled: boolean;
  98110. /**
  98111. * If the scale gizmo is enabled
  98112. */
  98113. scaleGizmoEnabled: boolean;
  98114. /**
  98115. * If the boundingBox gizmo is enabled
  98116. */
  98117. boundingBoxGizmoEnabled: boolean;
  98118. /**
  98119. * Disposes of the gizmo manager
  98120. */
  98121. dispose(): void;
  98122. }
  98123. }
  98124. declare module BABYLON {
  98125. /** @hidden */
  98126. export var backgroundFragmentDeclaration: {
  98127. name: string;
  98128. shader: string;
  98129. };
  98130. }
  98131. declare module BABYLON {
  98132. /** @hidden */
  98133. export var backgroundUboDeclaration: {
  98134. name: string;
  98135. shader: string;
  98136. };
  98137. }
  98138. declare module BABYLON {
  98139. /** @hidden */
  98140. export var backgroundPixelShader: {
  98141. name: string;
  98142. shader: string;
  98143. };
  98144. }
  98145. declare module BABYLON {
  98146. /** @hidden */
  98147. export var backgroundVertexDeclaration: {
  98148. name: string;
  98149. shader: string;
  98150. };
  98151. }
  98152. declare module BABYLON {
  98153. /** @hidden */
  98154. export var backgroundVertexShader: {
  98155. name: string;
  98156. shader: string;
  98157. };
  98158. }
  98159. declare module BABYLON {
  98160. /**
  98161. * Background material used to create an efficient environement around your scene.
  98162. */
  98163. export class BackgroundMaterial extends PushMaterial {
  98164. /**
  98165. * Standard reflectance value at parallel view angle.
  98166. */
  98167. static StandardReflectance0: number;
  98168. /**
  98169. * Standard reflectance value at grazing angle.
  98170. */
  98171. static StandardReflectance90: number;
  98172. protected _primaryColor: Color3;
  98173. /**
  98174. * Key light Color (multiply against the environement texture)
  98175. */
  98176. primaryColor: Color3;
  98177. protected __perceptualColor: Nullable<Color3>;
  98178. /**
  98179. * Experimental Internal Use Only.
  98180. *
  98181. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98182. * This acts as a helper to set the primary color to a more "human friendly" value.
  98183. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98184. * output color as close as possible from the chosen value.
  98185. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98186. * part of lighting setup.)
  98187. */
  98188. _perceptualColor: Nullable<Color3>;
  98189. protected _primaryColorShadowLevel: float;
  98190. /**
  98191. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98192. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98193. */
  98194. primaryColorShadowLevel: float;
  98195. protected _primaryColorHighlightLevel: float;
  98196. /**
  98197. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98198. * The primary color is used at the level chosen to define what the white area would look.
  98199. */
  98200. primaryColorHighlightLevel: float;
  98201. protected _reflectionTexture: Nullable<BaseTexture>;
  98202. /**
  98203. * Reflection Texture used in the material.
  98204. * Should be author in a specific way for the best result (refer to the documentation).
  98205. */
  98206. reflectionTexture: Nullable<BaseTexture>;
  98207. protected _reflectionBlur: float;
  98208. /**
  98209. * Reflection Texture level of blur.
  98210. *
  98211. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98212. * texture twice.
  98213. */
  98214. reflectionBlur: float;
  98215. protected _diffuseTexture: Nullable<BaseTexture>;
  98216. /**
  98217. * Diffuse Texture used in the material.
  98218. * Should be author in a specific way for the best result (refer to the documentation).
  98219. */
  98220. diffuseTexture: Nullable<BaseTexture>;
  98221. protected _shadowLights: Nullable<IShadowLight[]>;
  98222. /**
  98223. * Specify the list of lights casting shadow on the material.
  98224. * All scene shadow lights will be included if null.
  98225. */
  98226. shadowLights: Nullable<IShadowLight[]>;
  98227. protected _shadowLevel: float;
  98228. /**
  98229. * Helps adjusting the shadow to a softer level if required.
  98230. * 0 means black shadows and 1 means no shadows.
  98231. */
  98232. shadowLevel: float;
  98233. protected _sceneCenter: Vector3;
  98234. /**
  98235. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98236. * It is usually zero but might be interesting to modify according to your setup.
  98237. */
  98238. sceneCenter: Vector3;
  98239. protected _opacityFresnel: boolean;
  98240. /**
  98241. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98242. * This helps ensuring a nice transition when the camera goes under the ground.
  98243. */
  98244. opacityFresnel: boolean;
  98245. protected _reflectionFresnel: boolean;
  98246. /**
  98247. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98248. * This helps adding a mirror texture on the ground.
  98249. */
  98250. reflectionFresnel: boolean;
  98251. protected _reflectionFalloffDistance: number;
  98252. /**
  98253. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98254. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98255. */
  98256. reflectionFalloffDistance: number;
  98257. protected _reflectionAmount: number;
  98258. /**
  98259. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98260. */
  98261. reflectionAmount: number;
  98262. protected _reflectionReflectance0: number;
  98263. /**
  98264. * This specifies the weight of the reflection at grazing angle.
  98265. */
  98266. reflectionReflectance0: number;
  98267. protected _reflectionReflectance90: number;
  98268. /**
  98269. * This specifies the weight of the reflection at a perpendicular point of view.
  98270. */
  98271. reflectionReflectance90: number;
  98272. /**
  98273. * Sets the reflection reflectance fresnel values according to the default standard
  98274. * empirically know to work well :-)
  98275. */
  98276. reflectionStandardFresnelWeight: number;
  98277. protected _useRGBColor: boolean;
  98278. /**
  98279. * Helps to directly use the maps channels instead of their level.
  98280. */
  98281. useRGBColor: boolean;
  98282. protected _enableNoise: boolean;
  98283. /**
  98284. * This helps reducing the banding effect that could occur on the background.
  98285. */
  98286. enableNoise: boolean;
  98287. /**
  98288. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98289. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98290. * Recommended to be keep at 1.0 except for special cases.
  98291. */
  98292. fovMultiplier: number;
  98293. private _fovMultiplier;
  98294. /**
  98295. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98296. */
  98297. useEquirectangularFOV: boolean;
  98298. private _maxSimultaneousLights;
  98299. /**
  98300. * Number of Simultaneous lights allowed on the material.
  98301. */
  98302. maxSimultaneousLights: int;
  98303. /**
  98304. * Default configuration related to image processing available in the Background Material.
  98305. */
  98306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98307. /**
  98308. * Keep track of the image processing observer to allow dispose and replace.
  98309. */
  98310. private _imageProcessingObserver;
  98311. /**
  98312. * Attaches a new image processing configuration to the PBR Material.
  98313. * @param configuration (if null the scene configuration will be use)
  98314. */
  98315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98316. /**
  98317. * Gets the image processing configuration used either in this material.
  98318. */
  98319. /**
  98320. * Sets the Default image processing configuration used either in the this material.
  98321. *
  98322. * If sets to null, the scene one is in use.
  98323. */
  98324. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98325. /**
  98326. * Gets wether the color curves effect is enabled.
  98327. */
  98328. /**
  98329. * Sets wether the color curves effect is enabled.
  98330. */
  98331. cameraColorCurvesEnabled: boolean;
  98332. /**
  98333. * Gets wether the color grading effect is enabled.
  98334. */
  98335. /**
  98336. * Gets wether the color grading effect is enabled.
  98337. */
  98338. cameraColorGradingEnabled: boolean;
  98339. /**
  98340. * Gets wether tonemapping is enabled or not.
  98341. */
  98342. /**
  98343. * Sets wether tonemapping is enabled or not
  98344. */
  98345. cameraToneMappingEnabled: boolean;
  98346. /**
  98347. * The camera exposure used on this material.
  98348. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98349. * This corresponds to a photographic exposure.
  98350. */
  98351. /**
  98352. * The camera exposure used on this material.
  98353. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98354. * This corresponds to a photographic exposure.
  98355. */
  98356. cameraExposure: float;
  98357. /**
  98358. * Gets The camera contrast used on this material.
  98359. */
  98360. /**
  98361. * Sets The camera contrast used on this material.
  98362. */
  98363. cameraContrast: float;
  98364. /**
  98365. * Gets the Color Grading 2D Lookup Texture.
  98366. */
  98367. /**
  98368. * Sets the Color Grading 2D Lookup Texture.
  98369. */
  98370. cameraColorGradingTexture: Nullable<BaseTexture>;
  98371. /**
  98372. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98373. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98374. * 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;
  98375. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98376. */
  98377. /**
  98378. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98379. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98380. * 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;
  98381. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98382. */
  98383. cameraColorCurves: Nullable<ColorCurves>;
  98384. /**
  98385. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98386. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98387. */
  98388. switchToBGR: boolean;
  98389. private _renderTargets;
  98390. private _reflectionControls;
  98391. private _white;
  98392. private _primaryShadowColor;
  98393. private _primaryHighlightColor;
  98394. /**
  98395. * Instantiates a Background Material in the given scene
  98396. * @param name The friendly name of the material
  98397. * @param scene The scene to add the material to
  98398. */
  98399. constructor(name: string, scene: Scene);
  98400. /**
  98401. * Gets a boolean indicating that current material needs to register RTT
  98402. */
  98403. readonly hasRenderTargetTextures: boolean;
  98404. /**
  98405. * The entire material has been created in order to prevent overdraw.
  98406. * @returns false
  98407. */
  98408. needAlphaTesting(): boolean;
  98409. /**
  98410. * The entire material has been created in order to prevent overdraw.
  98411. * @returns true if blending is enable
  98412. */
  98413. needAlphaBlending(): boolean;
  98414. /**
  98415. * Checks wether the material is ready to be rendered for a given mesh.
  98416. * @param mesh The mesh to render
  98417. * @param subMesh The submesh to check against
  98418. * @param useInstances Specify wether or not the material is used with instances
  98419. * @returns true if all the dependencies are ready (Textures, Effects...)
  98420. */
  98421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98422. /**
  98423. * Compute the primary color according to the chosen perceptual color.
  98424. */
  98425. private _computePrimaryColorFromPerceptualColor;
  98426. /**
  98427. * Compute the highlights and shadow colors according to their chosen levels.
  98428. */
  98429. private _computePrimaryColors;
  98430. /**
  98431. * Build the uniform buffer used in the material.
  98432. */
  98433. buildUniformLayout(): void;
  98434. /**
  98435. * Unbind the material.
  98436. */
  98437. unbind(): void;
  98438. /**
  98439. * Bind only the world matrix to the material.
  98440. * @param world The world matrix to bind.
  98441. */
  98442. bindOnlyWorldMatrix(world: Matrix): void;
  98443. /**
  98444. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98445. * @param world The world matrix to bind.
  98446. * @param subMesh The submesh to bind for.
  98447. */
  98448. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98449. /**
  98450. * Dispose the material.
  98451. * @param forceDisposeEffect Force disposal of the associated effect.
  98452. * @param forceDisposeTextures Force disposal of the associated textures.
  98453. */
  98454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98455. /**
  98456. * Clones the material.
  98457. * @param name The cloned name.
  98458. * @returns The cloned material.
  98459. */
  98460. clone(name: string): BackgroundMaterial;
  98461. /**
  98462. * Serializes the current material to its JSON representation.
  98463. * @returns The JSON representation.
  98464. */
  98465. serialize(): any;
  98466. /**
  98467. * Gets the class name of the material
  98468. * @returns "BackgroundMaterial"
  98469. */
  98470. getClassName(): string;
  98471. /**
  98472. * Parse a JSON input to create back a background material.
  98473. * @param source The JSON data to parse
  98474. * @param scene The scene to create the parsed material in
  98475. * @param rootUrl The root url of the assets the material depends upon
  98476. * @returns the instantiated BackgroundMaterial.
  98477. */
  98478. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98479. }
  98480. }
  98481. declare module BABYLON {
  98482. /**
  98483. * Represents the different options available during the creation of
  98484. * a Environment helper.
  98485. *
  98486. * This can control the default ground, skybox and image processing setup of your scene.
  98487. */
  98488. export interface IEnvironmentHelperOptions {
  98489. /**
  98490. * Specifies wether or not to create a ground.
  98491. * True by default.
  98492. */
  98493. createGround: boolean;
  98494. /**
  98495. * Specifies the ground size.
  98496. * 15 by default.
  98497. */
  98498. groundSize: number;
  98499. /**
  98500. * The texture used on the ground for the main color.
  98501. * Comes from the BabylonJS CDN by default.
  98502. *
  98503. * Remarks: Can be either a texture or a url.
  98504. */
  98505. groundTexture: string | BaseTexture;
  98506. /**
  98507. * The color mixed in the ground texture by default.
  98508. * BabylonJS clearColor by default.
  98509. */
  98510. groundColor: Color3;
  98511. /**
  98512. * Specifies the ground opacity.
  98513. * 1 by default.
  98514. */
  98515. groundOpacity: number;
  98516. /**
  98517. * Enables the ground to receive shadows.
  98518. * True by default.
  98519. */
  98520. enableGroundShadow: boolean;
  98521. /**
  98522. * Helps preventing the shadow to be fully black on the ground.
  98523. * 0.5 by default.
  98524. */
  98525. groundShadowLevel: number;
  98526. /**
  98527. * Creates a mirror texture attach to the ground.
  98528. * false by default.
  98529. */
  98530. enableGroundMirror: boolean;
  98531. /**
  98532. * Specifies the ground mirror size ratio.
  98533. * 0.3 by default as the default kernel is 64.
  98534. */
  98535. groundMirrorSizeRatio: number;
  98536. /**
  98537. * Specifies the ground mirror blur kernel size.
  98538. * 64 by default.
  98539. */
  98540. groundMirrorBlurKernel: number;
  98541. /**
  98542. * Specifies the ground mirror visibility amount.
  98543. * 1 by default
  98544. */
  98545. groundMirrorAmount: number;
  98546. /**
  98547. * Specifies the ground mirror reflectance weight.
  98548. * This uses the standard weight of the background material to setup the fresnel effect
  98549. * of the mirror.
  98550. * 1 by default.
  98551. */
  98552. groundMirrorFresnelWeight: number;
  98553. /**
  98554. * Specifies the ground mirror Falloff distance.
  98555. * This can helps reducing the size of the reflection.
  98556. * 0 by Default.
  98557. */
  98558. groundMirrorFallOffDistance: number;
  98559. /**
  98560. * Specifies the ground mirror texture type.
  98561. * Unsigned Int by Default.
  98562. */
  98563. groundMirrorTextureType: number;
  98564. /**
  98565. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98566. * the shown objects.
  98567. */
  98568. groundYBias: number;
  98569. /**
  98570. * Specifies wether or not to create a skybox.
  98571. * True by default.
  98572. */
  98573. createSkybox: boolean;
  98574. /**
  98575. * Specifies the skybox size.
  98576. * 20 by default.
  98577. */
  98578. skyboxSize: number;
  98579. /**
  98580. * The texture used on the skybox for the main color.
  98581. * Comes from the BabylonJS CDN by default.
  98582. *
  98583. * Remarks: Can be either a texture or a url.
  98584. */
  98585. skyboxTexture: string | BaseTexture;
  98586. /**
  98587. * The color mixed in the skybox texture by default.
  98588. * BabylonJS clearColor by default.
  98589. */
  98590. skyboxColor: Color3;
  98591. /**
  98592. * The background rotation around the Y axis of the scene.
  98593. * This helps aligning the key lights of your scene with the background.
  98594. * 0 by default.
  98595. */
  98596. backgroundYRotation: number;
  98597. /**
  98598. * Compute automatically the size of the elements to best fit with the scene.
  98599. */
  98600. sizeAuto: boolean;
  98601. /**
  98602. * Default position of the rootMesh if autoSize is not true.
  98603. */
  98604. rootPosition: Vector3;
  98605. /**
  98606. * Sets up the image processing in the scene.
  98607. * true by default.
  98608. */
  98609. setupImageProcessing: boolean;
  98610. /**
  98611. * The texture used as your environment texture in the scene.
  98612. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98613. *
  98614. * Remarks: Can be either a texture or a url.
  98615. */
  98616. environmentTexture: string | BaseTexture;
  98617. /**
  98618. * The value of the exposure to apply to the scene.
  98619. * 0.6 by default if setupImageProcessing is true.
  98620. */
  98621. cameraExposure: number;
  98622. /**
  98623. * The value of the contrast to apply to the scene.
  98624. * 1.6 by default if setupImageProcessing is true.
  98625. */
  98626. cameraContrast: number;
  98627. /**
  98628. * Specifies wether or not tonemapping should be enabled in the scene.
  98629. * true by default if setupImageProcessing is true.
  98630. */
  98631. toneMappingEnabled: boolean;
  98632. }
  98633. /**
  98634. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98635. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98636. * It also helps with the default setup of your imageProcessing configuration.
  98637. */
  98638. export class EnvironmentHelper {
  98639. /**
  98640. * Default ground texture URL.
  98641. */
  98642. private static _groundTextureCDNUrl;
  98643. /**
  98644. * Default skybox texture URL.
  98645. */
  98646. private static _skyboxTextureCDNUrl;
  98647. /**
  98648. * Default environment texture URL.
  98649. */
  98650. private static _environmentTextureCDNUrl;
  98651. /**
  98652. * Creates the default options for the helper.
  98653. */
  98654. private static _getDefaultOptions;
  98655. private _rootMesh;
  98656. /**
  98657. * Gets the root mesh created by the helper.
  98658. */
  98659. readonly rootMesh: Mesh;
  98660. private _skybox;
  98661. /**
  98662. * Gets the skybox created by the helper.
  98663. */
  98664. readonly skybox: Nullable<Mesh>;
  98665. private _skyboxTexture;
  98666. /**
  98667. * Gets the skybox texture created by the helper.
  98668. */
  98669. readonly skyboxTexture: Nullable<BaseTexture>;
  98670. private _skyboxMaterial;
  98671. /**
  98672. * Gets the skybox material created by the helper.
  98673. */
  98674. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98675. private _ground;
  98676. /**
  98677. * Gets the ground mesh created by the helper.
  98678. */
  98679. readonly ground: Nullable<Mesh>;
  98680. private _groundTexture;
  98681. /**
  98682. * Gets the ground texture created by the helper.
  98683. */
  98684. readonly groundTexture: Nullable<BaseTexture>;
  98685. private _groundMirror;
  98686. /**
  98687. * Gets the ground mirror created by the helper.
  98688. */
  98689. readonly groundMirror: Nullable<MirrorTexture>;
  98690. /**
  98691. * Gets the ground mirror render list to helps pushing the meshes
  98692. * you wish in the ground reflection.
  98693. */
  98694. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98695. private _groundMaterial;
  98696. /**
  98697. * Gets the ground material created by the helper.
  98698. */
  98699. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98700. /**
  98701. * Stores the creation options.
  98702. */
  98703. private readonly _scene;
  98704. private _options;
  98705. /**
  98706. * This observable will be notified with any error during the creation of the environment,
  98707. * mainly texture creation errors.
  98708. */
  98709. onErrorObservable: Observable<{
  98710. message?: string;
  98711. exception?: any;
  98712. }>;
  98713. /**
  98714. * constructor
  98715. * @param options
  98716. * @param scene The scene to add the material to
  98717. */
  98718. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98719. /**
  98720. * Updates the background according to the new options
  98721. * @param options
  98722. */
  98723. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98724. /**
  98725. * Sets the primary color of all the available elements.
  98726. * @param color the main color to affect to the ground and the background
  98727. */
  98728. setMainColor(color: Color3): void;
  98729. /**
  98730. * Setup the image processing according to the specified options.
  98731. */
  98732. private _setupImageProcessing;
  98733. /**
  98734. * Setup the environment texture according to the specified options.
  98735. */
  98736. private _setupEnvironmentTexture;
  98737. /**
  98738. * Setup the background according to the specified options.
  98739. */
  98740. private _setupBackground;
  98741. /**
  98742. * Get the scene sizes according to the setup.
  98743. */
  98744. private _getSceneSize;
  98745. /**
  98746. * Setup the ground according to the specified options.
  98747. */
  98748. private _setupGround;
  98749. /**
  98750. * Setup the ground material according to the specified options.
  98751. */
  98752. private _setupGroundMaterial;
  98753. /**
  98754. * Setup the ground diffuse texture according to the specified options.
  98755. */
  98756. private _setupGroundDiffuseTexture;
  98757. /**
  98758. * Setup the ground mirror texture according to the specified options.
  98759. */
  98760. private _setupGroundMirrorTexture;
  98761. /**
  98762. * Setup the ground to receive the mirror texture.
  98763. */
  98764. private _setupMirrorInGroundMaterial;
  98765. /**
  98766. * Setup the skybox according to the specified options.
  98767. */
  98768. private _setupSkybox;
  98769. /**
  98770. * Setup the skybox material according to the specified options.
  98771. */
  98772. private _setupSkyboxMaterial;
  98773. /**
  98774. * Setup the skybox reflection texture according to the specified options.
  98775. */
  98776. private _setupSkyboxReflectionTexture;
  98777. private _errorHandler;
  98778. /**
  98779. * Dispose all the elements created by the Helper.
  98780. */
  98781. dispose(): void;
  98782. }
  98783. }
  98784. declare module BABYLON {
  98785. /**
  98786. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98787. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98788. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98789. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98790. */
  98791. export class PhotoDome extends TransformNode {
  98792. private _useDirectMapping;
  98793. /**
  98794. * The texture being displayed on the sphere
  98795. */
  98796. protected _photoTexture: Texture;
  98797. /**
  98798. * Gets or sets the texture being displayed on the sphere
  98799. */
  98800. photoTexture: Texture;
  98801. /**
  98802. * Observable raised when an error occured while loading the 360 image
  98803. */
  98804. onLoadErrorObservable: Observable<string>;
  98805. /**
  98806. * The skybox material
  98807. */
  98808. protected _material: BackgroundMaterial;
  98809. /**
  98810. * The surface used for the skybox
  98811. */
  98812. protected _mesh: Mesh;
  98813. /**
  98814. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98815. * Also see the options.resolution property.
  98816. */
  98817. fovMultiplier: number;
  98818. /**
  98819. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98820. * @param name Element's name, child elements will append suffixes for their own names.
  98821. * @param urlsOfPhoto defines the url of the photo to display
  98822. * @param options defines an object containing optional or exposed sub element properties
  98823. * @param onError defines a callback called when an error occured while loading the texture
  98824. */
  98825. constructor(name: string, urlOfPhoto: string, options: {
  98826. resolution?: number;
  98827. size?: number;
  98828. useDirectMapping?: boolean;
  98829. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98830. /**
  98831. * Releases resources associated with this node.
  98832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98834. */
  98835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98836. }
  98837. }
  98838. declare module BABYLON {
  98839. /**
  98840. * Class used to host texture specific utilities
  98841. */
  98842. export class TextureTools {
  98843. /**
  98844. * Uses the GPU to create a copy texture rescaled at a given size
  98845. * @param texture Texture to copy from
  98846. * @param width defines the desired width
  98847. * @param height defines the desired height
  98848. * @param useBilinearMode defines if bilinear mode has to be used
  98849. * @return the generated texture
  98850. */
  98851. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98852. /**
  98853. * Gets an environment BRDF texture for a given scene
  98854. * @param scene defines the hosting scene
  98855. * @returns the environment BRDF texture
  98856. */
  98857. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98858. private static _environmentBRDFBase64Texture;
  98859. }
  98860. }
  98861. declare module BABYLON {
  98862. /** @hidden */
  98863. export var pbrFragmentDeclaration: {
  98864. name: string;
  98865. shader: string;
  98866. };
  98867. }
  98868. declare module BABYLON {
  98869. /** @hidden */
  98870. export var pbrUboDeclaration: {
  98871. name: string;
  98872. shader: string;
  98873. };
  98874. }
  98875. declare module BABYLON {
  98876. /** @hidden */
  98877. export var pbrFunctions: {
  98878. name: string;
  98879. shader: string;
  98880. };
  98881. }
  98882. declare module BABYLON {
  98883. /** @hidden */
  98884. export var harmonicsFunctions: {
  98885. name: string;
  98886. shader: string;
  98887. };
  98888. }
  98889. declare module BABYLON {
  98890. /** @hidden */
  98891. export var pbrLightFunctions: {
  98892. name: string;
  98893. shader: string;
  98894. };
  98895. }
  98896. declare module BABYLON {
  98897. /** @hidden */
  98898. export var pbrPixelShader: {
  98899. name: string;
  98900. shader: string;
  98901. };
  98902. }
  98903. declare module BABYLON {
  98904. /** @hidden */
  98905. export var pbrVertexDeclaration: {
  98906. name: string;
  98907. shader: string;
  98908. };
  98909. }
  98910. declare module BABYLON {
  98911. /** @hidden */
  98912. export var pbrVertexShader: {
  98913. name: string;
  98914. shader: string;
  98915. };
  98916. }
  98917. declare module BABYLON {
  98918. /**
  98919. * The Physically based material base class of BJS.
  98920. *
  98921. * This offers the main features of a standard PBR material.
  98922. * For more information, please refer to the documentation :
  98923. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98924. */
  98925. export abstract class PBRBaseMaterial extends PushMaterial {
  98926. /**
  98927. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98928. */
  98929. static readonly PBRMATERIAL_OPAQUE: number;
  98930. /**
  98931. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98932. */
  98933. static readonly PBRMATERIAL_ALPHATEST: number;
  98934. /**
  98935. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98936. */
  98937. static readonly PBRMATERIAL_ALPHABLEND: number;
  98938. /**
  98939. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98940. * They are also discarded below the alpha cutoff threshold to improve performances.
  98941. */
  98942. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98943. /**
  98944. * Defines the default value of how much AO map is occluding the analytical lights
  98945. * (point spot...).
  98946. */
  98947. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98948. /**
  98949. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98950. */
  98951. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98952. /**
  98953. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98954. * to enhance interoperability with other engines.
  98955. */
  98956. static readonly LIGHTFALLOFF_GLTF: number;
  98957. /**
  98958. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98959. * to enhance interoperability with other materials.
  98960. */
  98961. static readonly LIGHTFALLOFF_STANDARD: number;
  98962. /**
  98963. * Intensity of the direct lights e.g. the four lights available in your scene.
  98964. * This impacts both the direct diffuse and specular highlights.
  98965. */
  98966. protected _directIntensity: number;
  98967. /**
  98968. * Intensity of the emissive part of the material.
  98969. * This helps controlling the emissive effect without modifying the emissive color.
  98970. */
  98971. protected _emissiveIntensity: number;
  98972. /**
  98973. * Intensity of the environment e.g. how much the environment will light the object
  98974. * either through harmonics for rough material or through the refelction for shiny ones.
  98975. */
  98976. protected _environmentIntensity: number;
  98977. /**
  98978. * This is a special control allowing the reduction of the specular highlights coming from the
  98979. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98980. */
  98981. protected _specularIntensity: number;
  98982. /**
  98983. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98984. */
  98985. private _lightingInfos;
  98986. /**
  98987. * Debug Control allowing disabling the bump map on this material.
  98988. */
  98989. protected _disableBumpMap: boolean;
  98990. /**
  98991. * AKA Diffuse Texture in standard nomenclature.
  98992. */
  98993. protected _albedoTexture: BaseTexture;
  98994. /**
  98995. * AKA Occlusion Texture in other nomenclature.
  98996. */
  98997. protected _ambientTexture: BaseTexture;
  98998. /**
  98999. * AKA Occlusion Texture Intensity in other nomenclature.
  99000. */
  99001. protected _ambientTextureStrength: number;
  99002. /**
  99003. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99004. * 1 means it completely occludes it
  99005. * 0 mean it has no impact
  99006. */
  99007. protected _ambientTextureImpactOnAnalyticalLights: number;
  99008. /**
  99009. * Stores the alpha values in a texture.
  99010. */
  99011. protected _opacityTexture: BaseTexture;
  99012. /**
  99013. * Stores the reflection values in a texture.
  99014. */
  99015. protected _reflectionTexture: BaseTexture;
  99016. /**
  99017. * Stores the refraction values in a texture.
  99018. */
  99019. protected _refractionTexture: BaseTexture;
  99020. /**
  99021. * Stores the emissive values in a texture.
  99022. */
  99023. protected _emissiveTexture: BaseTexture;
  99024. /**
  99025. * AKA Specular texture in other nomenclature.
  99026. */
  99027. protected _reflectivityTexture: BaseTexture;
  99028. /**
  99029. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99030. */
  99031. protected _metallicTexture: BaseTexture;
  99032. /**
  99033. * Specifies the metallic scalar of the metallic/roughness workflow.
  99034. * Can also be used to scale the metalness values of the metallic texture.
  99035. */
  99036. protected _metallic: Nullable<number>;
  99037. /**
  99038. * Specifies the roughness scalar of the metallic/roughness workflow.
  99039. * Can also be used to scale the roughness values of the metallic texture.
  99040. */
  99041. protected _roughness: Nullable<number>;
  99042. /**
  99043. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99044. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99045. */
  99046. protected _microSurfaceTexture: BaseTexture;
  99047. /**
  99048. * Stores surface normal data used to displace a mesh in a texture.
  99049. */
  99050. protected _bumpTexture: BaseTexture;
  99051. /**
  99052. * Stores the pre-calculated light information of a mesh in a texture.
  99053. */
  99054. protected _lightmapTexture: BaseTexture;
  99055. /**
  99056. * The color of a material in ambient lighting.
  99057. */
  99058. protected _ambientColor: Color3;
  99059. /**
  99060. * AKA Diffuse Color in other nomenclature.
  99061. */
  99062. protected _albedoColor: Color3;
  99063. /**
  99064. * AKA Specular Color in other nomenclature.
  99065. */
  99066. protected _reflectivityColor: Color3;
  99067. /**
  99068. * The color applied when light is reflected from a material.
  99069. */
  99070. protected _reflectionColor: Color3;
  99071. /**
  99072. * The color applied when light is emitted from a material.
  99073. */
  99074. protected _emissiveColor: Color3;
  99075. /**
  99076. * AKA Glossiness in other nomenclature.
  99077. */
  99078. protected _microSurface: number;
  99079. /**
  99080. * source material index of refraction (IOR)' / 'destination material IOR.
  99081. */
  99082. protected _indexOfRefraction: number;
  99083. /**
  99084. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99085. */
  99086. protected _invertRefractionY: boolean;
  99087. /**
  99088. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99089. * Materials half opaque for instance using refraction could benefit from this control.
  99090. */
  99091. protected _linkRefractionWithTransparency: boolean;
  99092. /**
  99093. * Specifies that the material will use the light map as a show map.
  99094. */
  99095. protected _useLightmapAsShadowmap: boolean;
  99096. /**
  99097. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99098. * makes the reflect vector face the model (under horizon).
  99099. */
  99100. protected _useHorizonOcclusion: boolean;
  99101. /**
  99102. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99103. * too much the area relying on ambient texture to define their ambient occlusion.
  99104. */
  99105. protected _useRadianceOcclusion: boolean;
  99106. /**
  99107. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99108. */
  99109. protected _useAlphaFromAlbedoTexture: boolean;
  99110. /**
  99111. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  99112. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99113. */
  99114. protected _useSpecularOverAlpha: boolean;
  99115. /**
  99116. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99117. */
  99118. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99119. /**
  99120. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99121. */
  99122. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  99123. /**
  99124. * Specifies if the metallic texture contains the roughness information in its green channel.
  99125. */
  99126. protected _useRoughnessFromMetallicTextureGreen: boolean;
  99127. /**
  99128. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99129. */
  99130. protected _useMetallnessFromMetallicTextureBlue: boolean;
  99131. /**
  99132. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99133. */
  99134. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  99135. /**
  99136. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99137. */
  99138. protected _useAmbientInGrayScale: boolean;
  99139. /**
  99140. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99141. * The material will try to infer what glossiness each pixel should be.
  99142. */
  99143. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  99144. /**
  99145. * Defines the falloff type used in this material.
  99146. * It by default is Physical.
  99147. */
  99148. protected _lightFalloff: number;
  99149. /**
  99150. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99151. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99152. */
  99153. protected _useRadianceOverAlpha: boolean;
  99154. /**
  99155. * Allows using an object space normal map (instead of tangent space).
  99156. */
  99157. protected _useObjectSpaceNormalMap: boolean;
  99158. /**
  99159. * Allows using the bump map in parallax mode.
  99160. */
  99161. protected _useParallax: boolean;
  99162. /**
  99163. * Allows using the bump map in parallax occlusion mode.
  99164. */
  99165. protected _useParallaxOcclusion: boolean;
  99166. /**
  99167. * Controls the scale bias of the parallax mode.
  99168. */
  99169. protected _parallaxScaleBias: number;
  99170. /**
  99171. * If sets to true, disables all the lights affecting the material.
  99172. */
  99173. protected _disableLighting: boolean;
  99174. /**
  99175. * Number of Simultaneous lights allowed on the material.
  99176. */
  99177. protected _maxSimultaneousLights: number;
  99178. /**
  99179. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99180. */
  99181. protected _invertNormalMapX: boolean;
  99182. /**
  99183. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99184. */
  99185. protected _invertNormalMapY: boolean;
  99186. /**
  99187. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99188. */
  99189. protected _twoSidedLighting: boolean;
  99190. /**
  99191. * Defines the alpha limits in alpha test mode.
  99192. */
  99193. protected _alphaCutOff: number;
  99194. /**
  99195. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99196. */
  99197. protected _forceAlphaTest: boolean;
  99198. /**
  99199. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99200. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99201. */
  99202. protected _useAlphaFresnel: boolean;
  99203. /**
  99204. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99205. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99206. */
  99207. protected _useLinearAlphaFresnel: boolean;
  99208. /**
  99209. * The transparency mode of the material.
  99210. */
  99211. protected _transparencyMode: Nullable<number>;
  99212. /**
  99213. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99214. * from cos thetav and roughness:
  99215. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99216. */
  99217. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99218. /**
  99219. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99220. */
  99221. protected _forceIrradianceInFragment: boolean;
  99222. /**
  99223. * Force normal to face away from face.
  99224. */
  99225. protected _forceNormalForward: boolean;
  99226. /**
  99227. * Enables specular anti aliasing in the PBR shader.
  99228. * It will both interacts on the Geometry for analytical and IBL lighting.
  99229. * It also prefilter the roughness map based on the bump values.
  99230. */
  99231. protected _enableSpecularAntiAliasing: boolean;
  99232. /**
  99233. * Default configuration related to image processing available in the PBR Material.
  99234. */
  99235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99236. /**
  99237. * Keep track of the image processing observer to allow dispose and replace.
  99238. */
  99239. private _imageProcessingObserver;
  99240. /**
  99241. * Attaches a new image processing configuration to the PBR Material.
  99242. * @param configuration
  99243. */
  99244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99245. /**
  99246. * Stores the available render targets.
  99247. */
  99248. private _renderTargets;
  99249. /**
  99250. * Sets the global ambient color for the material used in lighting calculations.
  99251. */
  99252. private _globalAmbientColor;
  99253. /**
  99254. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99255. */
  99256. private _useLogarithmicDepth;
  99257. /**
  99258. * If set to true, no lighting calculations will be applied.
  99259. */
  99260. private _unlit;
  99261. /**
  99262. * Instantiates a new PBRMaterial instance.
  99263. *
  99264. * @param name The material name
  99265. * @param scene The scene the material will be use in.
  99266. */
  99267. constructor(name: string, scene: Scene);
  99268. /**
  99269. * Gets a boolean indicating that current material needs to register RTT
  99270. */
  99271. readonly hasRenderTargetTextures: boolean;
  99272. /**
  99273. * Gets the name of the material class.
  99274. */
  99275. getClassName(): string;
  99276. /**
  99277. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99278. */
  99279. /**
  99280. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99281. */
  99282. useLogarithmicDepth: boolean;
  99283. /**
  99284. * Gets the current transparency mode.
  99285. */
  99286. /**
  99287. * Sets the transparency mode of the material.
  99288. *
  99289. * | Value | Type | Description |
  99290. * | ----- | ----------------------------------- | ----------- |
  99291. * | 0 | OPAQUE | |
  99292. * | 1 | ALPHATEST | |
  99293. * | 2 | ALPHABLEND | |
  99294. * | 3 | ALPHATESTANDBLEND | |
  99295. *
  99296. */
  99297. transparencyMode: Nullable<number>;
  99298. /**
  99299. * Returns true if alpha blending should be disabled.
  99300. */
  99301. private readonly _disableAlphaBlending;
  99302. /**
  99303. * Specifies whether or not this material should be rendered in alpha blend mode.
  99304. */
  99305. needAlphaBlending(): boolean;
  99306. /**
  99307. * Specifies if the mesh will require alpha blending.
  99308. * @param mesh - BJS mesh.
  99309. */
  99310. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99311. /**
  99312. * Specifies whether or not this material should be rendered in alpha test mode.
  99313. */
  99314. needAlphaTesting(): boolean;
  99315. /**
  99316. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99317. */
  99318. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99319. /**
  99320. * Gets the texture used for the alpha test.
  99321. */
  99322. getAlphaTestTexture(): BaseTexture;
  99323. /**
  99324. * Specifies that the submesh is ready to be used.
  99325. * @param mesh - BJS mesh.
  99326. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99327. * @param useInstances - Specifies that instances should be used.
  99328. * @returns - boolean indicating that the submesh is ready or not.
  99329. */
  99330. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99331. /**
  99332. * Specifies if the material uses metallic roughness workflow.
  99333. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99334. */
  99335. isMetallicWorkflow(): boolean;
  99336. private _prepareEffect;
  99337. private _prepareDefines;
  99338. /**
  99339. * Force shader compilation
  99340. */
  99341. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99342. clipPlane: boolean;
  99343. }>): void;
  99344. /**
  99345. * Initializes the uniform buffer layout for the shader.
  99346. */
  99347. buildUniformLayout(): void;
  99348. /**
  99349. * Unbinds the textures.
  99350. */
  99351. unbind(): void;
  99352. /**
  99353. * Binds the submesh data.
  99354. * @param world - The world matrix.
  99355. * @param mesh - The BJS mesh.
  99356. * @param subMesh - A submesh of the BJS mesh.
  99357. */
  99358. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99359. /**
  99360. * Returns the animatable textures.
  99361. * @returns - Array of animatable textures.
  99362. */
  99363. getAnimatables(): IAnimatable[];
  99364. /**
  99365. * Returns the texture used for reflections.
  99366. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99367. */
  99368. private _getReflectionTexture;
  99369. /**
  99370. * Returns the texture used for refraction or null if none is used.
  99371. * @returns - Refection texture if present. If no refraction texture and refraction
  99372. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99373. */
  99374. private _getRefractionTexture;
  99375. /**
  99376. * Disposes the resources of the material.
  99377. * @param forceDisposeEffect - Forces the disposal of effects.
  99378. * @param forceDisposeTextures - Forces the disposal of all textures.
  99379. */
  99380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99381. }
  99382. }
  99383. declare module BABYLON {
  99384. /**
  99385. * The Physically based material of BJS.
  99386. *
  99387. * This offers the main features of a standard PBR material.
  99388. * For more information, please refer to the documentation :
  99389. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99390. */
  99391. export class PBRMaterial extends PBRBaseMaterial {
  99392. /**
  99393. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99394. */
  99395. static readonly PBRMATERIAL_OPAQUE: number;
  99396. /**
  99397. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99398. */
  99399. static readonly PBRMATERIAL_ALPHATEST: number;
  99400. /**
  99401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99402. */
  99403. static readonly PBRMATERIAL_ALPHABLEND: number;
  99404. /**
  99405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99406. * They are also discarded below the alpha cutoff threshold to improve performances.
  99407. */
  99408. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99409. /**
  99410. * Defines the default value of how much AO map is occluding the analytical lights
  99411. * (point spot...).
  99412. */
  99413. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99414. /**
  99415. * Intensity of the direct lights e.g. the four lights available in your scene.
  99416. * This impacts both the direct diffuse and specular highlights.
  99417. */
  99418. directIntensity: number;
  99419. /**
  99420. * Intensity of the emissive part of the material.
  99421. * This helps controlling the emissive effect without modifying the emissive color.
  99422. */
  99423. emissiveIntensity: number;
  99424. /**
  99425. * Intensity of the environment e.g. how much the environment will light the object
  99426. * either through harmonics for rough material or through the refelction for shiny ones.
  99427. */
  99428. environmentIntensity: number;
  99429. /**
  99430. * This is a special control allowing the reduction of the specular highlights coming from the
  99431. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99432. */
  99433. specularIntensity: number;
  99434. /**
  99435. * Debug Control allowing disabling the bump map on this material.
  99436. */
  99437. disableBumpMap: boolean;
  99438. /**
  99439. * AKA Diffuse Texture in standard nomenclature.
  99440. */
  99441. albedoTexture: BaseTexture;
  99442. /**
  99443. * AKA Occlusion Texture in other nomenclature.
  99444. */
  99445. ambientTexture: BaseTexture;
  99446. /**
  99447. * AKA Occlusion Texture Intensity in other nomenclature.
  99448. */
  99449. ambientTextureStrength: number;
  99450. /**
  99451. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99452. * 1 means it completely occludes it
  99453. * 0 mean it has no impact
  99454. */
  99455. ambientTextureImpactOnAnalyticalLights: number;
  99456. /**
  99457. * Stores the alpha values in a texture.
  99458. */
  99459. opacityTexture: BaseTexture;
  99460. /**
  99461. * Stores the reflection values in a texture.
  99462. */
  99463. reflectionTexture: Nullable<BaseTexture>;
  99464. /**
  99465. * Stores the emissive values in a texture.
  99466. */
  99467. emissiveTexture: BaseTexture;
  99468. /**
  99469. * AKA Specular texture in other nomenclature.
  99470. */
  99471. reflectivityTexture: BaseTexture;
  99472. /**
  99473. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99474. */
  99475. metallicTexture: BaseTexture;
  99476. /**
  99477. * Specifies the metallic scalar of the metallic/roughness workflow.
  99478. * Can also be used to scale the metalness values of the metallic texture.
  99479. */
  99480. metallic: Nullable<number>;
  99481. /**
  99482. * Specifies the roughness scalar of the metallic/roughness workflow.
  99483. * Can also be used to scale the roughness values of the metallic texture.
  99484. */
  99485. roughness: Nullable<number>;
  99486. /**
  99487. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99488. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99489. */
  99490. microSurfaceTexture: BaseTexture;
  99491. /**
  99492. * Stores surface normal data used to displace a mesh in a texture.
  99493. */
  99494. bumpTexture: BaseTexture;
  99495. /**
  99496. * Stores the pre-calculated light information of a mesh in a texture.
  99497. */
  99498. lightmapTexture: BaseTexture;
  99499. /**
  99500. * Stores the refracted light information in a texture.
  99501. */
  99502. refractionTexture: BaseTexture;
  99503. /**
  99504. * The color of a material in ambient lighting.
  99505. */
  99506. ambientColor: Color3;
  99507. /**
  99508. * AKA Diffuse Color in other nomenclature.
  99509. */
  99510. albedoColor: Color3;
  99511. /**
  99512. * AKA Specular Color in other nomenclature.
  99513. */
  99514. reflectivityColor: Color3;
  99515. /**
  99516. * The color reflected from the material.
  99517. */
  99518. reflectionColor: Color3;
  99519. /**
  99520. * The color emitted from the material.
  99521. */
  99522. emissiveColor: Color3;
  99523. /**
  99524. * AKA Glossiness in other nomenclature.
  99525. */
  99526. microSurface: number;
  99527. /**
  99528. * source material index of refraction (IOR)' / 'destination material IOR.
  99529. */
  99530. indexOfRefraction: number;
  99531. /**
  99532. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99533. */
  99534. invertRefractionY: boolean;
  99535. /**
  99536. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99537. * Materials half opaque for instance using refraction could benefit from this control.
  99538. */
  99539. linkRefractionWithTransparency: boolean;
  99540. /**
  99541. * If true, the light map contains occlusion information instead of lighting info.
  99542. */
  99543. useLightmapAsShadowmap: boolean;
  99544. /**
  99545. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99546. */
  99547. useAlphaFromAlbedoTexture: boolean;
  99548. /**
  99549. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99550. */
  99551. forceAlphaTest: boolean;
  99552. /**
  99553. * Defines the alpha limits in alpha test mode.
  99554. */
  99555. alphaCutOff: number;
  99556. /**
  99557. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99558. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99559. */
  99560. useSpecularOverAlpha: boolean;
  99561. /**
  99562. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99563. */
  99564. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99565. /**
  99566. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99567. */
  99568. useRoughnessFromMetallicTextureAlpha: boolean;
  99569. /**
  99570. * Specifies if the metallic texture contains the roughness information in its green channel.
  99571. */
  99572. useRoughnessFromMetallicTextureGreen: boolean;
  99573. /**
  99574. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99575. */
  99576. useMetallnessFromMetallicTextureBlue: boolean;
  99577. /**
  99578. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99579. */
  99580. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99581. /**
  99582. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99583. */
  99584. useAmbientInGrayScale: boolean;
  99585. /**
  99586. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99587. * The material will try to infer what glossiness each pixel should be.
  99588. */
  99589. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99590. /**
  99591. * BJS is using an harcoded light falloff based on a manually sets up range.
  99592. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99593. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99594. */
  99595. /**
  99596. * BJS is using an harcoded light falloff based on a manually sets up range.
  99597. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99598. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99599. */
  99600. usePhysicalLightFalloff: boolean;
  99601. /**
  99602. * In order to support the falloff compatibility with gltf, a special mode has been added
  99603. * to reproduce the gltf light falloff.
  99604. */
  99605. /**
  99606. * In order to support the falloff compatibility with gltf, a special mode has been added
  99607. * to reproduce the gltf light falloff.
  99608. */
  99609. useGLTFLightFalloff: boolean;
  99610. /**
  99611. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99612. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99613. */
  99614. useRadianceOverAlpha: boolean;
  99615. /**
  99616. * Allows using an object space normal map (instead of tangent space).
  99617. */
  99618. useObjectSpaceNormalMap: boolean;
  99619. /**
  99620. * Allows using the bump map in parallax mode.
  99621. */
  99622. useParallax: boolean;
  99623. /**
  99624. * Allows using the bump map in parallax occlusion mode.
  99625. */
  99626. useParallaxOcclusion: boolean;
  99627. /**
  99628. * Controls the scale bias of the parallax mode.
  99629. */
  99630. parallaxScaleBias: number;
  99631. /**
  99632. * If sets to true, disables all the lights affecting the material.
  99633. */
  99634. disableLighting: boolean;
  99635. /**
  99636. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99637. */
  99638. forceIrradianceInFragment: boolean;
  99639. /**
  99640. * Number of Simultaneous lights allowed on the material.
  99641. */
  99642. maxSimultaneousLights: number;
  99643. /**
  99644. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99645. */
  99646. invertNormalMapX: boolean;
  99647. /**
  99648. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99649. */
  99650. invertNormalMapY: boolean;
  99651. /**
  99652. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99653. */
  99654. twoSidedLighting: boolean;
  99655. /**
  99656. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99657. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99658. */
  99659. useAlphaFresnel: boolean;
  99660. /**
  99661. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99662. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99663. */
  99664. useLinearAlphaFresnel: boolean;
  99665. /**
  99666. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99667. * And/Or occlude the blended part.
  99668. */
  99669. environmentBRDFTexture: Nullable<BaseTexture>;
  99670. /**
  99671. * Force normal to face away from face.
  99672. */
  99673. forceNormalForward: boolean;
  99674. /**
  99675. * Enables specular anti aliasing in the PBR shader.
  99676. * It will both interacts on the Geometry for analytical and IBL lighting.
  99677. * It also prefilter the roughness map based on the bump values.
  99678. */
  99679. enableSpecularAntiAliasing: boolean;
  99680. /**
  99681. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99682. * makes the reflect vector face the model (under horizon).
  99683. */
  99684. useHorizonOcclusion: boolean;
  99685. /**
  99686. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99687. * too much the area relying on ambient texture to define their ambient occlusion.
  99688. */
  99689. useRadianceOcclusion: boolean;
  99690. /**
  99691. * If set to true, no lighting calculations will be applied.
  99692. */
  99693. unlit: boolean;
  99694. /**
  99695. * Gets the image processing configuration used either in this material.
  99696. */
  99697. /**
  99698. * Sets the Default image processing configuration used either in the this material.
  99699. *
  99700. * If sets to null, the scene one is in use.
  99701. */
  99702. imageProcessingConfiguration: ImageProcessingConfiguration;
  99703. /**
  99704. * Gets wether the color curves effect is enabled.
  99705. */
  99706. /**
  99707. * Sets wether the color curves effect is enabled.
  99708. */
  99709. cameraColorCurvesEnabled: boolean;
  99710. /**
  99711. * Gets wether the color grading effect is enabled.
  99712. */
  99713. /**
  99714. * Gets wether the color grading effect is enabled.
  99715. */
  99716. cameraColorGradingEnabled: boolean;
  99717. /**
  99718. * Gets wether tonemapping is enabled or not.
  99719. */
  99720. /**
  99721. * Sets wether tonemapping is enabled or not
  99722. */
  99723. cameraToneMappingEnabled: boolean;
  99724. /**
  99725. * The camera exposure used on this material.
  99726. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99727. * This corresponds to a photographic exposure.
  99728. */
  99729. /**
  99730. * The camera exposure used on this material.
  99731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99732. * This corresponds to a photographic exposure.
  99733. */
  99734. cameraExposure: number;
  99735. /**
  99736. * Gets The camera contrast used on this material.
  99737. */
  99738. /**
  99739. * Sets The camera contrast used on this material.
  99740. */
  99741. cameraContrast: number;
  99742. /**
  99743. * Gets the Color Grading 2D Lookup Texture.
  99744. */
  99745. /**
  99746. * Sets the Color Grading 2D Lookup Texture.
  99747. */
  99748. cameraColorGradingTexture: Nullable<BaseTexture>;
  99749. /**
  99750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99752. * 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;
  99753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99754. */
  99755. /**
  99756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99758. * 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;
  99759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99760. */
  99761. cameraColorCurves: Nullable<ColorCurves>;
  99762. /**
  99763. * Instantiates a new PBRMaterial instance.
  99764. *
  99765. * @param name The material name
  99766. * @param scene The scene the material will be use in.
  99767. */
  99768. constructor(name: string, scene: Scene);
  99769. /**
  99770. * Returns the name of this material class.
  99771. */
  99772. getClassName(): string;
  99773. /**
  99774. * Returns an array of the actively used textures.
  99775. * @returns - Array of BaseTextures
  99776. */
  99777. getActiveTextures(): BaseTexture[];
  99778. /**
  99779. * Checks to see if a texture is used in the material.
  99780. * @param texture - Base texture to use.
  99781. * @returns - Boolean specifying if a texture is used in the material.
  99782. */
  99783. hasTexture(texture: BaseTexture): boolean;
  99784. /**
  99785. * Makes a duplicate of the current material.
  99786. * @param name - name to use for the new material.
  99787. */
  99788. clone(name: string): PBRMaterial;
  99789. /**
  99790. * Serializes this PBR Material.
  99791. * @returns - An object with the serialized material.
  99792. */
  99793. serialize(): any;
  99794. /**
  99795. * Parses a PBR Material from a serialized object.
  99796. * @param source - Serialized object.
  99797. * @param scene - BJS scene instance.
  99798. * @param rootUrl - url for the scene object
  99799. * @returns - PBRMaterial
  99800. */
  99801. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99802. }
  99803. }
  99804. declare module BABYLON {
  99805. /** @hidden */
  99806. export var _forceSceneHelpersToBundle: boolean;
  99807. interface Scene {
  99808. /**
  99809. * Creates a default light for the scene.
  99810. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99811. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99812. */
  99813. createDefaultLight(replace?: boolean): void;
  99814. /**
  99815. * Creates a default camera for the scene.
  99816. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99817. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99818. * @param replace has default false, when true replaces the active camera in the scene
  99819. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99820. */
  99821. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99822. /**
  99823. * Creates a default camera and a default light.
  99824. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99825. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99826. * @param replace has the default false, when true replaces the active camera/light in the scene
  99827. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99828. */
  99829. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99830. /**
  99831. * Creates a new sky box
  99832. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99833. * @param environmentTexture defines the texture to use as environment texture
  99834. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99835. * @param scale defines the overall scale of the skybox
  99836. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99837. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99838. * @returns a new mesh holding the sky box
  99839. */
  99840. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99841. /**
  99842. * Creates a new environment
  99843. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99844. * @param options defines the options you can use to configure the environment
  99845. * @returns the new EnvironmentHelper
  99846. */
  99847. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99848. /**
  99849. * Creates a new VREXperienceHelper
  99850. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99851. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99852. * @returns a new VREXperienceHelper
  99853. */
  99854. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99855. /**
  99856. * Creates a new XREXperienceHelper
  99857. * @see http://doc.babylonjs.com/how_to/webxr
  99858. * @returns a promise for a new XREXperienceHelper
  99859. */
  99860. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99861. }
  99862. }
  99863. declare module BABYLON {
  99864. /**
  99865. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99866. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99867. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99868. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99869. */
  99870. export class VideoDome extends TransformNode {
  99871. private _useDirectMapping;
  99872. /**
  99873. * The video texture being displayed on the sphere
  99874. */
  99875. protected _videoTexture: VideoTexture;
  99876. /**
  99877. * Gets the video texture being displayed on the sphere
  99878. */
  99879. readonly videoTexture: VideoTexture;
  99880. /**
  99881. * The skybox material
  99882. */
  99883. protected _material: BackgroundMaterial;
  99884. /**
  99885. * The surface used for the skybox
  99886. */
  99887. protected _mesh: Mesh;
  99888. /**
  99889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99890. * Also see the options.resolution property.
  99891. */
  99892. fovMultiplier: number;
  99893. /**
  99894. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99895. * @param name Element's name, child elements will append suffixes for their own names.
  99896. * @param urlsOrVideo defines the url(s) or the video element to use
  99897. * @param options An object containing optional or exposed sub element properties
  99898. */
  99899. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99900. resolution?: number;
  99901. clickToPlay?: boolean;
  99902. autoPlay?: boolean;
  99903. loop?: boolean;
  99904. size?: number;
  99905. poster?: string;
  99906. useDirectMapping?: boolean;
  99907. }, scene: Scene);
  99908. /**
  99909. * Releases resources associated with this node.
  99910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99912. */
  99913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99914. }
  99915. }
  99916. declare module BABYLON {
  99917. /**
  99918. * This class can be used to get instrumentation data from a Babylon engine
  99919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99920. */
  99921. export class EngineInstrumentation implements IDisposable {
  99922. /**
  99923. * Define the instrumented engine.
  99924. */
  99925. engine: Engine;
  99926. private _captureGPUFrameTime;
  99927. private _gpuFrameTimeToken;
  99928. private _gpuFrameTime;
  99929. private _captureShaderCompilationTime;
  99930. private _shaderCompilationTime;
  99931. private _onBeginFrameObserver;
  99932. private _onEndFrameObserver;
  99933. private _onBeforeShaderCompilationObserver;
  99934. private _onAfterShaderCompilationObserver;
  99935. /**
  99936. * Gets the perf counter used for GPU frame time
  99937. */
  99938. readonly gpuFrameTimeCounter: PerfCounter;
  99939. /**
  99940. * Gets the GPU frame time capture status
  99941. */
  99942. /**
  99943. * Enable or disable the GPU frame time capture
  99944. */
  99945. captureGPUFrameTime: boolean;
  99946. /**
  99947. * Gets the perf counter used for shader compilation time
  99948. */
  99949. readonly shaderCompilationTimeCounter: PerfCounter;
  99950. /**
  99951. * Gets the shader compilation time capture status
  99952. */
  99953. /**
  99954. * Enable or disable the shader compilation time capture
  99955. */
  99956. captureShaderCompilationTime: boolean;
  99957. /**
  99958. * Instantiates a new engine instrumentation.
  99959. * This class can be used to get instrumentation data from a Babylon engine
  99960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99961. * @param engine Defines the engine to instrument
  99962. */
  99963. constructor(
  99964. /**
  99965. * Define the instrumented engine.
  99966. */
  99967. engine: Engine);
  99968. /**
  99969. * Dispose and release associated resources.
  99970. */
  99971. dispose(): void;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * This class can be used to get instrumentation data from a Babylon engine
  99977. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99978. */
  99979. export class SceneInstrumentation implements IDisposable {
  99980. /**
  99981. * Defines the scene to instrument
  99982. */
  99983. scene: Scene;
  99984. private _captureActiveMeshesEvaluationTime;
  99985. private _activeMeshesEvaluationTime;
  99986. private _captureRenderTargetsRenderTime;
  99987. private _renderTargetsRenderTime;
  99988. private _captureFrameTime;
  99989. private _frameTime;
  99990. private _captureRenderTime;
  99991. private _renderTime;
  99992. private _captureInterFrameTime;
  99993. private _interFrameTime;
  99994. private _captureParticlesRenderTime;
  99995. private _particlesRenderTime;
  99996. private _captureSpritesRenderTime;
  99997. private _spritesRenderTime;
  99998. private _capturePhysicsTime;
  99999. private _physicsTime;
  100000. private _captureAnimationsTime;
  100001. private _animationsTime;
  100002. private _captureCameraRenderTime;
  100003. private _cameraRenderTime;
  100004. private _onBeforeActiveMeshesEvaluationObserver;
  100005. private _onAfterActiveMeshesEvaluationObserver;
  100006. private _onBeforeRenderTargetsRenderObserver;
  100007. private _onAfterRenderTargetsRenderObserver;
  100008. private _onAfterRenderObserver;
  100009. private _onBeforeDrawPhaseObserver;
  100010. private _onAfterDrawPhaseObserver;
  100011. private _onBeforeAnimationsObserver;
  100012. private _onBeforeParticlesRenderingObserver;
  100013. private _onAfterParticlesRenderingObserver;
  100014. private _onBeforeSpritesRenderingObserver;
  100015. private _onAfterSpritesRenderingObserver;
  100016. private _onBeforePhysicsObserver;
  100017. private _onAfterPhysicsObserver;
  100018. private _onAfterAnimationsObserver;
  100019. private _onBeforeCameraRenderObserver;
  100020. private _onAfterCameraRenderObserver;
  100021. /**
  100022. * Gets the perf counter used for active meshes evaluation time
  100023. */
  100024. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  100025. /**
  100026. * Gets the active meshes evaluation time capture status
  100027. */
  100028. /**
  100029. * Enable or disable the active meshes evaluation time capture
  100030. */
  100031. captureActiveMeshesEvaluationTime: boolean;
  100032. /**
  100033. * Gets the perf counter used for render targets render time
  100034. */
  100035. readonly renderTargetsRenderTimeCounter: PerfCounter;
  100036. /**
  100037. * Gets the render targets render time capture status
  100038. */
  100039. /**
  100040. * Enable or disable the render targets render time capture
  100041. */
  100042. captureRenderTargetsRenderTime: boolean;
  100043. /**
  100044. * Gets the perf counter used for particles render time
  100045. */
  100046. readonly particlesRenderTimeCounter: PerfCounter;
  100047. /**
  100048. * Gets the particles render time capture status
  100049. */
  100050. /**
  100051. * Enable or disable the particles render time capture
  100052. */
  100053. captureParticlesRenderTime: boolean;
  100054. /**
  100055. * Gets the perf counter used for sprites render time
  100056. */
  100057. readonly spritesRenderTimeCounter: PerfCounter;
  100058. /**
  100059. * Gets the sprites render time capture status
  100060. */
  100061. /**
  100062. * Enable or disable the sprites render time capture
  100063. */
  100064. captureSpritesRenderTime: boolean;
  100065. /**
  100066. * Gets the perf counter used for physics time
  100067. */
  100068. readonly physicsTimeCounter: PerfCounter;
  100069. /**
  100070. * Gets the physics time capture status
  100071. */
  100072. /**
  100073. * Enable or disable the physics time capture
  100074. */
  100075. capturePhysicsTime: boolean;
  100076. /**
  100077. * Gets the perf counter used for animations time
  100078. */
  100079. readonly animationsTimeCounter: PerfCounter;
  100080. /**
  100081. * Gets the animations time capture status
  100082. */
  100083. /**
  100084. * Enable or disable the animations time capture
  100085. */
  100086. captureAnimationsTime: boolean;
  100087. /**
  100088. * Gets the perf counter used for frame time capture
  100089. */
  100090. readonly frameTimeCounter: PerfCounter;
  100091. /**
  100092. * Gets the frame time capture status
  100093. */
  100094. /**
  100095. * Enable or disable the frame time capture
  100096. */
  100097. captureFrameTime: boolean;
  100098. /**
  100099. * Gets the perf counter used for inter-frames time capture
  100100. */
  100101. readonly interFrameTimeCounter: PerfCounter;
  100102. /**
  100103. * Gets the inter-frames time capture status
  100104. */
  100105. /**
  100106. * Enable or disable the inter-frames time capture
  100107. */
  100108. captureInterFrameTime: boolean;
  100109. /**
  100110. * Gets the perf counter used for render time capture
  100111. */
  100112. readonly renderTimeCounter: PerfCounter;
  100113. /**
  100114. * Gets the render time capture status
  100115. */
  100116. /**
  100117. * Enable or disable the render time capture
  100118. */
  100119. captureRenderTime: boolean;
  100120. /**
  100121. * Gets the perf counter used for camera render time capture
  100122. */
  100123. readonly cameraRenderTimeCounter: PerfCounter;
  100124. /**
  100125. * Gets the camera render time capture status
  100126. */
  100127. /**
  100128. * Enable or disable the camera render time capture
  100129. */
  100130. captureCameraRenderTime: boolean;
  100131. /**
  100132. * Gets the perf counter used for draw calls
  100133. */
  100134. readonly drawCallsCounter: PerfCounter;
  100135. /**
  100136. * Gets the perf counter used for texture collisions
  100137. */
  100138. readonly textureCollisionsCounter: PerfCounter;
  100139. /**
  100140. * Instantiates a new scene instrumentation.
  100141. * This class can be used to get instrumentation data from a Babylon engine
  100142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100143. * @param scene Defines the scene to instrument
  100144. */
  100145. constructor(
  100146. /**
  100147. * Defines the scene to instrument
  100148. */
  100149. scene: Scene);
  100150. /**
  100151. * Dispose and release associated resources.
  100152. */
  100153. dispose(): void;
  100154. }
  100155. }
  100156. declare module BABYLON {
  100157. /** @hidden */
  100158. export var glowMapGenerationPixelShader: {
  100159. name: string;
  100160. shader: string;
  100161. };
  100162. }
  100163. declare module BABYLON {
  100164. /** @hidden */
  100165. export var glowMapGenerationVertexShader: {
  100166. name: string;
  100167. shader: string;
  100168. };
  100169. }
  100170. declare module BABYLON {
  100171. /**
  100172. * Effect layer options. This helps customizing the behaviour
  100173. * of the effect layer.
  100174. */
  100175. export interface IEffectLayerOptions {
  100176. /**
  100177. * Multiplication factor apply to the canvas size to compute the render target size
  100178. * used to generated the objects (the smaller the faster).
  100179. */
  100180. mainTextureRatio: number;
  100181. /**
  100182. * Enforces a fixed size texture to ensure effect stability across devices.
  100183. */
  100184. mainTextureFixedSize?: number;
  100185. /**
  100186. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100187. */
  100188. alphaBlendingMode: number;
  100189. /**
  100190. * The camera attached to the layer.
  100191. */
  100192. camera: Nullable<Camera>;
  100193. /**
  100194. * The rendering group to draw the layer in.
  100195. */
  100196. renderingGroupId: number;
  100197. }
  100198. /**
  100199. * The effect layer Helps adding post process effect blended with the main pass.
  100200. *
  100201. * This can be for instance use to generate glow or higlight effects on the scene.
  100202. *
  100203. * The effect layer class can not be used directly and is intented to inherited from to be
  100204. * customized per effects.
  100205. */
  100206. export abstract class EffectLayer {
  100207. private _vertexBuffers;
  100208. private _indexBuffer;
  100209. private _cachedDefines;
  100210. private _effectLayerMapGenerationEffect;
  100211. private _effectLayerOptions;
  100212. private _mergeEffect;
  100213. protected _scene: Scene;
  100214. protected _engine: Engine;
  100215. protected _maxSize: number;
  100216. protected _mainTextureDesiredSize: ISize;
  100217. protected _mainTexture: RenderTargetTexture;
  100218. protected _shouldRender: boolean;
  100219. protected _postProcesses: PostProcess[];
  100220. protected _textures: BaseTexture[];
  100221. protected _emissiveTextureAndColor: {
  100222. texture: Nullable<BaseTexture>;
  100223. color: Color4;
  100224. };
  100225. /**
  100226. * The name of the layer
  100227. */
  100228. name: string;
  100229. /**
  100230. * The clear color of the texture used to generate the glow map.
  100231. */
  100232. neutralColor: Color4;
  100233. /**
  100234. * Specifies wether the highlight layer is enabled or not.
  100235. */
  100236. isEnabled: boolean;
  100237. /**
  100238. * Gets the camera attached to the layer.
  100239. */
  100240. readonly camera: Nullable<Camera>;
  100241. /**
  100242. * Gets the rendering group id the layer should render in.
  100243. */
  100244. readonly renderingGroupId: number;
  100245. /**
  100246. * An event triggered when the effect layer has been disposed.
  100247. */
  100248. onDisposeObservable: Observable<EffectLayer>;
  100249. /**
  100250. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100251. */
  100252. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100253. /**
  100254. * An event triggered when the generated texture is being merged in the scene.
  100255. */
  100256. onBeforeComposeObservable: Observable<EffectLayer>;
  100257. /**
  100258. * An event triggered when the generated texture has been merged in the scene.
  100259. */
  100260. onAfterComposeObservable: Observable<EffectLayer>;
  100261. /**
  100262. * An event triggered when the efffect layer changes its size.
  100263. */
  100264. onSizeChangedObservable: Observable<EffectLayer>;
  100265. /** @hidden */
  100266. static _SceneComponentInitialization: (scene: Scene) => void;
  100267. /**
  100268. * Instantiates a new effect Layer and references it in the scene.
  100269. * @param name The name of the layer
  100270. * @param scene The scene to use the layer in
  100271. */
  100272. constructor(
  100273. /** The Friendly of the effect in the scene */
  100274. name: string, scene: Scene);
  100275. /**
  100276. * Get the effect name of the layer.
  100277. * @return The effect name
  100278. */
  100279. abstract getEffectName(): string;
  100280. /**
  100281. * Checks for the readiness of the element composing the layer.
  100282. * @param subMesh the mesh to check for
  100283. * @param useInstances specify wether or not to use instances to render the mesh
  100284. * @return true if ready otherwise, false
  100285. */
  100286. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100287. /**
  100288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100289. * @returns true if the effect requires stencil during the main canvas render pass.
  100290. */
  100291. abstract needStencil(): boolean;
  100292. /**
  100293. * Create the merge effect. This is the shader use to blit the information back
  100294. * to the main canvas at the end of the scene rendering.
  100295. * @returns The effect containing the shader used to merge the effect on the main canvas
  100296. */
  100297. protected abstract _createMergeEffect(): Effect;
  100298. /**
  100299. * Creates the render target textures and post processes used in the effect layer.
  100300. */
  100301. protected abstract _createTextureAndPostProcesses(): void;
  100302. /**
  100303. * Implementation specific of rendering the generating effect on the main canvas.
  100304. * @param effect The effect used to render through
  100305. */
  100306. protected abstract _internalRender(effect: Effect): void;
  100307. /**
  100308. * Sets the required values for both the emissive texture and and the main color.
  100309. */
  100310. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100311. /**
  100312. * Free any resources and references associated to a mesh.
  100313. * Internal use
  100314. * @param mesh The mesh to free.
  100315. */
  100316. abstract _disposeMesh(mesh: Mesh): void;
  100317. /**
  100318. * Serializes this layer (Glow or Highlight for example)
  100319. * @returns a serialized layer object
  100320. */
  100321. abstract serialize?(): any;
  100322. /**
  100323. * Initializes the effect layer with the required options.
  100324. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100325. */
  100326. protected _init(options: Partial<IEffectLayerOptions>): void;
  100327. /**
  100328. * Generates the index buffer of the full screen quad blending to the main canvas.
  100329. */
  100330. private _generateIndexBuffer;
  100331. /**
  100332. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100333. */
  100334. private _genrateVertexBuffer;
  100335. /**
  100336. * Sets the main texture desired size which is the closest power of two
  100337. * of the engine canvas size.
  100338. */
  100339. private _setMainTextureSize;
  100340. /**
  100341. * Creates the main texture for the effect layer.
  100342. */
  100343. protected _createMainTexture(): void;
  100344. /**
  100345. * Adds specific effects defines.
  100346. * @param defines The defines to add specifics to.
  100347. */
  100348. protected _addCustomEffectDefines(defines: string[]): void;
  100349. /**
  100350. * Checks for the readiness of the element composing the layer.
  100351. * @param subMesh the mesh to check for
  100352. * @param useInstances specify wether or not to use instances to render the mesh
  100353. * @param emissiveTexture the associated emissive texture used to generate the glow
  100354. * @return true if ready otherwise, false
  100355. */
  100356. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100357. /**
  100358. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100359. */
  100360. render(): void;
  100361. /**
  100362. * Determine if a given mesh will be used in the current effect.
  100363. * @param mesh mesh to test
  100364. * @returns true if the mesh will be used
  100365. */
  100366. hasMesh(mesh: AbstractMesh): boolean;
  100367. /**
  100368. * Returns true if the layer contains information to display, otherwise false.
  100369. * @returns true if the glow layer should be rendered
  100370. */
  100371. shouldRender(): boolean;
  100372. /**
  100373. * Returns true if the mesh should render, otherwise false.
  100374. * @param mesh The mesh to render
  100375. * @returns true if it should render otherwise false
  100376. */
  100377. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100378. /**
  100379. * Returns true if the mesh can be rendered, otherwise false.
  100380. * @param mesh The mesh to render
  100381. * @param material The material used on the mesh
  100382. * @returns true if it can be rendered otherwise false
  100383. */
  100384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100385. /**
  100386. * Returns true if the mesh should render, otherwise false.
  100387. * @param mesh The mesh to render
  100388. * @returns true if it should render otherwise false
  100389. */
  100390. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100391. /**
  100392. * Renders the submesh passed in parameter to the generation map.
  100393. */
  100394. protected _renderSubMesh(subMesh: SubMesh): void;
  100395. /**
  100396. * Rebuild the required buffers.
  100397. * @hidden Internal use only.
  100398. */
  100399. _rebuild(): void;
  100400. /**
  100401. * Dispose only the render target textures and post process.
  100402. */
  100403. private _disposeTextureAndPostProcesses;
  100404. /**
  100405. * Dispose the highlight layer and free resources.
  100406. */
  100407. dispose(): void;
  100408. /**
  100409. * Gets the class name of the effect layer
  100410. * @returns the string with the class name of the effect layer
  100411. */
  100412. getClassName(): string;
  100413. /**
  100414. * Creates an effect layer from parsed effect layer data
  100415. * @param parsedEffectLayer defines effect layer data
  100416. * @param scene defines the current scene
  100417. * @param rootUrl defines the root URL containing the effect layer information
  100418. * @returns a parsed effect Layer
  100419. */
  100420. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100421. }
  100422. }
  100423. declare module BABYLON {
  100424. interface AbstractScene {
  100425. /**
  100426. * The list of effect layers (highlights/glow) added to the scene
  100427. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100428. * @see http://doc.babylonjs.com/how_to/glow_layer
  100429. */
  100430. effectLayers: Array<EffectLayer>;
  100431. /**
  100432. * Removes the given effect layer from this scene.
  100433. * @param toRemove defines the effect layer to remove
  100434. * @returns the index of the removed effect layer
  100435. */
  100436. removeEffectLayer(toRemove: EffectLayer): number;
  100437. /**
  100438. * Adds the given effect layer to this scene
  100439. * @param newEffectLayer defines the effect layer to add
  100440. */
  100441. addEffectLayer(newEffectLayer: EffectLayer): void;
  100442. }
  100443. /**
  100444. * Defines the layer scene component responsible to manage any effect layers
  100445. * in a given scene.
  100446. */
  100447. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100448. /**
  100449. * The component name helpfull to identify the component in the list of scene components.
  100450. */
  100451. readonly name: string;
  100452. /**
  100453. * The scene the component belongs to.
  100454. */
  100455. scene: Scene;
  100456. private _engine;
  100457. private _renderEffects;
  100458. private _needStencil;
  100459. private _previousStencilState;
  100460. /**
  100461. * Creates a new instance of the component for the given scene
  100462. * @param scene Defines the scene to register the component in
  100463. */
  100464. constructor(scene: Scene);
  100465. /**
  100466. * Registers the component in a given scene
  100467. */
  100468. register(): void;
  100469. /**
  100470. * Rebuilds the elements related to this component in case of
  100471. * context lost for instance.
  100472. */
  100473. rebuild(): void;
  100474. /**
  100475. * Serializes the component data to the specified json object
  100476. * @param serializationObject The object to serialize to
  100477. */
  100478. serialize(serializationObject: any): void;
  100479. /**
  100480. * Adds all the element from the container to the scene
  100481. * @param container the container holding the elements
  100482. */
  100483. addFromContainer(container: AbstractScene): void;
  100484. /**
  100485. * Removes all the elements in the container from the scene
  100486. * @param container contains the elements to remove
  100487. */
  100488. removeFromContainer(container: AbstractScene): void;
  100489. /**
  100490. * Disposes the component and the associated ressources.
  100491. */
  100492. dispose(): void;
  100493. private _isReadyForMesh;
  100494. private _renderMainTexture;
  100495. private _setStencil;
  100496. private _setStencilBack;
  100497. private _draw;
  100498. private _drawCamera;
  100499. private _drawRenderingGroup;
  100500. }
  100501. }
  100502. declare module BABYLON {
  100503. /** @hidden */
  100504. export var glowMapMergePixelShader: {
  100505. name: string;
  100506. shader: string;
  100507. };
  100508. }
  100509. declare module BABYLON {
  100510. /** @hidden */
  100511. export var glowMapMergeVertexShader: {
  100512. name: string;
  100513. shader: string;
  100514. };
  100515. }
  100516. declare module BABYLON {
  100517. interface AbstractScene {
  100518. /**
  100519. * Return a the first highlight layer of the scene with a given name.
  100520. * @param name The name of the highlight layer to look for.
  100521. * @return The highlight layer if found otherwise null.
  100522. */
  100523. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100524. }
  100525. /**
  100526. * Glow layer options. This helps customizing the behaviour
  100527. * of the glow layer.
  100528. */
  100529. export interface IGlowLayerOptions {
  100530. /**
  100531. * Multiplication factor apply to the canvas size to compute the render target size
  100532. * used to generated the glowing objects (the smaller the faster).
  100533. */
  100534. mainTextureRatio: number;
  100535. /**
  100536. * Enforces a fixed size texture to ensure resize independant blur.
  100537. */
  100538. mainTextureFixedSize?: number;
  100539. /**
  100540. * How big is the kernel of the blur texture.
  100541. */
  100542. blurKernelSize: number;
  100543. /**
  100544. * The camera attached to the layer.
  100545. */
  100546. camera: Nullable<Camera>;
  100547. /**
  100548. * Enable MSAA by chosing the number of samples.
  100549. */
  100550. mainTextureSamples?: number;
  100551. /**
  100552. * The rendering group to draw the layer in.
  100553. */
  100554. renderingGroupId: number;
  100555. }
  100556. /**
  100557. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100558. *
  100559. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100560. * glowy meshes to your scene.
  100561. *
  100562. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100563. */
  100564. export class GlowLayer extends EffectLayer {
  100565. /**
  100566. * Effect Name of the layer.
  100567. */
  100568. static readonly EffectName: string;
  100569. /**
  100570. * The default blur kernel size used for the glow.
  100571. */
  100572. static DefaultBlurKernelSize: number;
  100573. /**
  100574. * The default texture size ratio used for the glow.
  100575. */
  100576. static DefaultTextureRatio: number;
  100577. /**
  100578. * Sets the kernel size of the blur.
  100579. */
  100580. /**
  100581. * Gets the kernel size of the blur.
  100582. */
  100583. blurKernelSize: number;
  100584. /**
  100585. * Sets the glow intensity.
  100586. */
  100587. /**
  100588. * Gets the glow intensity.
  100589. */
  100590. intensity: number;
  100591. private _options;
  100592. private _intensity;
  100593. private _horizontalBlurPostprocess1;
  100594. private _verticalBlurPostprocess1;
  100595. private _horizontalBlurPostprocess2;
  100596. private _verticalBlurPostprocess2;
  100597. private _blurTexture1;
  100598. private _blurTexture2;
  100599. private _postProcesses1;
  100600. private _postProcesses2;
  100601. private _includedOnlyMeshes;
  100602. private _excludedMeshes;
  100603. /**
  100604. * Callback used to let the user override the color selection on a per mesh basis
  100605. */
  100606. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100607. /**
  100608. * Callback used to let the user override the texture selection on a per mesh basis
  100609. */
  100610. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100611. /**
  100612. * Instantiates a new glow Layer and references it to the scene.
  100613. * @param name The name of the layer
  100614. * @param scene The scene to use the layer in
  100615. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100616. */
  100617. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100618. /**
  100619. * Get the effect name of the layer.
  100620. * @return The effect name
  100621. */
  100622. getEffectName(): string;
  100623. /**
  100624. * Create the merge effect. This is the shader use to blit the information back
  100625. * to the main canvas at the end of the scene rendering.
  100626. */
  100627. protected _createMergeEffect(): Effect;
  100628. /**
  100629. * Creates the render target textures and post processes used in the glow layer.
  100630. */
  100631. protected _createTextureAndPostProcesses(): void;
  100632. /**
  100633. * Checks for the readiness of the element composing the layer.
  100634. * @param subMesh the mesh to check for
  100635. * @param useInstances specify wether or not to use instances to render the mesh
  100636. * @param emissiveTexture the associated emissive texture used to generate the glow
  100637. * @return true if ready otherwise, false
  100638. */
  100639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100640. /**
  100641. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100642. */
  100643. needStencil(): boolean;
  100644. /**
  100645. * Returns true if the mesh can be rendered, otherwise false.
  100646. * @param mesh The mesh to render
  100647. * @param material The material used on the mesh
  100648. * @returns true if it can be rendered otherwise false
  100649. */
  100650. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100651. /**
  100652. * Implementation specific of rendering the generating effect on the main canvas.
  100653. * @param effect The effect used to render through
  100654. */
  100655. protected _internalRender(effect: Effect): void;
  100656. /**
  100657. * Sets the required values for both the emissive texture and and the main color.
  100658. */
  100659. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100660. /**
  100661. * Returns true if the mesh should render, otherwise false.
  100662. * @param mesh The mesh to render
  100663. * @returns true if it should render otherwise false
  100664. */
  100665. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100666. /**
  100667. * Adds specific effects defines.
  100668. * @param defines The defines to add specifics to.
  100669. */
  100670. protected _addCustomEffectDefines(defines: string[]): void;
  100671. /**
  100672. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100673. * @param mesh The mesh to exclude from the glow layer
  100674. */
  100675. addExcludedMesh(mesh: Mesh): void;
  100676. /**
  100677. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100678. * @param mesh The mesh to remove
  100679. */
  100680. removeExcludedMesh(mesh: Mesh): void;
  100681. /**
  100682. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100683. * @param mesh The mesh to include in the glow layer
  100684. */
  100685. addIncludedOnlyMesh(mesh: Mesh): void;
  100686. /**
  100687. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100688. * @param mesh The mesh to remove
  100689. */
  100690. removeIncludedOnlyMesh(mesh: Mesh): void;
  100691. /**
  100692. * Determine if a given mesh will be used in the glow layer
  100693. * @param mesh The mesh to test
  100694. * @returns true if the mesh will be highlighted by the current glow layer
  100695. */
  100696. hasMesh(mesh: AbstractMesh): boolean;
  100697. /**
  100698. * Free any resources and references associated to a mesh.
  100699. * Internal use
  100700. * @param mesh The mesh to free.
  100701. * @hidden
  100702. */
  100703. _disposeMesh(mesh: Mesh): void;
  100704. /**
  100705. * Gets the class name of the effect layer
  100706. * @returns the string with the class name of the effect layer
  100707. */
  100708. getClassName(): string;
  100709. /**
  100710. * Serializes this glow layer
  100711. * @returns a serialized glow layer object
  100712. */
  100713. serialize(): any;
  100714. /**
  100715. * Creates a Glow Layer from parsed glow layer data
  100716. * @param parsedGlowLayer defines glow layer data
  100717. * @param scene defines the current scene
  100718. * @param rootUrl defines the root URL containing the glow layer information
  100719. * @returns a parsed Glow Layer
  100720. */
  100721. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100722. }
  100723. }
  100724. declare module BABYLON {
  100725. /** @hidden */
  100726. export var glowBlurPostProcessPixelShader: {
  100727. name: string;
  100728. shader: string;
  100729. };
  100730. }
  100731. declare module BABYLON {
  100732. interface AbstractScene {
  100733. /**
  100734. * Return a the first highlight layer of the scene with a given name.
  100735. * @param name The name of the highlight layer to look for.
  100736. * @return The highlight layer if found otherwise null.
  100737. */
  100738. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100739. }
  100740. /**
  100741. * Highlight layer options. This helps customizing the behaviour
  100742. * of the highlight layer.
  100743. */
  100744. export interface IHighlightLayerOptions {
  100745. /**
  100746. * Multiplication factor apply to the canvas size to compute the render target size
  100747. * used to generated the glowing objects (the smaller the faster).
  100748. */
  100749. mainTextureRatio: number;
  100750. /**
  100751. * Enforces a fixed size texture to ensure resize independant blur.
  100752. */
  100753. mainTextureFixedSize?: number;
  100754. /**
  100755. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100756. * of the picture to blur (the smaller the faster).
  100757. */
  100758. blurTextureSizeRatio: number;
  100759. /**
  100760. * How big in texel of the blur texture is the vertical blur.
  100761. */
  100762. blurVerticalSize: number;
  100763. /**
  100764. * How big in texel of the blur texture is the horizontal blur.
  100765. */
  100766. blurHorizontalSize: number;
  100767. /**
  100768. * Alpha blending mode used to apply the blur. Default is combine.
  100769. */
  100770. alphaBlendingMode: number;
  100771. /**
  100772. * The camera attached to the layer.
  100773. */
  100774. camera: Nullable<Camera>;
  100775. /**
  100776. * Should we display highlight as a solid stroke?
  100777. */
  100778. isStroke?: boolean;
  100779. /**
  100780. * The rendering group to draw the layer in.
  100781. */
  100782. renderingGroupId: number;
  100783. }
  100784. /**
  100785. * The highlight layer Helps adding a glow effect around a mesh.
  100786. *
  100787. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100788. * glowy meshes to your scene.
  100789. *
  100790. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100791. */
  100792. export class HighlightLayer extends EffectLayer {
  100793. name: string;
  100794. /**
  100795. * Effect Name of the highlight layer.
  100796. */
  100797. static readonly EffectName: string;
  100798. /**
  100799. * The neutral color used during the preparation of the glow effect.
  100800. * This is black by default as the blend operation is a blend operation.
  100801. */
  100802. static NeutralColor: Color4;
  100803. /**
  100804. * Stencil value used for glowing meshes.
  100805. */
  100806. static GlowingMeshStencilReference: number;
  100807. /**
  100808. * Stencil value used for the other meshes in the scene.
  100809. */
  100810. static NormalMeshStencilReference: number;
  100811. /**
  100812. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100813. */
  100814. innerGlow: boolean;
  100815. /**
  100816. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100817. */
  100818. outerGlow: boolean;
  100819. /**
  100820. * Specifies the horizontal size of the blur.
  100821. */
  100822. /**
  100823. * Gets the horizontal size of the blur.
  100824. */
  100825. blurHorizontalSize: number;
  100826. /**
  100827. * Specifies the vertical size of the blur.
  100828. */
  100829. /**
  100830. * Gets the vertical size of the blur.
  100831. */
  100832. blurVerticalSize: number;
  100833. /**
  100834. * An event triggered when the highlight layer is being blurred.
  100835. */
  100836. onBeforeBlurObservable: Observable<HighlightLayer>;
  100837. /**
  100838. * An event triggered when the highlight layer has been blurred.
  100839. */
  100840. onAfterBlurObservable: Observable<HighlightLayer>;
  100841. private _instanceGlowingMeshStencilReference;
  100842. private _options;
  100843. private _downSamplePostprocess;
  100844. private _horizontalBlurPostprocess;
  100845. private _verticalBlurPostprocess;
  100846. private _blurTexture;
  100847. private _meshes;
  100848. private _excludedMeshes;
  100849. /**
  100850. * Instantiates a new highlight Layer and references it to the scene..
  100851. * @param name The name of the layer
  100852. * @param scene The scene to use the layer in
  100853. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100854. */
  100855. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100856. /**
  100857. * Get the effect name of the layer.
  100858. * @return The effect name
  100859. */
  100860. getEffectName(): string;
  100861. /**
  100862. * Create the merge effect. This is the shader use to blit the information back
  100863. * to the main canvas at the end of the scene rendering.
  100864. */
  100865. protected _createMergeEffect(): Effect;
  100866. /**
  100867. * Creates the render target textures and post processes used in the highlight layer.
  100868. */
  100869. protected _createTextureAndPostProcesses(): void;
  100870. /**
  100871. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100872. */
  100873. needStencil(): boolean;
  100874. /**
  100875. * Checks for the readiness of the element composing the layer.
  100876. * @param subMesh the mesh to check for
  100877. * @param useInstances specify wether or not to use instances to render the mesh
  100878. * @param emissiveTexture the associated emissive texture used to generate the glow
  100879. * @return true if ready otherwise, false
  100880. */
  100881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100882. /**
  100883. * Implementation specific of rendering the generating effect on the main canvas.
  100884. * @param effect The effect used to render through
  100885. */
  100886. protected _internalRender(effect: Effect): void;
  100887. /**
  100888. * Returns true if the layer contains information to display, otherwise false.
  100889. */
  100890. shouldRender(): boolean;
  100891. /**
  100892. * Returns true if the mesh should render, otherwise false.
  100893. * @param mesh The mesh to render
  100894. * @returns true if it should render otherwise false
  100895. */
  100896. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100897. /**
  100898. * Sets the required values for both the emissive texture and and the main color.
  100899. */
  100900. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100901. /**
  100902. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100903. * @param mesh The mesh to exclude from the highlight layer
  100904. */
  100905. addExcludedMesh(mesh: Mesh): void;
  100906. /**
  100907. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100908. * @param mesh The mesh to highlight
  100909. */
  100910. removeExcludedMesh(mesh: Mesh): void;
  100911. /**
  100912. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100913. * @param mesh mesh to test
  100914. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100915. */
  100916. hasMesh(mesh: AbstractMesh): boolean;
  100917. /**
  100918. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100919. * @param mesh The mesh to highlight
  100920. * @param color The color of the highlight
  100921. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100922. */
  100923. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100924. /**
  100925. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100926. * @param mesh The mesh to highlight
  100927. */
  100928. removeMesh(mesh: Mesh): void;
  100929. /**
  100930. * Force the stencil to the normal expected value for none glowing parts
  100931. */
  100932. private _defaultStencilReference;
  100933. /**
  100934. * Free any resources and references associated to a mesh.
  100935. * Internal use
  100936. * @param mesh The mesh to free.
  100937. * @hidden
  100938. */
  100939. _disposeMesh(mesh: Mesh): void;
  100940. /**
  100941. * Dispose the highlight layer and free resources.
  100942. */
  100943. dispose(): void;
  100944. /**
  100945. * Gets the class name of the effect layer
  100946. * @returns the string with the class name of the effect layer
  100947. */
  100948. getClassName(): string;
  100949. /**
  100950. * Serializes this Highlight layer
  100951. * @returns a serialized Highlight layer object
  100952. */
  100953. serialize(): any;
  100954. /**
  100955. * Creates a Highlight layer from parsed Highlight layer data
  100956. * @param parsedHightlightLayer defines the Highlight layer data
  100957. * @param scene defines the current scene
  100958. * @param rootUrl defines the root URL containing the Highlight layer information
  100959. * @returns a parsed Highlight layer
  100960. */
  100961. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100962. }
  100963. }
  100964. declare module BABYLON {
  100965. /** @hidden */
  100966. export var lensFlarePixelShader: {
  100967. name: string;
  100968. shader: string;
  100969. };
  100970. }
  100971. declare module BABYLON {
  100972. /** @hidden */
  100973. export var lensFlareVertexShader: {
  100974. name: string;
  100975. shader: string;
  100976. };
  100977. }
  100978. declare module BABYLON {
  100979. /**
  100980. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100981. * It is usually composed of several `lensFlare`.
  100982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100983. */
  100984. export class LensFlareSystem {
  100985. /**
  100986. * Define the name of the lens flare system
  100987. */
  100988. name: string;
  100989. /**
  100990. * List of lens flares used in this system.
  100991. */
  100992. lensFlares: LensFlare[];
  100993. /**
  100994. * Define a limit from the border the lens flare can be visible.
  100995. */
  100996. borderLimit: number;
  100997. /**
  100998. * Define a viewport border we do not want to see the lens flare in.
  100999. */
  101000. viewportBorder: number;
  101001. /**
  101002. * Define a predicate which could limit the list of meshes able to occlude the effect.
  101003. */
  101004. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101005. /**
  101006. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  101007. */
  101008. layerMask: number;
  101009. /**
  101010. * Define the id of the lens flare system in the scene.
  101011. * (equal to name by default)
  101012. */
  101013. id: string;
  101014. private _scene;
  101015. private _emitter;
  101016. private _vertexBuffers;
  101017. private _indexBuffer;
  101018. private _effect;
  101019. private _positionX;
  101020. private _positionY;
  101021. private _isEnabled;
  101022. /** @hidden */
  101023. static _SceneComponentInitialization: (scene: Scene) => void;
  101024. /**
  101025. * Instantiates a lens flare system.
  101026. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101027. * It is usually composed of several `lensFlare`.
  101028. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101029. * @param name Define the name of the lens flare system in the scene
  101030. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  101031. * @param scene Define the scene the lens flare system belongs to
  101032. */
  101033. constructor(
  101034. /**
  101035. * Define the name of the lens flare system
  101036. */
  101037. name: string, emitter: any, scene: Scene);
  101038. /**
  101039. * Define if the lens flare system is enabled.
  101040. */
  101041. isEnabled: boolean;
  101042. /**
  101043. * Get the scene the effects belongs to.
  101044. * @returns the scene holding the lens flare system
  101045. */
  101046. getScene(): Scene;
  101047. /**
  101048. * Get the emitter of the lens flare system.
  101049. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101050. * @returns the emitter of the lens flare system
  101051. */
  101052. getEmitter(): any;
  101053. /**
  101054. * Set the emitter of the lens flare system.
  101055. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101056. * @param newEmitter Define the new emitter of the system
  101057. */
  101058. setEmitter(newEmitter: any): void;
  101059. /**
  101060. * Get the lens flare system emitter position.
  101061. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  101062. * @returns the position
  101063. */
  101064. getEmitterPosition(): Vector3;
  101065. /**
  101066. * @hidden
  101067. */
  101068. computeEffectivePosition(globalViewport: Viewport): boolean;
  101069. /** @hidden */
  101070. _isVisible(): boolean;
  101071. /**
  101072. * @hidden
  101073. */
  101074. render(): boolean;
  101075. /**
  101076. * Dispose and release the lens flare with its associated resources.
  101077. */
  101078. dispose(): void;
  101079. /**
  101080. * Parse a lens flare system from a JSON repressentation
  101081. * @param parsedLensFlareSystem Define the JSON to parse
  101082. * @param scene Define the scene the parsed system should be instantiated in
  101083. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  101084. * @returns the parsed system
  101085. */
  101086. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  101087. /**
  101088. * Serialize the current Lens Flare System into a JSON representation.
  101089. * @returns the serialized JSON
  101090. */
  101091. serialize(): any;
  101092. }
  101093. }
  101094. declare module BABYLON {
  101095. /**
  101096. * This represents one of the lens effect in a `lensFlareSystem`.
  101097. * It controls one of the indiviual texture used in the effect.
  101098. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101099. */
  101100. export class LensFlare {
  101101. /**
  101102. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101103. */
  101104. size: number;
  101105. /**
  101106. * 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.
  101107. */
  101108. position: number;
  101109. /**
  101110. * Define the lens color.
  101111. */
  101112. color: Color3;
  101113. /**
  101114. * Define the lens texture.
  101115. */
  101116. texture: Nullable<Texture>;
  101117. /**
  101118. * Define the alpha mode to render this particular lens.
  101119. */
  101120. alphaMode: number;
  101121. private _system;
  101122. /**
  101123. * Creates a new Lens Flare.
  101124. * This represents one of the lens effect in a `lensFlareSystem`.
  101125. * It controls one of the indiviual texture used in the effect.
  101126. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101127. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  101128. * @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.
  101129. * @param color Define the lens color
  101130. * @param imgUrl Define the lens texture url
  101131. * @param system Define the `lensFlareSystem` this flare is part of
  101132. * @returns The newly created Lens Flare
  101133. */
  101134. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  101135. /**
  101136. * Instantiates a new Lens Flare.
  101137. * This represents one of the lens effect in a `lensFlareSystem`.
  101138. * It controls one of the indiviual texture used in the effect.
  101139. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101140. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  101141. * @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.
  101142. * @param color Define the lens color
  101143. * @param imgUrl Define the lens texture url
  101144. * @param system Define the `lensFlareSystem` this flare is part of
  101145. */
  101146. constructor(
  101147. /**
  101148. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101149. */
  101150. size: number,
  101151. /**
  101152. * 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.
  101153. */
  101154. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101155. /**
  101156. * Dispose and release the lens flare with its associated resources.
  101157. */
  101158. dispose(): void;
  101159. }
  101160. }
  101161. declare module BABYLON {
  101162. interface AbstractScene {
  101163. /**
  101164. * The list of lens flare system added to the scene
  101165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101166. */
  101167. lensFlareSystems: Array<LensFlareSystem>;
  101168. /**
  101169. * Removes the given lens flare system from this scene.
  101170. * @param toRemove The lens flare system to remove
  101171. * @returns The index of the removed lens flare system
  101172. */
  101173. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101174. /**
  101175. * Adds the given lens flare system to this scene
  101176. * @param newLensFlareSystem The lens flare system to add
  101177. */
  101178. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101179. /**
  101180. * Gets a lens flare system using its name
  101181. * @param name defines the name to look for
  101182. * @returns the lens flare system or null if not found
  101183. */
  101184. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101185. /**
  101186. * Gets a lens flare system using its id
  101187. * @param id defines the id to look for
  101188. * @returns the lens flare system or null if not found
  101189. */
  101190. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101191. }
  101192. /**
  101193. * Defines the lens flare scene component responsible to manage any lens flares
  101194. * in a given scene.
  101195. */
  101196. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101197. /**
  101198. * The component name helpfull to identify the component in the list of scene components.
  101199. */
  101200. readonly name: string;
  101201. /**
  101202. * The scene the component belongs to.
  101203. */
  101204. scene: Scene;
  101205. /**
  101206. * Creates a new instance of the component for the given scene
  101207. * @param scene Defines the scene to register the component in
  101208. */
  101209. constructor(scene: Scene);
  101210. /**
  101211. * Registers the component in a given scene
  101212. */
  101213. register(): void;
  101214. /**
  101215. * Rebuilds the elements related to this component in case of
  101216. * context lost for instance.
  101217. */
  101218. rebuild(): void;
  101219. /**
  101220. * Adds all the element from the container to the scene
  101221. * @param container the container holding the elements
  101222. */
  101223. addFromContainer(container: AbstractScene): void;
  101224. /**
  101225. * Removes all the elements in the container from the scene
  101226. * @param container contains the elements to remove
  101227. */
  101228. removeFromContainer(container: AbstractScene): void;
  101229. /**
  101230. * Serializes the component data to the specified json object
  101231. * @param serializationObject The object to serialize to
  101232. */
  101233. serialize(serializationObject: any): void;
  101234. /**
  101235. * Disposes the component and the associated ressources.
  101236. */
  101237. dispose(): void;
  101238. private _draw;
  101239. }
  101240. }
  101241. declare module BABYLON {
  101242. /**
  101243. * Defines the shadow generator component responsible to manage any shadow generators
  101244. * in a given scene.
  101245. */
  101246. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101247. /**
  101248. * The component name helpfull to identify the component in the list of scene components.
  101249. */
  101250. readonly name: string;
  101251. /**
  101252. * The scene the component belongs to.
  101253. */
  101254. scene: Scene;
  101255. /**
  101256. * Creates a new instance of the component for the given scene
  101257. * @param scene Defines the scene to register the component in
  101258. */
  101259. constructor(scene: Scene);
  101260. /**
  101261. * Registers the component in a given scene
  101262. */
  101263. register(): void;
  101264. /**
  101265. * Rebuilds the elements related to this component in case of
  101266. * context lost for instance.
  101267. */
  101268. rebuild(): void;
  101269. /**
  101270. * Serializes the component data to the specified json object
  101271. * @param serializationObject The object to serialize to
  101272. */
  101273. serialize(serializationObject: any): void;
  101274. /**
  101275. * Adds all the element from the container to the scene
  101276. * @param container the container holding the elements
  101277. */
  101278. addFromContainer(container: AbstractScene): void;
  101279. /**
  101280. * Removes all the elements in the container from the scene
  101281. * @param container contains the elements to remove
  101282. */
  101283. removeFromContainer(container: AbstractScene): void;
  101284. /**
  101285. * Rebuilds the elements related to this component in case of
  101286. * context lost for instance.
  101287. */
  101288. dispose(): void;
  101289. private _gatherRenderTargets;
  101290. }
  101291. }
  101292. declare module BABYLON {
  101293. /**
  101294. * A directional light is defined by a direction (what a surprise!).
  101295. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101296. * 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.
  101297. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101298. */
  101299. export class DirectionalLight extends ShadowLight {
  101300. private _shadowFrustumSize;
  101301. /**
  101302. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101303. */
  101304. /**
  101305. * Specifies a fix frustum size for the shadow generation.
  101306. */
  101307. shadowFrustumSize: number;
  101308. private _shadowOrthoScale;
  101309. /**
  101310. * Gets the shadow projection scale against the optimal computed one.
  101311. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101312. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101313. */
  101314. /**
  101315. * Sets the shadow projection scale against the optimal computed one.
  101316. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101317. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101318. */
  101319. shadowOrthoScale: number;
  101320. /**
  101321. * Automatically compute the projection matrix to best fit (including all the casters)
  101322. * on each frame.
  101323. */
  101324. autoUpdateExtends: boolean;
  101325. private _orthoLeft;
  101326. private _orthoRight;
  101327. private _orthoTop;
  101328. private _orthoBottom;
  101329. /**
  101330. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101331. * The directional light is emitted from everywhere in the given direction.
  101332. * It can cast shadows.
  101333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101334. * @param name The friendly name of the light
  101335. * @param direction The direction of the light
  101336. * @param scene The scene the light belongs to
  101337. */
  101338. constructor(name: string, direction: Vector3, scene: Scene);
  101339. /**
  101340. * Returns the string "DirectionalLight".
  101341. * @return The class name
  101342. */
  101343. getClassName(): string;
  101344. /**
  101345. * Returns the integer 1.
  101346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101347. */
  101348. getTypeID(): number;
  101349. /**
  101350. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101351. * Returns the DirectionalLight Shadow projection matrix.
  101352. */
  101353. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101354. /**
  101355. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101356. * Returns the DirectionalLight Shadow projection matrix.
  101357. */
  101358. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101359. /**
  101360. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101361. * Returns the DirectionalLight Shadow projection matrix.
  101362. */
  101363. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101364. protected _buildUniformLayout(): void;
  101365. /**
  101366. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101367. * @param effect The effect to update
  101368. * @param lightIndex The index of the light in the effect to update
  101369. * @returns The directional light
  101370. */
  101371. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101372. /**
  101373. * Gets the minZ used for shadow according to both the scene and the light.
  101374. *
  101375. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101376. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101377. * @param activeCamera The camera we are returning the min for
  101378. * @returns the depth min z
  101379. */
  101380. getDepthMinZ(activeCamera: Camera): number;
  101381. /**
  101382. * Gets the maxZ used for shadow according to both the scene and the light.
  101383. *
  101384. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101385. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101386. * @param activeCamera The camera we are returning the max for
  101387. * @returns the depth max z
  101388. */
  101389. getDepthMaxZ(activeCamera: Camera): number;
  101390. /**
  101391. * Prepares the list of defines specific to the light type.
  101392. * @param defines the list of defines
  101393. * @param lightIndex defines the index of the light for the effect
  101394. */
  101395. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * A point light is a light defined by an unique point in world space.
  101401. * The light is emitted in every direction from this point.
  101402. * A good example of a point light is a standard light bulb.
  101403. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101404. */
  101405. export class PointLight extends ShadowLight {
  101406. private _shadowAngle;
  101407. /**
  101408. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101409. * This specifies what angle the shadow will use to be created.
  101410. *
  101411. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101412. */
  101413. /**
  101414. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101415. * This specifies what angle the shadow will use to be created.
  101416. *
  101417. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101418. */
  101419. shadowAngle: number;
  101420. /**
  101421. * Gets the direction if it has been set.
  101422. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101423. */
  101424. /**
  101425. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101426. */
  101427. direction: Vector3;
  101428. /**
  101429. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101430. * A PointLight emits the light in every direction.
  101431. * It can cast shadows.
  101432. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101433. * ```javascript
  101434. * var pointLight = new PointLight("pl", camera.position, scene);
  101435. * ```
  101436. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101437. * @param name The light friendly name
  101438. * @param position The position of the point light in the scene
  101439. * @param scene The scene the lights belongs to
  101440. */
  101441. constructor(name: string, position: Vector3, scene: Scene);
  101442. /**
  101443. * Returns the string "PointLight"
  101444. * @returns the class name
  101445. */
  101446. getClassName(): string;
  101447. /**
  101448. * Returns the integer 0.
  101449. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101450. */
  101451. getTypeID(): number;
  101452. /**
  101453. * Specifies wether or not the shadowmap should be a cube texture.
  101454. * @returns true if the shadowmap needs to be a cube texture.
  101455. */
  101456. needCube(): boolean;
  101457. /**
  101458. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101459. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101460. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101461. */
  101462. getShadowDirection(faceIndex?: number): Vector3;
  101463. /**
  101464. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101465. * - fov = PI / 2
  101466. * - aspect ratio : 1.0
  101467. * - z-near and far equal to the active camera minZ and maxZ.
  101468. * Returns the PointLight.
  101469. */
  101470. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101471. protected _buildUniformLayout(): void;
  101472. /**
  101473. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101474. * @param effect The effect to update
  101475. * @param lightIndex The index of the light in the effect to update
  101476. * @returns The point light
  101477. */
  101478. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101479. /**
  101480. * Prepares the list of defines specific to the light type.
  101481. * @param defines the list of defines
  101482. * @param lightIndex defines the index of the light for the effect
  101483. */
  101484. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101485. }
  101486. }
  101487. declare module BABYLON {
  101488. /**
  101489. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101490. * These values define a cone of light starting from the position, emitting toward the direction.
  101491. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101492. * and the exponent defines the speed of the decay of the light with distance (reach).
  101493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101494. */
  101495. export class SpotLight extends ShadowLight {
  101496. private _angle;
  101497. private _innerAngle;
  101498. private _cosHalfAngle;
  101499. private _lightAngleScale;
  101500. private _lightAngleOffset;
  101501. /**
  101502. * Gets the cone angle of the spot light in Radians.
  101503. */
  101504. /**
  101505. * Sets the cone angle of the spot light in Radians.
  101506. */
  101507. angle: number;
  101508. /**
  101509. * Only used in gltf falloff mode, this defines the angle where
  101510. * the directional falloff will start before cutting at angle which could be seen
  101511. * as outer angle.
  101512. */
  101513. /**
  101514. * Only used in gltf falloff mode, this defines the angle where
  101515. * the directional falloff will start before cutting at angle which could be seen
  101516. * as outer angle.
  101517. */
  101518. innerAngle: number;
  101519. private _shadowAngleScale;
  101520. /**
  101521. * Allows scaling the angle of the light for shadow generation only.
  101522. */
  101523. /**
  101524. * Allows scaling the angle of the light for shadow generation only.
  101525. */
  101526. shadowAngleScale: number;
  101527. /**
  101528. * The light decay speed with the distance from the emission spot.
  101529. */
  101530. exponent: number;
  101531. private _projectionTextureMatrix;
  101532. /**
  101533. * Allows reading the projecton texture
  101534. */
  101535. readonly projectionTextureMatrix: Matrix;
  101536. protected _projectionTextureLightNear: number;
  101537. /**
  101538. * Gets the near clip of the Spotlight for texture projection.
  101539. */
  101540. /**
  101541. * Sets the near clip of the Spotlight for texture projection.
  101542. */
  101543. projectionTextureLightNear: number;
  101544. protected _projectionTextureLightFar: number;
  101545. /**
  101546. * Gets the far clip of the Spotlight for texture projection.
  101547. */
  101548. /**
  101549. * Sets the far clip of the Spotlight for texture projection.
  101550. */
  101551. projectionTextureLightFar: number;
  101552. protected _projectionTextureUpDirection: Vector3;
  101553. /**
  101554. * Gets the Up vector of the Spotlight for texture projection.
  101555. */
  101556. /**
  101557. * Sets the Up vector of the Spotlight for texture projection.
  101558. */
  101559. projectionTextureUpDirection: Vector3;
  101560. private _projectionTexture;
  101561. /**
  101562. * Gets the projection texture of the light.
  101563. */
  101564. /**
  101565. * Sets the projection texture of the light.
  101566. */
  101567. projectionTexture: Nullable<BaseTexture>;
  101568. private _projectionTextureViewLightDirty;
  101569. private _projectionTextureProjectionLightDirty;
  101570. private _projectionTextureDirty;
  101571. private _projectionTextureViewTargetVector;
  101572. private _projectionTextureViewLightMatrix;
  101573. private _projectionTextureProjectionLightMatrix;
  101574. private _projectionTextureScalingMatrix;
  101575. /**
  101576. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101577. * It can cast shadows.
  101578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101579. * @param name The light friendly name
  101580. * @param position The position of the spot light in the scene
  101581. * @param direction The direction of the light in the scene
  101582. * @param angle The cone angle of the light in Radians
  101583. * @param exponent The light decay speed with the distance from the emission spot
  101584. * @param scene The scene the lights belongs to
  101585. */
  101586. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101587. /**
  101588. * Returns the string "SpotLight".
  101589. * @returns the class name
  101590. */
  101591. getClassName(): string;
  101592. /**
  101593. * Returns the integer 2.
  101594. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101595. */
  101596. getTypeID(): number;
  101597. /**
  101598. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101599. */
  101600. protected _setDirection(value: Vector3): void;
  101601. /**
  101602. * Overrides the position setter to recompute the projection texture view light Matrix.
  101603. */
  101604. protected _setPosition(value: Vector3): void;
  101605. /**
  101606. * 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.
  101607. * Returns the SpotLight.
  101608. */
  101609. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101610. protected _computeProjectionTextureViewLightMatrix(): void;
  101611. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101612. /**
  101613. * Main function for light texture projection matrix computing.
  101614. */
  101615. protected _computeProjectionTextureMatrix(): void;
  101616. protected _buildUniformLayout(): void;
  101617. private _computeAngleValues;
  101618. /**
  101619. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101620. * @param effect The effect to update
  101621. * @param lightIndex The index of the light in the effect to update
  101622. * @returns The spot light
  101623. */
  101624. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101625. /**
  101626. * Disposes the light and the associated resources.
  101627. */
  101628. dispose(): void;
  101629. /**
  101630. * Prepares the list of defines specific to the light type.
  101631. * @param defines the list of defines
  101632. * @param lightIndex defines the index of the light for the effect
  101633. */
  101634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101635. }
  101636. }
  101637. declare module BABYLON {
  101638. /**
  101639. * Header information of HDR texture files.
  101640. */
  101641. export interface HDRInfo {
  101642. /**
  101643. * The height of the texture in pixels.
  101644. */
  101645. height: number;
  101646. /**
  101647. * The width of the texture in pixels.
  101648. */
  101649. width: number;
  101650. /**
  101651. * The index of the beginning of the data in the binary file.
  101652. */
  101653. dataPosition: number;
  101654. }
  101655. /**
  101656. * This groups tools to convert HDR texture to native colors array.
  101657. */
  101658. export class HDRTools {
  101659. private static Ldexp;
  101660. private static Rgbe2float;
  101661. private static readStringLine;
  101662. /**
  101663. * Reads header information from an RGBE texture stored in a native array.
  101664. * More information on this format are available here:
  101665. * https://en.wikipedia.org/wiki/RGBE_image_format
  101666. *
  101667. * @param uint8array The binary file stored in native array.
  101668. * @return The header information.
  101669. */
  101670. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101671. /**
  101672. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101673. * This RGBE texture needs to store the information as a panorama.
  101674. *
  101675. * More information on this format are available here:
  101676. * https://en.wikipedia.org/wiki/RGBE_image_format
  101677. *
  101678. * @param buffer The binary file stored in an array buffer.
  101679. * @param size The expected size of the extracted cubemap.
  101680. * @return The Cube Map information.
  101681. */
  101682. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101683. /**
  101684. * Returns the pixels data extracted from an RGBE texture.
  101685. * This pixels will be stored left to right up to down in the R G B order in one array.
  101686. *
  101687. * More information on this format are available here:
  101688. * https://en.wikipedia.org/wiki/RGBE_image_format
  101689. *
  101690. * @param uint8array The binary file stored in an array buffer.
  101691. * @param hdrInfo The header information of the file.
  101692. * @return The pixels data in RGB right to left up to down order.
  101693. */
  101694. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101695. private static RGBE_ReadPixels_RLE;
  101696. }
  101697. }
  101698. declare module BABYLON {
  101699. /**
  101700. * This represents a texture coming from an HDR input.
  101701. *
  101702. * The only supported format is currently panorama picture stored in RGBE format.
  101703. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101704. */
  101705. export class HDRCubeTexture extends BaseTexture {
  101706. private static _facesMapping;
  101707. private _generateHarmonics;
  101708. private _noMipmap;
  101709. private _textureMatrix;
  101710. private _size;
  101711. private _onLoad;
  101712. private _onError;
  101713. /**
  101714. * The texture URL.
  101715. */
  101716. url: string;
  101717. /**
  101718. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101719. */
  101720. coordinatesMode: number;
  101721. protected _isBlocking: boolean;
  101722. /**
  101723. * Sets wether or not the texture is blocking during loading.
  101724. */
  101725. /**
  101726. * Gets wether or not the texture is blocking during loading.
  101727. */
  101728. isBlocking: boolean;
  101729. protected _rotationY: number;
  101730. /**
  101731. * Sets texture matrix rotation angle around Y axis in radians.
  101732. */
  101733. /**
  101734. * Gets texture matrix rotation angle around Y axis radians.
  101735. */
  101736. rotationY: number;
  101737. /**
  101738. * Gets or sets the center of the bounding box associated with the cube texture
  101739. * It must define where the camera used to render the texture was set
  101740. */
  101741. boundingBoxPosition: Vector3;
  101742. private _boundingBoxSize;
  101743. /**
  101744. * Gets or sets the size of the bounding box associated with the cube texture
  101745. * When defined, the cubemap will switch to local mode
  101746. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101747. * @example https://www.babylonjs-playground.com/#RNASML
  101748. */
  101749. boundingBoxSize: Vector3;
  101750. /**
  101751. * Instantiates an HDRTexture from the following parameters.
  101752. *
  101753. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101754. * @param scene The scene the texture will be used in
  101755. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101756. * @param noMipmap Forces to not generate the mipmap if true
  101757. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101758. * @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)
  101759. * @param reserved Reserved flag for internal use.
  101760. */
  101761. 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>);
  101762. /**
  101763. * Get the current class name of the texture useful for serialization or dynamic coding.
  101764. * @returns "HDRCubeTexture"
  101765. */
  101766. getClassName(): string;
  101767. /**
  101768. * Occurs when the file is raw .hdr file.
  101769. */
  101770. private loadTexture;
  101771. clone(): HDRCubeTexture;
  101772. delayLoad(): void;
  101773. /**
  101774. * Get the texture reflection matrix used to rotate/transform the reflection.
  101775. * @returns the reflection matrix
  101776. */
  101777. getReflectionTextureMatrix(): Matrix;
  101778. /**
  101779. * Set the texture reflection matrix used to rotate/transform the reflection.
  101780. * @param value Define the reflection matrix to set
  101781. */
  101782. setReflectionTextureMatrix(value: Matrix): void;
  101783. /**
  101784. * Parses a JSON representation of an HDR Texture in order to create the texture
  101785. * @param parsedTexture Define the JSON representation
  101786. * @param scene Define the scene the texture should be created in
  101787. * @param rootUrl Define the root url in case we need to load relative dependencies
  101788. * @returns the newly created texture after parsing
  101789. */
  101790. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101791. serialize(): any;
  101792. }
  101793. }
  101794. declare module BABYLON {
  101795. /**
  101796. * Class used to control physics engine
  101797. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101798. */
  101799. export class PhysicsEngine implements IPhysicsEngine {
  101800. private _physicsPlugin;
  101801. /**
  101802. * Global value used to control the smallest number supported by the simulation
  101803. */
  101804. static Epsilon: number;
  101805. private _impostors;
  101806. private _joints;
  101807. /**
  101808. * Gets the gravity vector used by the simulation
  101809. */
  101810. gravity: Vector3;
  101811. /**
  101812. * Factory used to create the default physics plugin.
  101813. * @returns The default physics plugin
  101814. */
  101815. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101816. /**
  101817. * Creates a new Physics Engine
  101818. * @param gravity defines the gravity vector used by the simulation
  101819. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101820. */
  101821. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101822. /**
  101823. * Sets the gravity vector used by the simulation
  101824. * @param gravity defines the gravity vector to use
  101825. */
  101826. setGravity(gravity: Vector3): void;
  101827. /**
  101828. * Set the time step of the physics engine.
  101829. * Default is 1/60.
  101830. * To slow it down, enter 1/600 for example.
  101831. * To speed it up, 1/30
  101832. * @param newTimeStep defines the new timestep to apply to this world.
  101833. */
  101834. setTimeStep(newTimeStep?: number): void;
  101835. /**
  101836. * Get the time step of the physics engine.
  101837. * @returns the current time step
  101838. */
  101839. getTimeStep(): number;
  101840. /**
  101841. * Release all resources
  101842. */
  101843. dispose(): void;
  101844. /**
  101845. * Gets the name of the current physics plugin
  101846. * @returns the name of the plugin
  101847. */
  101848. getPhysicsPluginName(): string;
  101849. /**
  101850. * Adding a new impostor for the impostor tracking.
  101851. * This will be done by the impostor itself.
  101852. * @param impostor the impostor to add
  101853. */
  101854. addImpostor(impostor: PhysicsImpostor): void;
  101855. /**
  101856. * Remove an impostor from the engine.
  101857. * This impostor and its mesh will not longer be updated by the physics engine.
  101858. * @param impostor the impostor to remove
  101859. */
  101860. removeImpostor(impostor: PhysicsImpostor): void;
  101861. /**
  101862. * Add a joint to the physics engine
  101863. * @param mainImpostor defines the main impostor to which the joint is added.
  101864. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101865. * @param joint defines the joint that will connect both impostors.
  101866. */
  101867. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101868. /**
  101869. * Removes a joint from the simulation
  101870. * @param mainImpostor defines the impostor used with the joint
  101871. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101872. * @param joint defines the joint to remove
  101873. */
  101874. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101875. /**
  101876. * Called by the scene. No need to call it.
  101877. * @param delta defines the timespam between frames
  101878. */
  101879. _step(delta: number): void;
  101880. /**
  101881. * Gets the current plugin used to run the simulation
  101882. * @returns current plugin
  101883. */
  101884. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101885. /**
  101886. * Gets the list of physic impostors
  101887. * @returns an array of PhysicsImpostor
  101888. */
  101889. getImpostors(): Array<PhysicsImpostor>;
  101890. /**
  101891. * Gets the impostor for a physics enabled object
  101892. * @param object defines the object impersonated by the impostor
  101893. * @returns the PhysicsImpostor or null if not found
  101894. */
  101895. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101896. /**
  101897. * Gets the impostor for a physics body object
  101898. * @param body defines physics body used by the impostor
  101899. * @returns the PhysicsImpostor or null if not found
  101900. */
  101901. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101902. }
  101903. }
  101904. declare module BABYLON {
  101905. /** @hidden */
  101906. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101907. private _useDeltaForWorldStep;
  101908. world: any;
  101909. name: string;
  101910. private _physicsMaterials;
  101911. private _fixedTimeStep;
  101912. BJSCANNON: any;
  101913. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101914. setGravity(gravity: Vector3): void;
  101915. setTimeStep(timeStep: number): void;
  101916. getTimeStep(): number;
  101917. executeStep(delta: number): void;
  101918. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101920. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101921. private _processChildMeshes;
  101922. removePhysicsBody(impostor: PhysicsImpostor): void;
  101923. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101924. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101925. private _addMaterial;
  101926. private _checkWithEpsilon;
  101927. private _createShape;
  101928. private _createHeightmap;
  101929. private _minus90X;
  101930. private _plus90X;
  101931. private _tmpPosition;
  101932. private _tmpDeltaPosition;
  101933. private _tmpUnityRotation;
  101934. private _updatePhysicsBodyTransformation;
  101935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101937. isSupported(): boolean;
  101938. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101939. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101940. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101941. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101942. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101943. getBodyMass(impostor: PhysicsImpostor): number;
  101944. getBodyFriction(impostor: PhysicsImpostor): number;
  101945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101946. getBodyRestitution(impostor: PhysicsImpostor): number;
  101947. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101948. sleepBody(impostor: PhysicsImpostor): void;
  101949. wakeUpBody(impostor: PhysicsImpostor): void;
  101950. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101951. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101952. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101954. getRadius(impostor: PhysicsImpostor): number;
  101955. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101956. dispose(): void;
  101957. private _extendNamespace;
  101958. }
  101959. }
  101960. declare module BABYLON {
  101961. /** @hidden */
  101962. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101963. world: any;
  101964. name: string;
  101965. BJSOIMO: any;
  101966. constructor(iterations?: number, oimoInjection?: any);
  101967. setGravity(gravity: Vector3): void;
  101968. setTimeStep(timeStep: number): void;
  101969. getTimeStep(): number;
  101970. private _tmpImpostorsArray;
  101971. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101972. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101973. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101974. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101975. private _tmpPositionVector;
  101976. removePhysicsBody(impostor: PhysicsImpostor): void;
  101977. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101978. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101979. isSupported(): boolean;
  101980. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101981. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101982. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101983. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101984. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101985. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101986. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101987. getBodyMass(impostor: PhysicsImpostor): number;
  101988. getBodyFriction(impostor: PhysicsImpostor): number;
  101989. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101990. getBodyRestitution(impostor: PhysicsImpostor): number;
  101991. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101992. sleepBody(impostor: PhysicsImpostor): void;
  101993. wakeUpBody(impostor: PhysicsImpostor): void;
  101994. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101995. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101996. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101997. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101998. getRadius(impostor: PhysicsImpostor): number;
  101999. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102000. dispose(): void;
  102001. }
  102002. }
  102003. declare module BABYLON {
  102004. interface AbstractScene {
  102005. /**
  102006. * The list of reflection probes added to the scene
  102007. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102008. */
  102009. reflectionProbes: Array<ReflectionProbe>;
  102010. /**
  102011. * Removes the given reflection probe from this scene.
  102012. * @param toRemove The reflection probe to remove
  102013. * @returns The index of the removed reflection probe
  102014. */
  102015. removeReflectionProbe(toRemove: ReflectionProbe): number;
  102016. /**
  102017. * Adds the given reflection probe to this scene.
  102018. * @param newReflectionProbe The reflection probe to add
  102019. */
  102020. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  102021. }
  102022. /**
  102023. * Class used to generate realtime reflection / refraction cube textures
  102024. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102025. */
  102026. export class ReflectionProbe {
  102027. /** defines the name of the probe */
  102028. name: string;
  102029. private _scene;
  102030. private _renderTargetTexture;
  102031. private _projectionMatrix;
  102032. private _viewMatrix;
  102033. private _target;
  102034. private _add;
  102035. private _attachedMesh;
  102036. private _invertYAxis;
  102037. /** Gets or sets probe position (center of the cube map) */
  102038. position: Vector3;
  102039. /**
  102040. * Creates a new reflection probe
  102041. * @param name defines the name of the probe
  102042. * @param size defines the texture resolution (for each face)
  102043. * @param scene defines the hosting scene
  102044. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  102045. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  102046. */
  102047. constructor(
  102048. /** defines the name of the probe */
  102049. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  102050. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  102051. samples: number;
  102052. /** Gets or sets the refresh rate to use (on every frame by default) */
  102053. refreshRate: number;
  102054. /**
  102055. * Gets the hosting scene
  102056. * @returns a Scene
  102057. */
  102058. getScene(): Scene;
  102059. /** Gets the internal CubeTexture used to render to */
  102060. readonly cubeTexture: RenderTargetTexture;
  102061. /** Gets the list of meshes to render */
  102062. readonly renderList: Nullable<AbstractMesh[]>;
  102063. /**
  102064. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  102065. * @param mesh defines the mesh to attach to
  102066. */
  102067. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102068. /**
  102069. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  102070. * @param renderingGroupId The rendering group id corresponding to its index
  102071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102072. */
  102073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102074. /**
  102075. * Clean all associated resources
  102076. */
  102077. dispose(): void;
  102078. /**
  102079. * Converts the reflection probe information to a readable string for debug purpose.
  102080. * @param fullDetails Supports for multiple levels of logging within scene loading
  102081. * @returns the human readable reflection probe info
  102082. */
  102083. toString(fullDetails?: boolean): string;
  102084. /**
  102085. * Get the class name of the relfection probe.
  102086. * @returns "ReflectionProbe"
  102087. */
  102088. getClassName(): string;
  102089. /**
  102090. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  102091. * @returns The JSON representation of the texture
  102092. */
  102093. serialize(): any;
  102094. /**
  102095. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  102096. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  102097. * @param scene Define the scene the parsed reflection probe should be instantiated in
  102098. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102099. * @returns The parsed reflection probe if successful
  102100. */
  102101. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. /** @hidden */
  102106. export var _BabylonLoaderRegistered: boolean;
  102107. }
  102108. declare module BABYLON {
  102109. /**
  102110. * The Physically based simple base material of BJS.
  102111. *
  102112. * This enables better naming and convention enforcements on top of the pbrMaterial.
  102113. * It is used as the base class for both the specGloss and metalRough conventions.
  102114. */
  102115. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  102116. /**
  102117. * Number of Simultaneous lights allowed on the material.
  102118. */
  102119. maxSimultaneousLights: number;
  102120. /**
  102121. * If sets to true, disables all the lights affecting the material.
  102122. */
  102123. disableLighting: boolean;
  102124. /**
  102125. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  102126. */
  102127. environmentTexture: BaseTexture;
  102128. /**
  102129. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102130. */
  102131. invertNormalMapX: boolean;
  102132. /**
  102133. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102134. */
  102135. invertNormalMapY: boolean;
  102136. /**
  102137. * Normal map used in the model.
  102138. */
  102139. normalTexture: BaseTexture;
  102140. /**
  102141. * Emissivie color used to self-illuminate the model.
  102142. */
  102143. emissiveColor: Color3;
  102144. /**
  102145. * Emissivie texture used to self-illuminate the model.
  102146. */
  102147. emissiveTexture: BaseTexture;
  102148. /**
  102149. * Occlusion Channel Strenght.
  102150. */
  102151. occlusionStrength: number;
  102152. /**
  102153. * Occlusion Texture of the material (adding extra occlusion effects).
  102154. */
  102155. occlusionTexture: BaseTexture;
  102156. /**
  102157. * Defines the alpha limits in alpha test mode.
  102158. */
  102159. alphaCutOff: number;
  102160. /**
  102161. * Gets the current double sided mode.
  102162. */
  102163. /**
  102164. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102165. */
  102166. doubleSided: boolean;
  102167. /**
  102168. * Stores the pre-calculated light information of a mesh in a texture.
  102169. */
  102170. lightmapTexture: BaseTexture;
  102171. /**
  102172. * If true, the light map contains occlusion information instead of lighting info.
  102173. */
  102174. useLightmapAsShadowmap: boolean;
  102175. /**
  102176. * Return the active textures of the material.
  102177. */
  102178. getActiveTextures(): BaseTexture[];
  102179. hasTexture(texture: BaseTexture): boolean;
  102180. /**
  102181. * Instantiates a new PBRMaterial instance.
  102182. *
  102183. * @param name The material name
  102184. * @param scene The scene the material will be use in.
  102185. */
  102186. constructor(name: string, scene: Scene);
  102187. getClassName(): string;
  102188. }
  102189. }
  102190. declare module BABYLON {
  102191. /**
  102192. * The PBR material of BJS following the metal roughness convention.
  102193. *
  102194. * This fits to the PBR convention in the GLTF definition:
  102195. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102196. */
  102197. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102198. /**
  102199. * The base color has two different interpretations depending on the value of metalness.
  102200. * When the material is a metal, the base color is the specific measured reflectance value
  102201. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102202. * of the material.
  102203. */
  102204. baseColor: Color3;
  102205. /**
  102206. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102207. * well as opacity information in the alpha channel.
  102208. */
  102209. baseTexture: BaseTexture;
  102210. /**
  102211. * Specifies the metallic scalar value of the material.
  102212. * Can also be used to scale the metalness values of the metallic texture.
  102213. */
  102214. metallic: number;
  102215. /**
  102216. * Specifies the roughness scalar value of the material.
  102217. * Can also be used to scale the roughness values of the metallic texture.
  102218. */
  102219. roughness: number;
  102220. /**
  102221. * Texture containing both the metallic value in the B channel and the
  102222. * roughness value in the G channel to keep better precision.
  102223. */
  102224. metallicRoughnessTexture: BaseTexture;
  102225. /**
  102226. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102227. *
  102228. * @param name The material name
  102229. * @param scene The scene the material will be use in.
  102230. */
  102231. constructor(name: string, scene: Scene);
  102232. /**
  102233. * Return the currrent class name of the material.
  102234. */
  102235. getClassName(): string;
  102236. /**
  102237. * Return the active textures of the material.
  102238. */
  102239. getActiveTextures(): BaseTexture[];
  102240. /**
  102241. * Checks to see if a texture is used in the material.
  102242. * @param texture - Base texture to use.
  102243. * @returns - Boolean specifying if a texture is used in the material.
  102244. */
  102245. hasTexture(texture: BaseTexture): boolean;
  102246. /**
  102247. * Makes a duplicate of the current material.
  102248. * @param name - name to use for the new material.
  102249. */
  102250. clone(name: string): PBRMetallicRoughnessMaterial;
  102251. /**
  102252. * Serialize the material to a parsable JSON object.
  102253. */
  102254. serialize(): any;
  102255. /**
  102256. * Parses a JSON object correponding to the serialize function.
  102257. */
  102258. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102259. }
  102260. }
  102261. declare module BABYLON {
  102262. /**
  102263. * The PBR material of BJS following the specular glossiness convention.
  102264. *
  102265. * This fits to the PBR convention in the GLTF definition:
  102266. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102267. */
  102268. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102269. /**
  102270. * Specifies the diffuse color of the material.
  102271. */
  102272. diffuseColor: Color3;
  102273. /**
  102274. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102275. * channel.
  102276. */
  102277. diffuseTexture: BaseTexture;
  102278. /**
  102279. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102280. */
  102281. specularColor: Color3;
  102282. /**
  102283. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102284. */
  102285. glossiness: number;
  102286. /**
  102287. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102288. */
  102289. specularGlossinessTexture: BaseTexture;
  102290. /**
  102291. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102292. *
  102293. * @param name The material name
  102294. * @param scene The scene the material will be use in.
  102295. */
  102296. constructor(name: string, scene: Scene);
  102297. /**
  102298. * Return the currrent class name of the material.
  102299. */
  102300. getClassName(): string;
  102301. /**
  102302. * Return the active textures of the material.
  102303. */
  102304. getActiveTextures(): BaseTexture[];
  102305. /**
  102306. * Checks to see if a texture is used in the material.
  102307. * @param texture - Base texture to use.
  102308. * @returns - Boolean specifying if a texture is used in the material.
  102309. */
  102310. hasTexture(texture: BaseTexture): boolean;
  102311. /**
  102312. * Makes a duplicate of the current material.
  102313. * @param name - name to use for the new material.
  102314. */
  102315. clone(name: string): PBRSpecularGlossinessMaterial;
  102316. /**
  102317. * Serialize the material to a parsable JSON object.
  102318. */
  102319. serialize(): any;
  102320. /**
  102321. * Parses a JSON object correponding to the serialize function.
  102322. */
  102323. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102324. }
  102325. }
  102326. declare module BABYLON {
  102327. /**
  102328. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102329. * It can help converting any input color in a desired output one. This can then be used to create effects
  102330. * from sepia, black and white to sixties or futuristic rendering...
  102331. *
  102332. * The only supported format is currently 3dl.
  102333. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102334. */
  102335. export class ColorGradingTexture extends BaseTexture {
  102336. /**
  102337. * The current texture matrix. (will always be identity in color grading texture)
  102338. */
  102339. private _textureMatrix;
  102340. /**
  102341. * The texture URL.
  102342. */
  102343. url: string;
  102344. /**
  102345. * Empty line regex stored for GC.
  102346. */
  102347. private static _noneEmptyLineRegex;
  102348. private _engine;
  102349. /**
  102350. * Instantiates a ColorGradingTexture from the following parameters.
  102351. *
  102352. * @param url The location of the color gradind data (currently only supporting 3dl)
  102353. * @param scene The scene the texture will be used in
  102354. */
  102355. constructor(url: string, scene: Scene);
  102356. /**
  102357. * Returns the texture matrix used in most of the material.
  102358. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102359. */
  102360. getTextureMatrix(): Matrix;
  102361. /**
  102362. * Occurs when the file being loaded is a .3dl LUT file.
  102363. */
  102364. private load3dlTexture;
  102365. /**
  102366. * Starts the loading process of the texture.
  102367. */
  102368. private loadTexture;
  102369. /**
  102370. * Clones the color gradind texture.
  102371. */
  102372. clone(): ColorGradingTexture;
  102373. /**
  102374. * Called during delayed load for textures.
  102375. */
  102376. delayLoad(): void;
  102377. /**
  102378. * Parses a color grading texture serialized by Babylon.
  102379. * @param parsedTexture The texture information being parsedTexture
  102380. * @param scene The scene to load the texture in
  102381. * @param rootUrl The root url of the data assets to load
  102382. * @return A color gradind texture
  102383. */
  102384. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102385. /**
  102386. * Serializes the LUT texture to json format.
  102387. */
  102388. serialize(): any;
  102389. }
  102390. }
  102391. declare module BABYLON {
  102392. /**
  102393. * Direct draw surface info
  102394. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102395. */
  102396. export interface DDSInfo {
  102397. /**
  102398. * Width of the texture
  102399. */
  102400. width: number;
  102401. /**
  102402. * Width of the texture
  102403. */
  102404. height: number;
  102405. /**
  102406. * Number of Mipmaps for the texture
  102407. * @see https://en.wikipedia.org/wiki/Mipmap
  102408. */
  102409. mipmapCount: number;
  102410. /**
  102411. * If the textures format is a known fourCC format
  102412. * @see https://www.fourcc.org/
  102413. */
  102414. isFourCC: boolean;
  102415. /**
  102416. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102417. */
  102418. isRGB: boolean;
  102419. /**
  102420. * If the texture is a lumincance format
  102421. */
  102422. isLuminance: boolean;
  102423. /**
  102424. * If this is a cube texture
  102425. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102426. */
  102427. isCube: boolean;
  102428. /**
  102429. * If the texture is a compressed format eg. FOURCC_DXT1
  102430. */
  102431. isCompressed: boolean;
  102432. /**
  102433. * The dxgiFormat of the texture
  102434. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102435. */
  102436. dxgiFormat: number;
  102437. /**
  102438. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102439. */
  102440. textureType: number;
  102441. /**
  102442. * Sphericle polynomial created for the dds texture
  102443. */
  102444. sphericalPolynomial?: SphericalPolynomial;
  102445. }
  102446. /**
  102447. * Class used to provide DDS decompression tools
  102448. */
  102449. export class DDSTools {
  102450. /**
  102451. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102452. */
  102453. static StoreLODInAlphaChannel: boolean;
  102454. /**
  102455. * Gets DDS information from an array buffer
  102456. * @param arrayBuffer defines the array buffer to read data from
  102457. * @returns the DDS information
  102458. */
  102459. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102460. private static _FloatView;
  102461. private static _Int32View;
  102462. private static _ToHalfFloat;
  102463. private static _FromHalfFloat;
  102464. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102465. private static _GetHalfFloatRGBAArrayBuffer;
  102466. private static _GetFloatRGBAArrayBuffer;
  102467. private static _GetFloatAsUIntRGBAArrayBuffer;
  102468. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102469. private static _GetRGBAArrayBuffer;
  102470. private static _ExtractLongWordOrder;
  102471. private static _GetRGBArrayBuffer;
  102472. private static _GetLuminanceArrayBuffer;
  102473. /**
  102474. * Uploads DDS Levels to a Babylon Texture
  102475. * @hidden
  102476. */
  102477. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102478. }
  102479. interface Engine {
  102480. /**
  102481. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102482. * @param rootUrl defines the url where the file to load is located
  102483. * @param scene defines the current scene
  102484. * @param lodScale defines scale to apply to the mip map selection
  102485. * @param lodOffset defines offset to apply to the mip map selection
  102486. * @param onLoad defines an optional callback raised when the texture is loaded
  102487. * @param onError defines an optional callback raised if there is an issue to load the texture
  102488. * @param format defines the format of the data
  102489. * @param forcedExtension defines the extension to use to pick the right loader
  102490. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102491. * @returns the cube texture as an InternalTexture
  102492. */
  102493. 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;
  102494. }
  102495. }
  102496. declare module BABYLON {
  102497. /**
  102498. * Implementation of the DDS Texture Loader.
  102499. * @hidden
  102500. */
  102501. export class _DDSTextureLoader implements IInternalTextureLoader {
  102502. /**
  102503. * Defines wether the loader supports cascade loading the different faces.
  102504. */
  102505. readonly supportCascades: boolean;
  102506. /**
  102507. * This returns if the loader support the current file information.
  102508. * @param extension defines the file extension of the file being loaded
  102509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102510. * @param fallback defines the fallback internal texture if any
  102511. * @param isBase64 defines whether the texture is encoded as a base64
  102512. * @param isBuffer defines whether the texture data are stored as a buffer
  102513. * @returns true if the loader can load the specified file
  102514. */
  102515. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102516. /**
  102517. * Transform the url before loading if required.
  102518. * @param rootUrl the url of the texture
  102519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102520. * @returns the transformed texture
  102521. */
  102522. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102523. /**
  102524. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102525. * @param rootUrl the url of the texture
  102526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102527. * @returns the fallback texture
  102528. */
  102529. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102530. /**
  102531. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102532. * @param data contains the texture data
  102533. * @param texture defines the BabylonJS internal texture
  102534. * @param createPolynomials will be true if polynomials have been requested
  102535. * @param onLoad defines the callback to trigger once the texture is ready
  102536. * @param onError defines the callback to trigger in case of error
  102537. */
  102538. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102539. /**
  102540. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102541. * @param data contains the texture data
  102542. * @param texture defines the BabylonJS internal texture
  102543. * @param callback defines the method to call once ready to upload
  102544. */
  102545. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102546. }
  102547. }
  102548. declare module BABYLON {
  102549. /** @hidden */
  102550. export var rgbdEncodePixelShader: {
  102551. name: string;
  102552. shader: string;
  102553. };
  102554. }
  102555. declare module BABYLON {
  102556. /** @hidden */
  102557. export var rgbdDecodePixelShader: {
  102558. name: string;
  102559. shader: string;
  102560. };
  102561. }
  102562. declare module BABYLON {
  102563. /**
  102564. * Raw texture data and descriptor sufficient for WebGL texture upload
  102565. */
  102566. export interface EnvironmentTextureInfo {
  102567. /**
  102568. * Version of the environment map
  102569. */
  102570. version: number;
  102571. /**
  102572. * Width of image
  102573. */
  102574. width: number;
  102575. /**
  102576. * Irradiance information stored in the file.
  102577. */
  102578. irradiance: any;
  102579. /**
  102580. * Specular information stored in the file.
  102581. */
  102582. specular: any;
  102583. }
  102584. /**
  102585. * Sets of helpers addressing the serialization and deserialization of environment texture
  102586. * stored in a BabylonJS env file.
  102587. * Those files are usually stored as .env files.
  102588. */
  102589. export class EnvironmentTextureTools {
  102590. /**
  102591. * Magic number identifying the env file.
  102592. */
  102593. private static _MagicBytes;
  102594. /**
  102595. * Gets the environment info from an env file.
  102596. * @param data The array buffer containing the .env bytes.
  102597. * @returns the environment file info (the json header) if successfully parsed.
  102598. */
  102599. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102600. /**
  102601. * Creates an environment texture from a loaded cube texture.
  102602. * @param texture defines the cube texture to convert in env file
  102603. * @return a promise containing the environment data if succesfull.
  102604. */
  102605. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102606. /**
  102607. * Creates a JSON representation of the spherical data.
  102608. * @param texture defines the texture containing the polynomials
  102609. * @return the JSON representation of the spherical info
  102610. */
  102611. private static _CreateEnvTextureIrradiance;
  102612. /**
  102613. * Uploads the texture info contained in the env file to the GPU.
  102614. * @param texture defines the internal texture to upload to
  102615. * @param arrayBuffer defines the buffer cotaining the data to load
  102616. * @param info defines the texture info retrieved through the GetEnvInfo method
  102617. * @returns a promise
  102618. */
  102619. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102620. /**
  102621. * Uploads the levels of image data to the GPU.
  102622. * @param texture defines the internal texture to upload to
  102623. * @param imageData defines the array buffer views of image data [mipmap][face]
  102624. * @returns a promise
  102625. */
  102626. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102627. /**
  102628. * Uploads spherical polynomials information to the texture.
  102629. * @param texture defines the texture we are trying to upload the information to
  102630. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102631. */
  102632. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102633. /** @hidden */
  102634. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102635. }
  102636. }
  102637. declare module BABYLON {
  102638. /**
  102639. * Implementation of the ENV Texture Loader.
  102640. * @hidden
  102641. */
  102642. export class _ENVTextureLoader implements IInternalTextureLoader {
  102643. /**
  102644. * Defines wether the loader supports cascade loading the different faces.
  102645. */
  102646. readonly supportCascades: boolean;
  102647. /**
  102648. * This returns if the loader support the current file information.
  102649. * @param extension defines the file extension of the file being loaded
  102650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102651. * @param fallback defines the fallback internal texture if any
  102652. * @param isBase64 defines whether the texture is encoded as a base64
  102653. * @param isBuffer defines whether the texture data are stored as a buffer
  102654. * @returns true if the loader can load the specified file
  102655. */
  102656. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102657. /**
  102658. * Transform the url before loading if required.
  102659. * @param rootUrl the url of the texture
  102660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102661. * @returns the transformed texture
  102662. */
  102663. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102664. /**
  102665. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102666. * @param rootUrl the url of the texture
  102667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102668. * @returns the fallback texture
  102669. */
  102670. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102671. /**
  102672. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102673. * @param data contains the texture data
  102674. * @param texture defines the BabylonJS internal texture
  102675. * @param createPolynomials will be true if polynomials have been requested
  102676. * @param onLoad defines the callback to trigger once the texture is ready
  102677. * @param onError defines the callback to trigger in case of error
  102678. */
  102679. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102680. /**
  102681. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102682. * @param data contains the texture data
  102683. * @param texture defines the BabylonJS internal texture
  102684. * @param callback defines the method to call once ready to upload
  102685. */
  102686. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102687. }
  102688. }
  102689. declare module BABYLON {
  102690. /**
  102691. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102692. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102693. */
  102694. export class KhronosTextureContainer {
  102695. /** contents of the KTX container file */
  102696. arrayBuffer: any;
  102697. private static HEADER_LEN;
  102698. private static COMPRESSED_2D;
  102699. private static COMPRESSED_3D;
  102700. private static TEX_2D;
  102701. private static TEX_3D;
  102702. /**
  102703. * Gets the openGL type
  102704. */
  102705. glType: number;
  102706. /**
  102707. * Gets the openGL type size
  102708. */
  102709. glTypeSize: number;
  102710. /**
  102711. * Gets the openGL format
  102712. */
  102713. glFormat: number;
  102714. /**
  102715. * Gets the openGL internal format
  102716. */
  102717. glInternalFormat: number;
  102718. /**
  102719. * Gets the base internal format
  102720. */
  102721. glBaseInternalFormat: number;
  102722. /**
  102723. * Gets image width in pixel
  102724. */
  102725. pixelWidth: number;
  102726. /**
  102727. * Gets image height in pixel
  102728. */
  102729. pixelHeight: number;
  102730. /**
  102731. * Gets image depth in pixels
  102732. */
  102733. pixelDepth: number;
  102734. /**
  102735. * Gets the number of array elements
  102736. */
  102737. numberOfArrayElements: number;
  102738. /**
  102739. * Gets the number of faces
  102740. */
  102741. numberOfFaces: number;
  102742. /**
  102743. * Gets the number of mipmap levels
  102744. */
  102745. numberOfMipmapLevels: number;
  102746. /**
  102747. * Gets the bytes of key value data
  102748. */
  102749. bytesOfKeyValueData: number;
  102750. /**
  102751. * Gets the load type
  102752. */
  102753. loadType: number;
  102754. /**
  102755. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102756. */
  102757. isInvalid: boolean;
  102758. /**
  102759. * Creates a new KhronosTextureContainer
  102760. * @param arrayBuffer contents of the KTX container file
  102761. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102762. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102763. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102764. */
  102765. constructor(
  102766. /** contents of the KTX container file */
  102767. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102768. /**
  102769. * Uploads KTX content to a Babylon Texture.
  102770. * It is assumed that the texture has already been created & is currently bound
  102771. * @hidden
  102772. */
  102773. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102774. private _upload2DCompressedLevels;
  102775. }
  102776. }
  102777. declare module BABYLON {
  102778. /**
  102779. * Implementation of the KTX Texture Loader.
  102780. * @hidden
  102781. */
  102782. export class _KTXTextureLoader implements IInternalTextureLoader {
  102783. /**
  102784. * Defines wether the loader supports cascade loading the different faces.
  102785. */
  102786. readonly supportCascades: boolean;
  102787. /**
  102788. * This returns if the loader support the current file information.
  102789. * @param extension defines the file extension of the file being loaded
  102790. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102791. * @param fallback defines the fallback internal texture if any
  102792. * @param isBase64 defines whether the texture is encoded as a base64
  102793. * @param isBuffer defines whether the texture data are stored as a buffer
  102794. * @returns true if the loader can load the specified file
  102795. */
  102796. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102797. /**
  102798. * Transform the url before loading if required.
  102799. * @param rootUrl the url of the texture
  102800. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102801. * @returns the transformed texture
  102802. */
  102803. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102804. /**
  102805. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102806. * @param rootUrl the url of the texture
  102807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102808. * @returns the fallback texture
  102809. */
  102810. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102811. /**
  102812. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102813. * @param data contains the texture data
  102814. * @param texture defines the BabylonJS internal texture
  102815. * @param createPolynomials will be true if polynomials have been requested
  102816. * @param onLoad defines the callback to trigger once the texture is ready
  102817. * @param onError defines the callback to trigger in case of error
  102818. */
  102819. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102820. /**
  102821. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102822. * @param data contains the texture data
  102823. * @param texture defines the BabylonJS internal texture
  102824. * @param callback defines the method to call once ready to upload
  102825. */
  102826. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. /**
  102831. * Based on jsTGALoader - Javascript loader for TGA file
  102832. * By Vincent Thibault
  102833. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102834. */
  102835. export class TGATools {
  102836. private static _TYPE_INDEXED;
  102837. private static _TYPE_RGB;
  102838. private static _TYPE_GREY;
  102839. private static _TYPE_RLE_INDEXED;
  102840. private static _TYPE_RLE_RGB;
  102841. private static _TYPE_RLE_GREY;
  102842. private static _ORIGIN_MASK;
  102843. private static _ORIGIN_SHIFT;
  102844. private static _ORIGIN_BL;
  102845. private static _ORIGIN_BR;
  102846. private static _ORIGIN_UL;
  102847. private static _ORIGIN_UR;
  102848. /**
  102849. * Gets the header of a TGA file
  102850. * @param data defines the TGA data
  102851. * @returns the header
  102852. */
  102853. static GetTGAHeader(data: Uint8Array): any;
  102854. /**
  102855. * Uploads TGA content to a Babylon Texture
  102856. * @hidden
  102857. */
  102858. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102859. /** @hidden */
  102860. 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;
  102861. /** @hidden */
  102862. 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;
  102863. /** @hidden */
  102864. 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;
  102865. /** @hidden */
  102866. 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;
  102867. /** @hidden */
  102868. 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;
  102869. /** @hidden */
  102870. 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;
  102871. }
  102872. }
  102873. declare module BABYLON {
  102874. /**
  102875. * Implementation of the TGA Texture Loader.
  102876. * @hidden
  102877. */
  102878. export class _TGATextureLoader implements IInternalTextureLoader {
  102879. /**
  102880. * Defines wether the loader supports cascade loading the different faces.
  102881. */
  102882. readonly supportCascades: boolean;
  102883. /**
  102884. * This returns if the loader support the current file information.
  102885. * @param extension defines the file extension of the file being loaded
  102886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102887. * @param fallback defines the fallback internal texture if any
  102888. * @param isBase64 defines whether the texture is encoded as a base64
  102889. * @param isBuffer defines whether the texture data are stored as a buffer
  102890. * @returns true if the loader can load the specified file
  102891. */
  102892. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102893. /**
  102894. * Transform the url before loading if required.
  102895. * @param rootUrl the url of the texture
  102896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102897. * @returns the transformed texture
  102898. */
  102899. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102900. /**
  102901. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102902. * @param rootUrl the url of the texture
  102903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102904. * @returns the fallback texture
  102905. */
  102906. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102907. /**
  102908. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102909. * @param data contains the texture data
  102910. * @param texture defines the BabylonJS internal texture
  102911. * @param createPolynomials will be true if polynomials have been requested
  102912. * @param onLoad defines the callback to trigger once the texture is ready
  102913. * @param onError defines the callback to trigger in case of error
  102914. */
  102915. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102916. /**
  102917. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102918. * @param data contains the texture data
  102919. * @param texture defines the BabylonJS internal texture
  102920. * @param callback defines the method to call once ready to upload
  102921. */
  102922. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102923. }
  102924. }
  102925. declare module BABYLON {
  102926. /**
  102927. * 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.
  102928. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102929. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102930. */
  102931. export class CustomProceduralTexture extends ProceduralTexture {
  102932. private _animate;
  102933. private _time;
  102934. private _config;
  102935. private _texturePath;
  102936. /**
  102937. * Instantiates a new Custom Procedural Texture.
  102938. * 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.
  102939. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102940. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102941. * @param name Define the name of the texture
  102942. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102943. * @param size Define the size of the texture to create
  102944. * @param scene Define the scene the texture belongs to
  102945. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102946. * @param generateMipMaps Define if the texture should creates mip maps or not
  102947. */
  102948. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102949. private _loadJson;
  102950. /**
  102951. * Is the texture ready to be used ? (rendered at least once)
  102952. * @returns true if ready, otherwise, false.
  102953. */
  102954. isReady(): boolean;
  102955. /**
  102956. * Render the texture to its associated render target.
  102957. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102958. */
  102959. render(useCameraPostProcess?: boolean): void;
  102960. /**
  102961. * Update the list of dependant textures samplers in the shader.
  102962. */
  102963. updateTextures(): void;
  102964. /**
  102965. * Update the uniform values of the procedural texture in the shader.
  102966. */
  102967. updateShaderUniforms(): void;
  102968. /**
  102969. * Define if the texture animates or not.
  102970. */
  102971. animate: boolean;
  102972. }
  102973. }
  102974. declare module BABYLON {
  102975. /** @hidden */
  102976. export var noisePixelShader: {
  102977. name: string;
  102978. shader: string;
  102979. };
  102980. }
  102981. declare module BABYLON {
  102982. /**
  102983. * Class used to generate noise procedural textures
  102984. */
  102985. export class NoiseProceduralTexture extends ProceduralTexture {
  102986. private _time;
  102987. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102988. brightness: number;
  102989. /** Defines the number of octaves to process */
  102990. octaves: number;
  102991. /** Defines the level of persistence (0.8 by default) */
  102992. persistence: number;
  102993. /** Gets or sets animation speed factor (default is 1) */
  102994. animationSpeedFactor: number;
  102995. /**
  102996. * Creates a new NoiseProceduralTexture
  102997. * @param name defines the name fo the texture
  102998. * @param size defines the size of the texture (default is 256)
  102999. * @param scene defines the hosting scene
  103000. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  103001. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  103002. */
  103003. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103004. private _updateShaderUniforms;
  103005. protected _getDefines(): string;
  103006. /** Generate the current state of the procedural texture */
  103007. render(useCameraPostProcess?: boolean): void;
  103008. /**
  103009. * Serializes this noise procedural texture
  103010. * @returns a serialized noise procedural texture object
  103011. */
  103012. serialize(): any;
  103013. /**
  103014. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  103015. * @param parsedTexture defines parsed texture data
  103016. * @param scene defines the current scene
  103017. * @param rootUrl defines the root URL containing noise procedural texture information
  103018. * @returns a parsed NoiseProceduralTexture
  103019. */
  103020. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  103021. }
  103022. }
  103023. declare module BABYLON {
  103024. /**
  103025. * Raw cube texture where the raw buffers are passed in
  103026. */
  103027. export class RawCubeTexture extends CubeTexture {
  103028. /**
  103029. * Creates a cube texture where the raw buffers are passed in.
  103030. * @param scene defines the scene the texture is attached to
  103031. * @param data defines the array of data to use to create each face
  103032. * @param size defines the size of the textures
  103033. * @param format defines the format of the data
  103034. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  103035. * @param generateMipMaps defines if the engine should generate the mip levels
  103036. * @param invertY defines if data must be stored with Y axis inverted
  103037. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  103038. * @param compression defines the compression used (null by default)
  103039. */
  103040. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  103041. /**
  103042. * Updates the raw cube texture.
  103043. * @param data defines the data to store
  103044. * @param format defines the data format
  103045. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  103046. * @param invertY defines if data must be stored with Y axis inverted
  103047. * @param compression defines the compression used (null by default)
  103048. * @param level defines which level of the texture to update
  103049. */
  103050. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  103051. /**
  103052. * Updates a raw cube texture with RGBD encoded data.
  103053. * @param data defines the array of data [mipmap][face] to use to create each face
  103054. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  103055. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  103056. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  103057. * @returns a promsie that resolves when the operation is complete
  103058. */
  103059. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  103060. /**
  103061. * Clones the raw cube texture.
  103062. * @return a new cube texture
  103063. */
  103064. clone(): CubeTexture;
  103065. /** @hidden */
  103066. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103067. }
  103068. }
  103069. declare module BABYLON {
  103070. /**
  103071. * Class used to store 3D textures containing user data
  103072. */
  103073. export class RawTexture3D extends Texture {
  103074. /** Gets or sets the texture format to use */
  103075. format: number;
  103076. private _engine;
  103077. /**
  103078. * Create a new RawTexture3D
  103079. * @param data defines the data of the texture
  103080. * @param width defines the width of the texture
  103081. * @param height defines the height of the texture
  103082. * @param depth defines the depth of the texture
  103083. * @param format defines the texture format to use
  103084. * @param scene defines the hosting scene
  103085. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  103086. * @param invertY defines if texture must be stored with Y axis inverted
  103087. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  103088. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  103089. */
  103090. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  103091. /** Gets or sets the texture format to use */
  103092. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  103093. /**
  103094. * Update the texture with new data
  103095. * @param data defines the data to store in the texture
  103096. */
  103097. update(data: ArrayBufferView): void;
  103098. }
  103099. }
  103100. declare module BABYLON {
  103101. /**
  103102. * Creates a refraction texture used by refraction channel of the standard material.
  103103. * It is like a mirror but to see through a material.
  103104. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103105. */
  103106. export class RefractionTexture extends RenderTargetTexture {
  103107. /**
  103108. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  103109. * 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.
  103110. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103111. */
  103112. refractionPlane: Plane;
  103113. /**
  103114. * Define how deep under the surface we should see.
  103115. */
  103116. depth: number;
  103117. /**
  103118. * Creates a refraction texture used by refraction channel of the standard material.
  103119. * It is like a mirror but to see through a material.
  103120. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103121. * @param name Define the texture name
  103122. * @param size Define the size of the underlying texture
  103123. * @param scene Define the scene the refraction belongs to
  103124. * @param generateMipMaps Define if we need to generate mips level for the refraction
  103125. */
  103126. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  103127. /**
  103128. * Clone the refraction texture.
  103129. * @returns the cloned texture
  103130. */
  103131. clone(): RefractionTexture;
  103132. /**
  103133. * Serialize the texture to a JSON representation you could use in Parse later on
  103134. * @returns the serialized JSON representation
  103135. */
  103136. serialize(): any;
  103137. }
  103138. }
  103139. declare module BABYLON {
  103140. /**
  103141. * Configuration for Draco compression
  103142. */
  103143. export interface IDracoCompressionConfiguration {
  103144. /**
  103145. * Configuration for the decoder.
  103146. */
  103147. decoder?: {
  103148. /**
  103149. * The url to the WebAssembly module.
  103150. */
  103151. wasmUrl?: string;
  103152. /**
  103153. * The url to the WebAssembly binary.
  103154. */
  103155. wasmBinaryUrl?: string;
  103156. /**
  103157. * The url to the fallback JavaScript module.
  103158. */
  103159. fallbackUrl?: string;
  103160. };
  103161. }
  103162. /**
  103163. * Draco compression (https://google.github.io/draco/)
  103164. *
  103165. * This class wraps the Draco module.
  103166. *
  103167. * **Encoder**
  103168. *
  103169. * The encoder is not currently implemented.
  103170. *
  103171. * **Decoder**
  103172. *
  103173. * 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.
  103174. *
  103175. * To update the configuration, use the following code:
  103176. * ```javascript
  103177. * DracoCompression.Configuration = {
  103178. * decoder: {
  103179. * wasmUrl: "<url to the WebAssembly library>",
  103180. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103181. * fallbackUrl: "<url to the fallback JavaScript library>",
  103182. * }
  103183. * };
  103184. * ```
  103185. *
  103186. * 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.
  103187. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103188. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103189. *
  103190. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103191. * ```javascript
  103192. * var dracoCompression = new DracoCompression();
  103193. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103194. * [VertexBuffer.PositionKind]: 0
  103195. * });
  103196. * ```
  103197. *
  103198. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103199. */
  103200. export class DracoCompression implements IDisposable {
  103201. private static _DecoderModulePromise;
  103202. /**
  103203. * The configuration. Defaults to the following urls:
  103204. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103205. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103206. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103207. */
  103208. static Configuration: IDracoCompressionConfiguration;
  103209. /**
  103210. * Returns true if the decoder is available.
  103211. */
  103212. static readonly DecoderAvailable: boolean;
  103213. /**
  103214. * Constructor
  103215. */
  103216. constructor();
  103217. /**
  103218. * Stop all async operations and release resources.
  103219. */
  103220. dispose(): void;
  103221. /**
  103222. * Decode Draco compressed mesh data to vertex data.
  103223. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103224. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103225. * @returns A promise that resolves with the decoded vertex data
  103226. */
  103227. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103228. [kind: string]: number;
  103229. }): Promise<VertexData>;
  103230. private static _GetDecoderModule;
  103231. private static _LoadScriptAsync;
  103232. private static _LoadFileAsync;
  103233. }
  103234. }
  103235. declare module BABYLON {
  103236. /**
  103237. * Class for building Constructive Solid Geometry
  103238. */
  103239. export class CSG {
  103240. private polygons;
  103241. /**
  103242. * The world matrix
  103243. */
  103244. matrix: Matrix;
  103245. /**
  103246. * Stores the position
  103247. */
  103248. position: Vector3;
  103249. /**
  103250. * Stores the rotation
  103251. */
  103252. rotation: Vector3;
  103253. /**
  103254. * Stores the rotation quaternion
  103255. */
  103256. rotationQuaternion: Nullable<Quaternion>;
  103257. /**
  103258. * Stores the scaling vector
  103259. */
  103260. scaling: Vector3;
  103261. /**
  103262. * Convert the Mesh to CSG
  103263. * @param mesh The Mesh to convert to CSG
  103264. * @returns A new CSG from the Mesh
  103265. */
  103266. static FromMesh(mesh: Mesh): CSG;
  103267. /**
  103268. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103269. * @param polygons Polygons used to construct a CSG solid
  103270. */
  103271. private static FromPolygons;
  103272. /**
  103273. * Clones, or makes a deep copy, of the CSG
  103274. * @returns A new CSG
  103275. */
  103276. clone(): CSG;
  103277. /**
  103278. * Unions this CSG with another CSG
  103279. * @param csg The CSG to union against this CSG
  103280. * @returns The unioned CSG
  103281. */
  103282. union(csg: CSG): CSG;
  103283. /**
  103284. * Unions this CSG with another CSG in place
  103285. * @param csg The CSG to union against this CSG
  103286. */
  103287. unionInPlace(csg: CSG): void;
  103288. /**
  103289. * Subtracts this CSG with another CSG
  103290. * @param csg The CSG to subtract against this CSG
  103291. * @returns A new CSG
  103292. */
  103293. subtract(csg: CSG): CSG;
  103294. /**
  103295. * Subtracts this CSG with another CSG in place
  103296. * @param csg The CSG to subtact against this CSG
  103297. */
  103298. subtractInPlace(csg: CSG): void;
  103299. /**
  103300. * Intersect this CSG with another CSG
  103301. * @param csg The CSG to intersect against this CSG
  103302. * @returns A new CSG
  103303. */
  103304. intersect(csg: CSG): CSG;
  103305. /**
  103306. * Intersects this CSG with another CSG in place
  103307. * @param csg The CSG to intersect against this CSG
  103308. */
  103309. intersectInPlace(csg: CSG): void;
  103310. /**
  103311. * Return a new CSG solid with solid and empty space switched. This solid is
  103312. * not modified.
  103313. * @returns A new CSG solid with solid and empty space switched
  103314. */
  103315. inverse(): CSG;
  103316. /**
  103317. * Inverses the CSG in place
  103318. */
  103319. inverseInPlace(): void;
  103320. /**
  103321. * This is used to keep meshes transformations so they can be restored
  103322. * when we build back a Babylon Mesh
  103323. * NB : All CSG operations are performed in world coordinates
  103324. * @param csg The CSG to copy the transform attributes from
  103325. * @returns This CSG
  103326. */
  103327. copyTransformAttributes(csg: CSG): CSG;
  103328. /**
  103329. * Build Raw mesh from CSG
  103330. * Coordinates here are in world space
  103331. * @param name The name of the mesh geometry
  103332. * @param scene The Scene
  103333. * @param keepSubMeshes Specifies if the submeshes should be kept
  103334. * @returns A new Mesh
  103335. */
  103336. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103337. /**
  103338. * Build Mesh from CSG taking material and transforms into account
  103339. * @param name The name of the Mesh
  103340. * @param material The material of the Mesh
  103341. * @param scene The Scene
  103342. * @param keepSubMeshes Specifies if submeshes should be kept
  103343. * @returns The new Mesh
  103344. */
  103345. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /**
  103350. * A simplifier interface for future simplification implementations
  103351. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103352. */
  103353. export interface ISimplifier {
  103354. /**
  103355. * Simplification of a given mesh according to the given settings.
  103356. * Since this requires computation, it is assumed that the function runs async.
  103357. * @param settings The settings of the simplification, including quality and distance
  103358. * @param successCallback A callback that will be called after the mesh was simplified.
  103359. * @param errorCallback in case of an error, this callback will be called. optional.
  103360. */
  103361. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  103362. }
  103363. /**
  103364. * Expected simplification settings.
  103365. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  103366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103367. */
  103368. export interface ISimplificationSettings {
  103369. /**
  103370. * Gets or sets the expected quality
  103371. */
  103372. quality: number;
  103373. /**
  103374. * Gets or sets the distance when this optimized version should be used
  103375. */
  103376. distance: number;
  103377. /**
  103378. * Gets an already optimized mesh
  103379. */
  103380. optimizeMesh?: boolean;
  103381. }
  103382. /**
  103383. * Class used to specify simplification options
  103384. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103385. */
  103386. export class SimplificationSettings implements ISimplificationSettings {
  103387. /** expected quality */
  103388. quality: number;
  103389. /** distance when this optimized version should be used */
  103390. distance: number;
  103391. /** already optimized mesh */
  103392. optimizeMesh?: boolean | undefined;
  103393. /**
  103394. * Creates a SimplificationSettings
  103395. * @param quality expected quality
  103396. * @param distance distance when this optimized version should be used
  103397. * @param optimizeMesh already optimized mesh
  103398. */
  103399. constructor(
  103400. /** expected quality */
  103401. quality: number,
  103402. /** distance when this optimized version should be used */
  103403. distance: number,
  103404. /** already optimized mesh */
  103405. optimizeMesh?: boolean | undefined);
  103406. }
  103407. /**
  103408. * Interface used to define a simplification task
  103409. */
  103410. export interface ISimplificationTask {
  103411. /**
  103412. * Array of settings
  103413. */
  103414. settings: Array<ISimplificationSettings>;
  103415. /**
  103416. * Simplification type
  103417. */
  103418. simplificationType: SimplificationType;
  103419. /**
  103420. * Mesh to simplify
  103421. */
  103422. mesh: Mesh;
  103423. /**
  103424. * Callback called on success
  103425. */
  103426. successCallback?: () => void;
  103427. /**
  103428. * Defines if parallel processing can be used
  103429. */
  103430. parallelProcessing: boolean;
  103431. }
  103432. /**
  103433. * Queue used to order the simplification tasks
  103434. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103435. */
  103436. export class SimplificationQueue {
  103437. private _simplificationArray;
  103438. /**
  103439. * Gets a boolean indicating that the process is still running
  103440. */
  103441. running: boolean;
  103442. /**
  103443. * Creates a new queue
  103444. */
  103445. constructor();
  103446. /**
  103447. * Adds a new simplification task
  103448. * @param task defines a task to add
  103449. */
  103450. addTask(task: ISimplificationTask): void;
  103451. /**
  103452. * Execute next task
  103453. */
  103454. executeNext(): void;
  103455. /**
  103456. * Execute a simplification task
  103457. * @param task defines the task to run
  103458. */
  103459. runSimplification(task: ISimplificationTask): void;
  103460. private getSimplifier;
  103461. }
  103462. /**
  103463. * The implemented types of simplification
  103464. * At the moment only Quadratic Error Decimation is implemented
  103465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103466. */
  103467. export enum SimplificationType {
  103468. /** Quadratic error decimation */
  103469. QUADRATIC = 0
  103470. }
  103471. }
  103472. declare module BABYLON {
  103473. interface Scene {
  103474. /** @hidden (Backing field) */
  103475. _simplificationQueue: SimplificationQueue;
  103476. /**
  103477. * Gets or sets the simplification queue attached to the scene
  103478. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  103479. */
  103480. simplificationQueue: SimplificationQueue;
  103481. }
  103482. interface Mesh {
  103483. /**
  103484. * Simplify the mesh according to the given array of settings.
  103485. * Function will return immediately and will simplify async
  103486. * @param settings a collection of simplification settings
  103487. * @param parallelProcessing should all levels calculate parallel or one after the other
  103488. * @param simplificationType the type of simplification to run
  103489. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  103490. * @returns the current mesh
  103491. */
  103492. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  103493. }
  103494. /**
  103495. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  103496. * created in a scene
  103497. */
  103498. export class SimplicationQueueSceneComponent implements ISceneComponent {
  103499. /**
  103500. * The component name helpfull to identify the component in the list of scene components.
  103501. */
  103502. readonly name: string;
  103503. /**
  103504. * The scene the component belongs to.
  103505. */
  103506. scene: Scene;
  103507. /**
  103508. * Creates a new instance of the component for the given scene
  103509. * @param scene Defines the scene to register the component in
  103510. */
  103511. constructor(scene: Scene);
  103512. /**
  103513. * Registers the component in a given scene
  103514. */
  103515. register(): void;
  103516. /**
  103517. * Rebuilds the elements related to this component in case of
  103518. * context lost for instance.
  103519. */
  103520. rebuild(): void;
  103521. /**
  103522. * Disposes the component and the associated ressources
  103523. */
  103524. dispose(): void;
  103525. private _beforeCameraUpdate;
  103526. }
  103527. }
  103528. declare module BABYLON {
  103529. /**
  103530. * Class used to enable access to IndexedDB
  103531. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  103532. */
  103533. export class Database implements IOfflineProvider {
  103534. private _callbackManifestChecked;
  103535. private _currentSceneUrl;
  103536. private _db;
  103537. private _enableSceneOffline;
  103538. private _enableTexturesOffline;
  103539. private _manifestVersionFound;
  103540. private _mustUpdateRessources;
  103541. private _hasReachedQuota;
  103542. private _isSupported;
  103543. private _idbFactory;
  103544. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  103545. private static IsUASupportingBlobStorage;
  103546. /**
  103547. * Gets a boolean indicating if Database storate is enabled (off by default)
  103548. */
  103549. static IDBStorageEnabled: boolean;
  103550. /**
  103551. * Gets a boolean indicating if scene must be saved in the database
  103552. */
  103553. readonly enableSceneOffline: boolean;
  103554. /**
  103555. * Gets a boolean indicating if textures must be saved in the database
  103556. */
  103557. readonly enableTexturesOffline: boolean;
  103558. /**
  103559. * Creates a new Database
  103560. * @param urlToScene defines the url to load the scene
  103561. * @param callbackManifestChecked defines the callback to use when manifest is checked
  103562. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  103563. */
  103564. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  103565. private static _ParseURL;
  103566. private static _ReturnFullUrlLocation;
  103567. private _checkManifestFile;
  103568. /**
  103569. * Open the database and make it available
  103570. * @param successCallback defines the callback to call on success
  103571. * @param errorCallback defines the callback to call on error
  103572. */
  103573. open(successCallback: () => void, errorCallback: () => void): void;
  103574. /**
  103575. * Loads an image from the database
  103576. * @param url defines the url to load from
  103577. * @param image defines the target DOM image
  103578. */
  103579. loadImage(url: string, image: HTMLImageElement): void;
  103580. private _loadImageFromDBAsync;
  103581. private _saveImageIntoDBAsync;
  103582. private _checkVersionFromDB;
  103583. private _loadVersionFromDBAsync;
  103584. private _saveVersionIntoDBAsync;
  103585. /**
  103586. * Loads a file from database
  103587. * @param url defines the URL to load from
  103588. * @param sceneLoaded defines a callback to call on success
  103589. * @param progressCallBack defines a callback to call when progress changed
  103590. * @param errorCallback defines a callback to call on error
  103591. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  103592. */
  103593. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  103594. private _loadFileAsync;
  103595. private _saveFileAsync;
  103596. /**
  103597. * Validates if xhr data is correct
  103598. * @param xhr defines the request to validate
  103599. * @param dataType defines the expected data type
  103600. * @returns true if data is correct
  103601. */
  103602. private static _ValidateXHRData;
  103603. }
  103604. }
  103605. declare module BABYLON {
  103606. /** @hidden */
  103607. export var gpuUpdateParticlesPixelShader: {
  103608. name: string;
  103609. shader: string;
  103610. };
  103611. }
  103612. declare module BABYLON {
  103613. /** @hidden */
  103614. export var gpuUpdateParticlesVertexShader: {
  103615. name: string;
  103616. shader: string;
  103617. };
  103618. }
  103619. declare module BABYLON {
  103620. /** @hidden */
  103621. export var clipPlaneFragmentDeclaration2: {
  103622. name: string;
  103623. shader: string;
  103624. };
  103625. }
  103626. declare module BABYLON {
  103627. /** @hidden */
  103628. export var gpuRenderParticlesPixelShader: {
  103629. name: string;
  103630. shader: string;
  103631. };
  103632. }
  103633. declare module BABYLON {
  103634. /** @hidden */
  103635. export var clipPlaneVertexDeclaration2: {
  103636. name: string;
  103637. shader: string;
  103638. };
  103639. }
  103640. declare module BABYLON {
  103641. /** @hidden */
  103642. export var gpuRenderParticlesVertexShader: {
  103643. name: string;
  103644. shader: string;
  103645. };
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * This represents a GPU particle system in Babylon
  103650. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  103651. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  103652. */
  103653. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  103654. /**
  103655. * The layer mask we are rendering the particles through.
  103656. */
  103657. layerMask: number;
  103658. private _capacity;
  103659. private _activeCount;
  103660. private _currentActiveCount;
  103661. private _accumulatedCount;
  103662. private _renderEffect;
  103663. private _updateEffect;
  103664. private _buffer0;
  103665. private _buffer1;
  103666. private _spriteBuffer;
  103667. private _updateVAO;
  103668. private _renderVAO;
  103669. private _targetIndex;
  103670. private _sourceBuffer;
  103671. private _targetBuffer;
  103672. private _engine;
  103673. private _currentRenderId;
  103674. private _started;
  103675. private _stopped;
  103676. private _timeDelta;
  103677. private _randomTexture;
  103678. private _randomTexture2;
  103679. private _attributesStrideSize;
  103680. private _updateEffectOptions;
  103681. private _randomTextureSize;
  103682. private _actualFrame;
  103683. private readonly _rawTextureWidth;
  103684. /**
  103685. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  103686. */
  103687. static readonly IsSupported: boolean;
  103688. /**
  103689. * An event triggered when the system is disposed.
  103690. */
  103691. onDisposeObservable: Observable<GPUParticleSystem>;
  103692. /**
  103693. * Gets the maximum number of particles active at the same time.
  103694. * @returns The max number of active particles.
  103695. */
  103696. getCapacity(): number;
  103697. /**
  103698. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103699. * to override the particles.
  103700. */
  103701. forceDepthWrite: boolean;
  103702. /**
  103703. * Gets or set the number of active particles
  103704. */
  103705. activeParticleCount: number;
  103706. private _preWarmDone;
  103707. /**
  103708. * Is this system ready to be used/rendered
  103709. * @return true if the system is ready
  103710. */
  103711. isReady(): boolean;
  103712. /**
  103713. * Gets if the system has been started. (Note: this will still be true after stop is called)
  103714. * @returns True if it has been started, otherwise false.
  103715. */
  103716. isStarted(): boolean;
  103717. /**
  103718. * Starts the particle system and begins to emit
  103719. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  103720. */
  103721. start(delay?: number): void;
  103722. /**
  103723. * Stops the particle system.
  103724. */
  103725. stop(): void;
  103726. /**
  103727. * Remove all active particles
  103728. */
  103729. reset(): void;
  103730. /**
  103731. * Returns the string "GPUParticleSystem"
  103732. * @returns a string containing the class name
  103733. */
  103734. getClassName(): string;
  103735. private _colorGradientsTexture;
  103736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  103737. /**
  103738. * Adds a new color gradient
  103739. * @param gradient defines the gradient to use (between 0 and 1)
  103740. * @param color1 defines the color to affect to the specified gradient
  103741. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  103742. * @returns the current particle system
  103743. */
  103744. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  103745. /**
  103746. * Remove a specific color gradient
  103747. * @param gradient defines the gradient to remove
  103748. * @returns the current particle system
  103749. */
  103750. removeColorGradient(gradient: number): GPUParticleSystem;
  103751. private _angularSpeedGradientsTexture;
  103752. private _sizeGradientsTexture;
  103753. private _velocityGradientsTexture;
  103754. private _limitVelocityGradientsTexture;
  103755. private _dragGradientsTexture;
  103756. private _addFactorGradient;
  103757. /**
  103758. * Adds a new size gradient
  103759. * @param gradient defines the gradient to use (between 0 and 1)
  103760. * @param factor defines the size factor to affect to the specified gradient
  103761. * @returns the current particle system
  103762. */
  103763. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  103764. /**
  103765. * Remove a specific size gradient
  103766. * @param gradient defines the gradient to remove
  103767. * @returns the current particle system
  103768. */
  103769. removeSizeGradient(gradient: number): GPUParticleSystem;
  103770. /**
  103771. * Adds a new angular speed gradient
  103772. * @param gradient defines the gradient to use (between 0 and 1)
  103773. * @param factor defines the angular speed to affect to the specified gradient
  103774. * @returns the current particle system
  103775. */
  103776. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  103777. /**
  103778. * Remove a specific angular speed gradient
  103779. * @param gradient defines the gradient to remove
  103780. * @returns the current particle system
  103781. */
  103782. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  103783. /**
  103784. * Adds a new velocity gradient
  103785. * @param gradient defines the gradient to use (between 0 and 1)
  103786. * @param factor defines the velocity to affect to the specified gradient
  103787. * @returns the current particle system
  103788. */
  103789. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  103790. /**
  103791. * Remove a specific velocity gradient
  103792. * @param gradient defines the gradient to remove
  103793. * @returns the current particle system
  103794. */
  103795. removeVelocityGradient(gradient: number): GPUParticleSystem;
  103796. /**
  103797. * Adds a new limit velocity gradient
  103798. * @param gradient defines the gradient to use (between 0 and 1)
  103799. * @param factor defines the limit velocity value to affect to the specified gradient
  103800. * @returns the current particle system
  103801. */
  103802. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  103803. /**
  103804. * Remove a specific limit velocity gradient
  103805. * @param gradient defines the gradient to remove
  103806. * @returns the current particle system
  103807. */
  103808. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  103809. /**
  103810. * Adds a new drag gradient
  103811. * @param gradient defines the gradient to use (between 0 and 1)
  103812. * @param factor defines the drag value to affect to the specified gradient
  103813. * @returns the current particle system
  103814. */
  103815. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  103816. /**
  103817. * Remove a specific drag gradient
  103818. * @param gradient defines the gradient to remove
  103819. * @returns the current particle system
  103820. */
  103821. removeDragGradient(gradient: number): GPUParticleSystem;
  103822. /**
  103823. * Not supported by GPUParticleSystem
  103824. * @param gradient defines the gradient to use (between 0 and 1)
  103825. * @param factor defines the emit rate value to affect to the specified gradient
  103826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103827. * @returns the current particle system
  103828. */
  103829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103830. /**
  103831. * Not supported by GPUParticleSystem
  103832. * @param gradient defines the gradient to remove
  103833. * @returns the current particle system
  103834. */
  103835. removeEmitRateGradient(gradient: number): IParticleSystem;
  103836. /**
  103837. * Not supported by GPUParticleSystem
  103838. * @param gradient defines the gradient to use (between 0 and 1)
  103839. * @param factor defines the start size value to affect to the specified gradient
  103840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103841. * @returns the current particle system
  103842. */
  103843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103844. /**
  103845. * Not supported by GPUParticleSystem
  103846. * @param gradient defines the gradient to remove
  103847. * @returns the current particle system
  103848. */
  103849. removeStartSizeGradient(gradient: number): IParticleSystem;
  103850. /**
  103851. * Not supported by GPUParticleSystem
  103852. * @param gradient defines the gradient to use (between 0 and 1)
  103853. * @param min defines the color remap minimal range
  103854. * @param max defines the color remap maximal range
  103855. * @returns the current particle system
  103856. */
  103857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  103858. /**
  103859. * Not supported by GPUParticleSystem
  103860. * @param gradient defines the gradient to remove
  103861. * @returns the current particle system
  103862. */
  103863. removeColorRemapGradient(): IParticleSystem;
  103864. /**
  103865. * Not supported by GPUParticleSystem
  103866. * @param gradient defines the gradient to use (between 0 and 1)
  103867. * @param min defines the alpha remap minimal range
  103868. * @param max defines the alpha remap maximal range
  103869. * @returns the current particle system
  103870. */
  103871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  103872. /**
  103873. * Not supported by GPUParticleSystem
  103874. * @param gradient defines the gradient to remove
  103875. * @returns the current particle system
  103876. */
  103877. removeAlphaRemapGradient(): IParticleSystem;
  103878. /**
  103879. * Not supported by GPUParticleSystem
  103880. * @param gradient defines the gradient to use (between 0 and 1)
  103881. * @param color defines the color to affect to the specified gradient
  103882. * @returns the current particle system
  103883. */
  103884. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  103885. /**
  103886. * Not supported by GPUParticleSystem
  103887. * @param gradient defines the gradient to remove
  103888. * @returns the current particle system
  103889. */
  103890. removeRampGradient(): IParticleSystem;
  103891. /**
  103892. * Not supported by GPUParticleSystem
  103893. * @returns the list of ramp gradients
  103894. */
  103895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  103896. /**
  103897. * Not supported by GPUParticleSystem
  103898. * Gets or sets a boolean indicating that ramp gradients must be used
  103899. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  103900. */
  103901. useRampGradients: boolean;
  103902. /**
  103903. * Not supported by GPUParticleSystem
  103904. * @param gradient defines the gradient to use (between 0 and 1)
  103905. * @param factor defines the life time factor to affect to the specified gradient
  103906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  103907. * @returns the current particle system
  103908. */
  103909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  103910. /**
  103911. * Not supported by GPUParticleSystem
  103912. * @param gradient defines the gradient to remove
  103913. * @returns the current particle system
  103914. */
  103915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  103916. /**
  103917. * Instantiates a GPU particle system.
  103918. * 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.
  103919. * @param name The name of the particle system
  103920. * @param options The options used to create the system
  103921. * @param scene The scene the particle system belongs to
  103922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  103923. */
  103924. constructor(name: string, options: Partial<{
  103925. capacity: number;
  103926. randomTextureSize: number;
  103927. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  103928. protected _reset(): void;
  103929. private _createUpdateVAO;
  103930. private _createRenderVAO;
  103931. private _initialize;
  103932. /** @hidden */
  103933. _recreateUpdateEffect(): void;
  103934. /** @hidden */
  103935. _recreateRenderEffect(): void;
  103936. /**
  103937. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  103938. * @param preWarm defines if we are in the pre-warmimg phase
  103939. */
  103940. animate(preWarm?: boolean): void;
  103941. private _createFactorGradientTexture;
  103942. private _createSizeGradientTexture;
  103943. private _createAngularSpeedGradientTexture;
  103944. private _createVelocityGradientTexture;
  103945. private _createLimitVelocityGradientTexture;
  103946. private _createDragGradientTexture;
  103947. private _createColorGradientTexture;
  103948. /**
  103949. * Renders the particle system in its current state
  103950. * @param preWarm defines if the system should only update the particles but not render them
  103951. * @returns the current number of particles
  103952. */
  103953. render(preWarm?: boolean): number;
  103954. /**
  103955. * Rebuilds the particle system
  103956. */
  103957. rebuild(): void;
  103958. private _releaseBuffers;
  103959. private _releaseVAOs;
  103960. /**
  103961. * Disposes the particle system and free the associated resources
  103962. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  103963. */
  103964. dispose(disposeTexture?: boolean): void;
  103965. /**
  103966. * Clones the particle system.
  103967. * @param name The name of the cloned object
  103968. * @param newEmitter The new emitter to use
  103969. * @returns the cloned particle system
  103970. */
  103971. clone(name: string, newEmitter: any): GPUParticleSystem;
  103972. /**
  103973. * Serializes the particle system to a JSON object.
  103974. * @returns the JSON object
  103975. */
  103976. serialize(): any;
  103977. /**
  103978. * Parses a JSON object to create a GPU particle system.
  103979. * @param parsedParticleSystem The JSON object to parse
  103980. * @param scene The scene to create the particle system in
  103981. * @param rootUrl The root url to use to load external dependencies like texture
  103982. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  103983. * @returns the parsed GPU particle system
  103984. */
  103985. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  103986. }
  103987. }
  103988. declare module BABYLON {
  103989. /**
  103990. * Represents a set of particle systems working together to create a specific effect
  103991. */
  103992. export class ParticleSystemSet implements IDisposable {
  103993. private _emitterCreationOptions;
  103994. private _emitterNode;
  103995. /**
  103996. * Gets the particle system list
  103997. */
  103998. systems: IParticleSystem[];
  103999. /**
  104000. * Gets the emitter node used with this set
  104001. */
  104002. readonly emitterNode: Nullable<TransformNode>;
  104003. /**
  104004. * Creates a new emitter mesh as a sphere
  104005. * @param options defines the options used to create the sphere
  104006. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104007. * @param scene defines the hosting scene
  104008. */
  104009. setEmitterAsSphere(options: {
  104010. diameter: number;
  104011. segments: number;
  104012. color: Color3;
  104013. }, renderingGroupId: number, scene: Scene): void;
  104014. /**
  104015. * Starts all particle systems of the set
  104016. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104017. */
  104018. start(emitter?: AbstractMesh): void;
  104019. /**
  104020. * Release all associated resources
  104021. */
  104022. dispose(): void;
  104023. /**
  104024. * Serialize the set into a JSON compatible object
  104025. * @returns a JSON compatible representation of the set
  104026. */
  104027. serialize(): any;
  104028. /**
  104029. * Parse a new ParticleSystemSet from a serialized source
  104030. * @param data defines a JSON compatible representation of the set
  104031. * @param scene defines the hosting scene
  104032. * @param gpu defines if we want GPU particles or CPU particles
  104033. * @returns a new ParticleSystemSet
  104034. */
  104035. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104036. }
  104037. }
  104038. declare module BABYLON {
  104039. /**
  104040. * This class is made for on one-liner static method to help creating particle system set.
  104041. */
  104042. export class ParticleHelper {
  104043. /**
  104044. * Gets or sets base Assets URL
  104045. */
  104046. static BaseAssetsUrl: string;
  104047. /**
  104048. * Create a default particle system that you can tweak
  104049. * @param emitter defines the emitter to use
  104050. * @param capacity defines the system capacity (default is 500 particles)
  104051. * @param scene defines the hosting scene
  104052. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104053. * @returns the new Particle system
  104054. */
  104055. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  104056. /**
  104057. * This is the main static method (one-liner) of this helper to create different particle systems
  104058. * @param type This string represents the type to the particle system to create
  104059. * @param scene The scene where the particle system should live
  104060. * @param gpu If the system will use gpu
  104061. * @returns the ParticleSystemSet created
  104062. */
  104063. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  104064. /**
  104065. * Static function used to export a particle system to a ParticleSystemSet variable.
  104066. * Please note that the emitter shape is not exported
  104067. * @param systems defines the particle systems to export
  104068. * @returns the created particle system set
  104069. */
  104070. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  104071. }
  104072. }
  104073. declare module BABYLON {
  104074. interface Engine {
  104075. /**
  104076. * Create an effect to use with particle systems.
  104077. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  104078. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  104079. * @param uniformsNames defines a list of attribute names
  104080. * @param samplers defines an array of string used to represent textures
  104081. * @param defines defines the string containing the defines to use to compile the shaders
  104082. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104083. * @param onCompiled defines a function to call when the effect creation is successful
  104084. * @param onError defines a function to call when the effect creation has failed
  104085. * @returns the new Effect
  104086. */
  104087. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  104088. }
  104089. interface Mesh {
  104090. /**
  104091. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  104092. * @returns an array of IParticleSystem
  104093. */
  104094. getEmittedParticleSystems(): IParticleSystem[];
  104095. /**
  104096. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  104097. * @returns an array of IParticleSystem
  104098. */
  104099. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  104100. }
  104101. /**
  104102. * @hidden
  104103. */
  104104. export var _IDoNeedToBeInTheBuild: number;
  104105. }
  104106. declare module BABYLON {
  104107. interface Scene {
  104108. /** @hidden (Backing field) */
  104109. _physicsEngine: Nullable<IPhysicsEngine>;
  104110. /**
  104111. * Gets the current physics engine
  104112. * @returns a IPhysicsEngine or null if none attached
  104113. */
  104114. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  104115. /**
  104116. * Enables physics to the current scene
  104117. * @param gravity defines the scene's gravity for the physics engine
  104118. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  104119. * @return a boolean indicating if the physics engine was initialized
  104120. */
  104121. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  104122. /**
  104123. * Disables and disposes the physics engine associated with the scene
  104124. */
  104125. disablePhysicsEngine(): void;
  104126. /**
  104127. * Gets a boolean indicating if there is an active physics engine
  104128. * @returns a boolean indicating if there is an active physics engine
  104129. */
  104130. isPhysicsEnabled(): boolean;
  104131. /**
  104132. * Deletes a physics compound impostor
  104133. * @param compound defines the compound to delete
  104134. */
  104135. deleteCompoundImpostor(compound: any): void;
  104136. /**
  104137. * An event triggered when physic simulation is about to be run
  104138. */
  104139. onBeforePhysicsObservable: Observable<Scene>;
  104140. /**
  104141. * An event triggered when physic simulation has been done
  104142. */
  104143. onAfterPhysicsObservable: Observable<Scene>;
  104144. }
  104145. interface AbstractMesh {
  104146. /** @hidden */
  104147. _physicsImpostor: Nullable<PhysicsImpostor>;
  104148. /**
  104149. * Gets or sets impostor used for physic simulation
  104150. * @see http://doc.babylonjs.com/features/physics_engine
  104151. */
  104152. physicsImpostor: Nullable<PhysicsImpostor>;
  104153. /**
  104154. * Gets the current physics impostor
  104155. * @see http://doc.babylonjs.com/features/physics_engine
  104156. * @returns a physics impostor or null
  104157. */
  104158. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  104159. /** Apply a physic impulse to the mesh
  104160. * @param force defines the force to apply
  104161. * @param contactPoint defines where to apply the force
  104162. * @returns the current mesh
  104163. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104164. */
  104165. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  104166. /**
  104167. * Creates a physic joint between two meshes
  104168. * @param otherMesh defines the other mesh to use
  104169. * @param pivot1 defines the pivot to use on this mesh
  104170. * @param pivot2 defines the pivot to use on the other mesh
  104171. * @param options defines additional options (can be plugin dependent)
  104172. * @returns the current mesh
  104173. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  104174. */
  104175. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  104176. /** @hidden */
  104177. _disposePhysicsObserver: Nullable<Observer<Node>>;
  104178. }
  104179. /**
  104180. * Defines the physics engine scene component responsible to manage a physics engine
  104181. */
  104182. export class PhysicsEngineSceneComponent implements ISceneComponent {
  104183. /**
  104184. * The component name helpful to identify the component in the list of scene components.
  104185. */
  104186. readonly name: string;
  104187. /**
  104188. * The scene the component belongs to.
  104189. */
  104190. scene: Scene;
  104191. /**
  104192. * Creates a new instance of the component for the given scene
  104193. * @param scene Defines the scene to register the component in
  104194. */
  104195. constructor(scene: Scene);
  104196. /**
  104197. * Registers the component in a given scene
  104198. */
  104199. register(): void;
  104200. /**
  104201. * Rebuilds the elements related to this component in case of
  104202. * context lost for instance.
  104203. */
  104204. rebuild(): void;
  104205. /**
  104206. * Disposes the component and the associated ressources
  104207. */
  104208. dispose(): void;
  104209. }
  104210. }
  104211. declare module BABYLON {
  104212. /**
  104213. * A helper for physics simulations
  104214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104215. */
  104216. export class PhysicsHelper {
  104217. private _scene;
  104218. private _physicsEngine;
  104219. /**
  104220. * Initializes the Physics helper
  104221. * @param scene Babylon.js scene
  104222. */
  104223. constructor(scene: Scene);
  104224. /**
  104225. * Applies a radial explosion impulse
  104226. * @param origin the origin of the explosion
  104227. * @param radius the explosion radius
  104228. * @param strength the explosion strength
  104229. * @param falloff possible options: Constant & Linear. Defaults to Constant
  104230. * @returns A physics radial explosion event, or null
  104231. */
  104232. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  104233. /**
  104234. * Applies a radial explosion force
  104235. * @param origin the origin of the explosion
  104236. * @param radius the explosion radius
  104237. * @param strength the explosion strength
  104238. * @param falloff possible options: Constant & Linear. Defaults to Constant
  104239. * @returns A physics radial explosion event, or null
  104240. */
  104241. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  104242. /**
  104243. * Creates a gravitational field
  104244. * @param origin the origin of the explosion
  104245. * @param radius the explosion radius
  104246. * @param strength the explosion strength
  104247. * @param falloff possible options: Constant & Linear. Defaults to Constant
  104248. * @returns A physics gravitational field event, or null
  104249. */
  104250. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  104251. /**
  104252. * Creates a physics updraft event
  104253. * @param origin the origin of the updraft
  104254. * @param radius the radius of the updraft
  104255. * @param strength the strength of the updraft
  104256. * @param height the height of the updraft
  104257. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  104258. * @returns A physics updraft event, or null
  104259. */
  104260. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  104261. /**
  104262. * Creates a physics vortex event
  104263. * @param origin the of the vortex
  104264. * @param radius the radius of the vortex
  104265. * @param strength the strength of the vortex
  104266. * @param height the height of the vortex
  104267. * @returns a Physics vortex event, or null
  104268. * A physics vortex event or null
  104269. */
  104270. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  104271. }
  104272. /**
  104273. * Represents a physics radial explosion event
  104274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104275. */
  104276. export class PhysicsRadialExplosionEvent {
  104277. private _scene;
  104278. private _sphere;
  104279. private _sphereOptions;
  104280. private _rays;
  104281. private _dataFetched;
  104282. /**
  104283. * Initializes a radial explosioin event
  104284. * @param scene BabylonJS scene
  104285. */
  104286. constructor(scene: Scene);
  104287. /**
  104288. * Returns the data related to the radial explosion event (sphere & rays).
  104289. * @returns The radial explosion event data
  104290. */
  104291. getData(): PhysicsRadialExplosionEventData;
  104292. /**
  104293. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  104294. * @param impostor A physics imposter
  104295. * @param origin the origin of the explosion
  104296. * @param radius the explosion radius
  104297. * @param strength the explosion strength
  104298. * @param falloff possible options: Constant & Linear
  104299. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  104300. */
  104301. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  104302. /**
  104303. * Disposes the sphere.
  104304. * @param force Specifies if the sphere should be disposed by force
  104305. */
  104306. dispose(force?: boolean): void;
  104307. /*** Helpers ***/
  104308. private _prepareSphere;
  104309. private _intersectsWithSphere;
  104310. }
  104311. /**
  104312. * Represents a gravitational field event
  104313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104314. */
  104315. export class PhysicsGravitationalFieldEvent {
  104316. private _physicsHelper;
  104317. private _scene;
  104318. private _origin;
  104319. private _radius;
  104320. private _strength;
  104321. private _falloff;
  104322. private _tickCallback;
  104323. private _sphere;
  104324. private _dataFetched;
  104325. /**
  104326. * Initializes the physics gravitational field event
  104327. * @param physicsHelper A physics helper
  104328. * @param scene BabylonJS scene
  104329. * @param origin The origin position of the gravitational field event
  104330. * @param radius The radius of the gravitational field event
  104331. * @param strength The strength of the gravitational field event
  104332. * @param falloff The falloff for the gravitational field event
  104333. */
  104334. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  104335. /**
  104336. * Returns the data related to the gravitational field event (sphere).
  104337. * @returns A gravitational field event
  104338. */
  104339. getData(): PhysicsGravitationalFieldEventData;
  104340. /**
  104341. * Enables the gravitational field.
  104342. */
  104343. enable(): void;
  104344. /**
  104345. * Disables the gravitational field.
  104346. */
  104347. disable(): void;
  104348. /**
  104349. * Disposes the sphere.
  104350. * @param force The force to dispose from the gravitational field event
  104351. */
  104352. dispose(force?: boolean): void;
  104353. private _tick;
  104354. }
  104355. /**
  104356. * Represents a physics updraft event
  104357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104358. */
  104359. export class PhysicsUpdraftEvent {
  104360. private _scene;
  104361. private _origin;
  104362. private _radius;
  104363. private _strength;
  104364. private _height;
  104365. private _updraftMode;
  104366. private _physicsEngine;
  104367. private _originTop;
  104368. private _originDirection;
  104369. private _tickCallback;
  104370. private _cylinder;
  104371. private _cylinderPosition;
  104372. private _dataFetched;
  104373. /**
  104374. * Initializes the physics updraft event
  104375. * @param _scene BabylonJS scene
  104376. * @param _origin The origin position of the updraft
  104377. * @param _radius The radius of the updraft
  104378. * @param _strength The strength of the updraft
  104379. * @param _height The height of the updraft
  104380. * @param _updraftMode The mode of the updraft
  104381. */
  104382. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  104383. /**
  104384. * Returns the data related to the updraft event (cylinder).
  104385. * @returns A physics updraft event
  104386. */
  104387. getData(): PhysicsUpdraftEventData;
  104388. /**
  104389. * Enables the updraft.
  104390. */
  104391. enable(): void;
  104392. /**
  104393. * Disables the cortex.
  104394. */
  104395. disable(): void;
  104396. /**
  104397. * Disposes the sphere.
  104398. * @param force Specifies if the updraft should be disposed by force
  104399. */
  104400. dispose(force?: boolean): void;
  104401. private getImpostorForceAndContactPoint;
  104402. private _tick;
  104403. /*** Helpers ***/
  104404. private _prepareCylinder;
  104405. private _intersectsWithCylinder;
  104406. }
  104407. /**
  104408. * Represents a physics vortex event
  104409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104410. */
  104411. export class PhysicsVortexEvent {
  104412. private _scene;
  104413. private _origin;
  104414. private _radius;
  104415. private _strength;
  104416. private _height;
  104417. private _physicsEngine;
  104418. private _originTop;
  104419. private _centripetalForceThreshold;
  104420. private _updraftMultiplier;
  104421. private _tickCallback;
  104422. private _cylinder;
  104423. private _cylinderPosition;
  104424. private _dataFetched;
  104425. /**
  104426. * Initializes the physics vortex event
  104427. * @param _scene The BabylonJS scene
  104428. * @param _origin The origin position of the vortex
  104429. * @param _radius The radius of the vortex
  104430. * @param _strength The strength of the vortex
  104431. * @param _height The height of the vortex
  104432. */
  104433. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  104434. /**
  104435. * Returns the data related to the vortex event (cylinder).
  104436. * @returns The physics vortex event data
  104437. */
  104438. getData(): PhysicsVortexEventData;
  104439. /**
  104440. * Enables the vortex.
  104441. */
  104442. enable(): void;
  104443. /**
  104444. * Disables the cortex.
  104445. */
  104446. disable(): void;
  104447. /**
  104448. * Disposes the sphere.
  104449. * @param force
  104450. */
  104451. dispose(force?: boolean): void;
  104452. private getImpostorForceAndContactPoint;
  104453. private _tick;
  104454. /*** Helpers ***/
  104455. private _prepareCylinder;
  104456. private _intersectsWithCylinder;
  104457. }
  104458. /**
  104459. * The strenght of the force in correspondence to the distance of the affected object
  104460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104461. */
  104462. export enum PhysicsRadialImpulseFalloff {
  104463. /** Defines that impulse is constant in strength across it's whole radius */
  104464. Constant = 0,
  104465. /** DEfines that impulse gets weaker if it's further from the origin */
  104466. Linear = 1
  104467. }
  104468. /**
  104469. * The strength of the force in correspondence to the distance of the affected object
  104470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104471. */
  104472. export enum PhysicsUpdraftMode {
  104473. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  104474. Center = 0,
  104475. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  104476. Perpendicular = 1
  104477. }
  104478. /**
  104479. * Interface for a physics force and contact point
  104480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104481. */
  104482. export interface PhysicsForceAndContactPoint {
  104483. /**
  104484. * The force applied at the contact point
  104485. */
  104486. force: Vector3;
  104487. /**
  104488. * The contact point
  104489. */
  104490. contactPoint: Vector3;
  104491. }
  104492. /**
  104493. * Interface for radial explosion event data
  104494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104495. */
  104496. export interface PhysicsRadialExplosionEventData {
  104497. /**
  104498. * A sphere used for the radial explosion event
  104499. */
  104500. sphere: Mesh;
  104501. /**
  104502. * An array of rays for the radial explosion event
  104503. */
  104504. rays: Array<Ray>;
  104505. }
  104506. /**
  104507. * Interface for gravitational field event data
  104508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104509. */
  104510. export interface PhysicsGravitationalFieldEventData {
  104511. /**
  104512. * A sphere mesh used for the gravitational field event
  104513. */
  104514. sphere: Mesh;
  104515. }
  104516. /**
  104517. * Interface for updraft event data
  104518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104519. */
  104520. export interface PhysicsUpdraftEventData {
  104521. /**
  104522. * A cylinder used for the updraft event
  104523. */
  104524. cylinder: Mesh;
  104525. }
  104526. /**
  104527. * Interface for vortex event data
  104528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104529. */
  104530. export interface PhysicsVortexEventData {
  104531. /**
  104532. * A cylinder used for the vortex event
  104533. */
  104534. cylinder: Mesh;
  104535. }
  104536. }
  104537. declare module BABYLON {
  104538. /**
  104539. * AmmoJS Physics plugin
  104540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104541. * @see https://github.com/kripken/ammo.js/
  104542. */
  104543. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  104544. private _useDeltaForWorldStep;
  104545. /**
  104546. * Reference to the Ammo library
  104547. */
  104548. bjsAMMO: any;
  104549. /**
  104550. * Created ammoJS world which physics bodies are added to
  104551. */
  104552. world: any;
  104553. /**
  104554. * Name of the plugin
  104555. */
  104556. name: string;
  104557. private _timeStep;
  104558. private _fixedTimeStep;
  104559. private _maxSteps;
  104560. private _tmpQuaternion;
  104561. private _tmpAmmoTransform;
  104562. private _tmpAmmoQuaternion;
  104563. private _tmpAmmoConcreteContactResultCallback;
  104564. private _collisionConfiguration;
  104565. private _dispatcher;
  104566. private _overlappingPairCache;
  104567. private _solver;
  104568. private _tmpAmmoVectorA;
  104569. private _tmpAmmoVectorB;
  104570. private _tmpAmmoVectorC;
  104571. private _tmpContactCallbackResult;
  104572. private static readonly DISABLE_COLLISION_FLAG;
  104573. private static readonly KINEMATIC_FLAG;
  104574. private static readonly DISABLE_DEACTIVATION_FLAG;
  104575. /**
  104576. * Initializes the ammoJS plugin
  104577. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  104578. * @param ammoInjection can be used to inject your own ammo reference
  104579. */
  104580. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  104581. /**
  104582. * Sets the gravity of the physics world (m/(s^2))
  104583. * @param gravity Gravity to set
  104584. */
  104585. setGravity(gravity: Vector3): void;
  104586. /**
  104587. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  104588. * @param timeStep timestep to use in seconds
  104589. */
  104590. setTimeStep(timeStep: number): void;
  104591. /**
  104592. * 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)
  104593. * @param fixedTimeStep fixedTimeStep to use in seconds
  104594. */
  104595. setFixedTimeStep(fixedTimeStep: number): void;
  104596. /**
  104597. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  104598. * @param maxSteps the maximum number of steps by the physics engine per frame
  104599. */
  104600. setMaxSteps(maxSteps: number): void;
  104601. /**
  104602. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  104603. * @returns the current timestep in seconds
  104604. */
  104605. getTimeStep(): number;
  104606. private _isImpostorInContact;
  104607. private _isImpostorPairInContact;
  104608. private _stepSimulation;
  104609. /**
  104610. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  104611. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  104612. * After the step the babylon meshes are set to the position of the physics imposters
  104613. * @param delta amount of time to step forward
  104614. * @param impostors array of imposters to update before/after the step
  104615. */
  104616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104617. private _tmpVector;
  104618. private _tmpMatrix;
  104619. /**
  104620. * Applies an implulse on the imposter
  104621. * @param impostor imposter to apply impulse
  104622. * @param force amount of force to be applied to the imposter
  104623. * @param contactPoint the location to apply the impulse on the imposter
  104624. */
  104625. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104626. /**
  104627. * Applies a force on the imposter
  104628. * @param impostor imposter to apply force
  104629. * @param force amount of force to be applied to the imposter
  104630. * @param contactPoint the location to apply the force on the imposter
  104631. */
  104632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104633. /**
  104634. * Creates a physics body using the plugin
  104635. * @param impostor the imposter to create the physics body on
  104636. */
  104637. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104638. /**
  104639. * Removes the physics body from the imposter and disposes of the body's memory
  104640. * @param impostor imposter to remove the physics body from
  104641. */
  104642. removePhysicsBody(impostor: PhysicsImpostor): void;
  104643. /**
  104644. * Generates a joint
  104645. * @param impostorJoint the imposter joint to create the joint with
  104646. */
  104647. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104648. /**
  104649. * Removes a joint
  104650. * @param impostorJoint the imposter joint to remove the joint from
  104651. */
  104652. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104653. private _addMeshVerts;
  104654. private _createShape;
  104655. /**
  104656. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  104657. * @param impostor imposter containing the physics body and babylon object
  104658. */
  104659. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104660. /**
  104661. * Sets the babylon object's position/rotation from the physics body's position/rotation
  104662. * @param impostor imposter containing the physics body and babylon object
  104663. * @param newPosition new position
  104664. * @param newRotation new rotation
  104665. */
  104666. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104667. /**
  104668. * If this plugin is supported
  104669. * @returns true if its supported
  104670. */
  104671. isSupported(): boolean;
  104672. /**
  104673. * Sets the linear velocity of the physics body
  104674. * @param impostor imposter to set the velocity on
  104675. * @param velocity velocity to set
  104676. */
  104677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104678. /**
  104679. * Sets the angular velocity of the physics body
  104680. * @param impostor imposter to set the velocity on
  104681. * @param velocity velocity to set
  104682. */
  104683. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104684. /**
  104685. * gets the linear velocity
  104686. * @param impostor imposter to get linear velocity from
  104687. * @returns linear velocity
  104688. */
  104689. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104690. /**
  104691. * gets the angular velocity
  104692. * @param impostor imposter to get angular velocity from
  104693. * @returns angular velocity
  104694. */
  104695. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104696. /**
  104697. * Sets the mass of physics body
  104698. * @param impostor imposter to set the mass on
  104699. * @param mass mass to set
  104700. */
  104701. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104702. /**
  104703. * Gets the mass of the physics body
  104704. * @param impostor imposter to get the mass from
  104705. * @returns mass
  104706. */
  104707. getBodyMass(impostor: PhysicsImpostor): number;
  104708. /**
  104709. * Gets friction of the impostor
  104710. * @param impostor impostor to get friction from
  104711. * @returns friction value
  104712. */
  104713. getBodyFriction(impostor: PhysicsImpostor): number;
  104714. /**
  104715. * Sets friction of the impostor
  104716. * @param impostor impostor to set friction on
  104717. * @param friction friction value
  104718. */
  104719. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104720. /**
  104721. * Gets restitution of the impostor
  104722. * @param impostor impostor to get restitution from
  104723. * @returns restitution value
  104724. */
  104725. getBodyRestitution(impostor: PhysicsImpostor): number;
  104726. /**
  104727. * Sets resitution of the impostor
  104728. * @param impostor impostor to set resitution on
  104729. * @param restitution resitution value
  104730. */
  104731. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104732. /**
  104733. * Sleeps the physics body and stops it from being active
  104734. * @param impostor impostor to sleep
  104735. */
  104736. sleepBody(impostor: PhysicsImpostor): void;
  104737. /**
  104738. * Activates the physics body
  104739. * @param impostor impostor to activate
  104740. */
  104741. wakeUpBody(impostor: PhysicsImpostor): void;
  104742. /**
  104743. * Updates the distance parameters of the joint
  104744. * @param joint joint to update
  104745. * @param maxDistance maximum distance of the joint
  104746. * @param minDistance minimum distance of the joint
  104747. */
  104748. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104749. /**
  104750. * Sets a motor on the joint
  104751. * @param joint joint to set motor on
  104752. * @param speed speed of the motor
  104753. * @param maxForce maximum force of the motor
  104754. * @param motorIndex index of the motor
  104755. */
  104756. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104757. /**
  104758. * Sets the motors limit
  104759. * @param joint joint to set limit on
  104760. * @param upperLimit upper limit
  104761. * @param lowerLimit lower limit
  104762. */
  104763. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104764. /**
  104765. * Syncs the position and rotation of a mesh with the impostor
  104766. * @param mesh mesh to sync
  104767. * @param impostor impostor to update the mesh with
  104768. */
  104769. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104770. /**
  104771. * Gets the radius of the impostor
  104772. * @param impostor impostor to get radius from
  104773. * @returns the radius
  104774. */
  104775. getRadius(impostor: PhysicsImpostor): number;
  104776. /**
  104777. * Gets the box size of the impostor
  104778. * @param impostor impostor to get box size from
  104779. * @param result the resulting box size
  104780. */
  104781. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104782. /**
  104783. * Disposes of the impostor
  104784. */
  104785. dispose(): void;
  104786. }
  104787. }
  104788. declare module BABYLON {
  104789. /** @hidden */
  104790. export var blackAndWhitePixelShader: {
  104791. name: string;
  104792. shader: string;
  104793. };
  104794. }
  104795. declare module BABYLON {
  104796. /**
  104797. * Post process used to render in black and white
  104798. */
  104799. export class BlackAndWhitePostProcess extends PostProcess {
  104800. /**
  104801. * Linear about to convert he result to black and white (default: 1)
  104802. */
  104803. degree: number;
  104804. /**
  104805. * Creates a black and white post process
  104806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  104807. * @param name The name of the effect.
  104808. * @param options The required width/height ratio to downsize to before computing the render pass.
  104809. * @param camera The camera to apply the render pass to.
  104810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104811. * @param engine The engine which the post process will be applied. (default: current engine)
  104812. * @param reusable If the post process can be reused on the same frame. (default: false)
  104813. */
  104814. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104815. }
  104816. }
  104817. declare module BABYLON {
  104818. /**
  104819. * This represents a set of one or more post processes in Babylon.
  104820. * A post process can be used to apply a shader to a texture after it is rendered.
  104821. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  104822. */
  104823. export class PostProcessRenderEffect {
  104824. private _postProcesses;
  104825. private _getPostProcesses;
  104826. private _singleInstance;
  104827. private _cameras;
  104828. private _indicesForCamera;
  104829. /**
  104830. * Name of the effect
  104831. * @hidden
  104832. */
  104833. _name: string;
  104834. /**
  104835. * Instantiates a post process render effect.
  104836. * A post process can be used to apply a shader to a texture after it is rendered.
  104837. * @param engine The engine the effect is tied to
  104838. * @param name The name of the effect
  104839. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  104840. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  104841. */
  104842. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  104843. /**
  104844. * Checks if all the post processes in the effect are supported.
  104845. */
  104846. readonly isSupported: boolean;
  104847. /**
  104848. * Updates the current state of the effect
  104849. * @hidden
  104850. */
  104851. _update(): void;
  104852. /**
  104853. * Attaches the effect on cameras
  104854. * @param cameras The camera to attach to.
  104855. * @hidden
  104856. */
  104857. _attachCameras(cameras: Camera): void;
  104858. /**
  104859. * Attaches the effect on cameras
  104860. * @param cameras The camera to attach to.
  104861. * @hidden
  104862. */
  104863. _attachCameras(cameras: Camera[]): void;
  104864. /**
  104865. * Detatches the effect on cameras
  104866. * @param cameras The camera to detatch from.
  104867. * @hidden
  104868. */
  104869. _detachCameras(cameras: Camera): void;
  104870. /**
  104871. * Detatches the effect on cameras
  104872. * @param cameras The camera to detatch from.
  104873. * @hidden
  104874. */
  104875. _detachCameras(cameras: Camera[]): void;
  104876. /**
  104877. * Enables the effect on given cameras
  104878. * @param cameras The camera to enable.
  104879. * @hidden
  104880. */
  104881. _enable(cameras: Camera): void;
  104882. /**
  104883. * Enables the effect on given cameras
  104884. * @param cameras The camera to enable.
  104885. * @hidden
  104886. */
  104887. _enable(cameras: Nullable<Camera[]>): void;
  104888. /**
  104889. * Disables the effect on the given cameras
  104890. * @param cameras The camera to disable.
  104891. * @hidden
  104892. */
  104893. _disable(cameras: Camera): void;
  104894. /**
  104895. * Disables the effect on the given cameras
  104896. * @param cameras The camera to disable.
  104897. * @hidden
  104898. */
  104899. _disable(cameras: Nullable<Camera[]>): void;
  104900. /**
  104901. * Gets a list of the post processes contained in the effect.
  104902. * @param camera The camera to get the post processes on.
  104903. * @returns The list of the post processes in the effect.
  104904. */
  104905. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  104906. }
  104907. }
  104908. declare module BABYLON {
  104909. /** @hidden */
  104910. export var extractHighlightsPixelShader: {
  104911. name: string;
  104912. shader: string;
  104913. };
  104914. }
  104915. declare module BABYLON {
  104916. /**
  104917. * 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.
  104918. */
  104919. export class ExtractHighlightsPostProcess extends PostProcess {
  104920. /**
  104921. * The luminance threshold, pixels below this value will be set to black.
  104922. */
  104923. threshold: number;
  104924. /** @hidden */
  104925. _exposure: number;
  104926. /**
  104927. * Post process which has the input texture to be used when performing highlight extraction
  104928. * @hidden
  104929. */
  104930. _inputPostProcess: Nullable<PostProcess>;
  104931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104932. }
  104933. }
  104934. declare module BABYLON {
  104935. /** @hidden */
  104936. export var bloomMergePixelShader: {
  104937. name: string;
  104938. shader: string;
  104939. };
  104940. }
  104941. declare module BABYLON {
  104942. /**
  104943. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  104944. */
  104945. export class BloomMergePostProcess extends PostProcess {
  104946. /** Weight of the bloom to be added to the original input. */
  104947. weight: number;
  104948. /**
  104949. * Creates a new instance of @see BloomMergePostProcess
  104950. * @param name The name of the effect.
  104951. * @param originalFromInput Post process which's input will be used for the merge.
  104952. * @param blurred Blurred highlights post process which's output will be used.
  104953. * @param weight Weight of the bloom to be added to the original input.
  104954. * @param options The required width/height ratio to downsize to before computing the render pass.
  104955. * @param camera The camera to apply the render pass to.
  104956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104957. * @param engine The engine which the post process will be applied. (default: current engine)
  104958. * @param reusable If the post process can be reused on the same frame. (default: false)
  104959. * @param textureType Type of textures used when performing the post process. (default: 0)
  104960. * @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)
  104961. */
  104962. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  104963. /** Weight of the bloom to be added to the original input. */
  104964. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104965. }
  104966. }
  104967. declare module BABYLON {
  104968. /**
  104969. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  104970. */
  104971. export class BloomEffect extends PostProcessRenderEffect {
  104972. private bloomScale;
  104973. /**
  104974. * @hidden Internal
  104975. */
  104976. _effects: Array<PostProcess>;
  104977. /**
  104978. * @hidden Internal
  104979. */
  104980. _downscale: ExtractHighlightsPostProcess;
  104981. private _blurX;
  104982. private _blurY;
  104983. private _merge;
  104984. /**
  104985. * The luminance threshold to find bright areas of the image to bloom.
  104986. */
  104987. threshold: number;
  104988. /**
  104989. * The strength of the bloom.
  104990. */
  104991. weight: number;
  104992. /**
  104993. * Specifies the size of the bloom blur kernel, relative to the final output size
  104994. */
  104995. kernel: number;
  104996. /**
  104997. * Creates a new instance of @see BloomEffect
  104998. * @param scene The scene the effect belongs to.
  104999. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105000. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105001. * @param bloomWeight The the strength of bloom.
  105002. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105003. * @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)
  105004. */
  105005. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105006. /**
  105007. * Disposes each of the internal effects for a given camera.
  105008. * @param camera The camera to dispose the effect on.
  105009. */
  105010. disposeEffects(camera: Camera): void;
  105011. /**
  105012. * @hidden Internal
  105013. */
  105014. _updateEffects(): void;
  105015. /**
  105016. * Internal
  105017. * @returns if all the contained post processes are ready.
  105018. * @hidden
  105019. */
  105020. _isReady(): boolean;
  105021. }
  105022. }
  105023. declare module BABYLON {
  105024. /** @hidden */
  105025. export var chromaticAberrationPixelShader: {
  105026. name: string;
  105027. shader: string;
  105028. };
  105029. }
  105030. declare module BABYLON {
  105031. /**
  105032. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105033. */
  105034. export class ChromaticAberrationPostProcess extends PostProcess {
  105035. /**
  105036. * The amount of seperation of rgb channels (default: 30)
  105037. */
  105038. aberrationAmount: number;
  105039. /**
  105040. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  105041. */
  105042. radialIntensity: number;
  105043. /**
  105044. * 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))
  105045. */
  105046. direction: Vector2;
  105047. /**
  105048. * 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))
  105049. */
  105050. centerPosition: Vector2;
  105051. /**
  105052. * Creates a new instance ChromaticAberrationPostProcess
  105053. * @param name The name of the effect.
  105054. * @param screenWidth The width of the screen to apply the effect on.
  105055. * @param screenHeight The height of the screen to apply the effect on.
  105056. * @param options The required width/height ratio to downsize to before computing the render pass.
  105057. * @param camera The camera to apply the render pass to.
  105058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105059. * @param engine The engine which the post process will be applied. (default: current engine)
  105060. * @param reusable If the post process can be reused on the same frame. (default: false)
  105061. * @param textureType Type of textures used when performing the post process. (default: 0)
  105062. * @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)
  105063. */
  105064. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105065. }
  105066. }
  105067. declare module BABYLON {
  105068. /** @hidden */
  105069. export var circleOfConfusionPixelShader: {
  105070. name: string;
  105071. shader: string;
  105072. };
  105073. }
  105074. declare module BABYLON {
  105075. /**
  105076. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  105077. */
  105078. export class CircleOfConfusionPostProcess extends PostProcess {
  105079. /**
  105080. * 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.
  105081. */
  105082. lensSize: number;
  105083. /**
  105084. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105085. */
  105086. fStop: number;
  105087. /**
  105088. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105089. */
  105090. focusDistance: number;
  105091. /**
  105092. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  105093. */
  105094. focalLength: number;
  105095. private _depthTexture;
  105096. /**
  105097. * Creates a new instance CircleOfConfusionPostProcess
  105098. * @param name The name of the effect.
  105099. * @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.
  105100. * @param options The required width/height ratio to downsize to before computing the render pass.
  105101. * @param camera The camera to apply the render pass to.
  105102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105103. * @param engine The engine which the post process will be applied. (default: current engine)
  105104. * @param reusable If the post process can be reused on the same frame. (default: false)
  105105. * @param textureType Type of textures used when performing the post process. (default: 0)
  105106. * @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)
  105107. */
  105108. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105109. /**
  105110. * 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.
  105111. */
  105112. depthTexture: RenderTargetTexture;
  105113. }
  105114. }
  105115. declare module BABYLON {
  105116. /** @hidden */
  105117. export var colorCorrectionPixelShader: {
  105118. name: string;
  105119. shader: string;
  105120. };
  105121. }
  105122. declare module BABYLON {
  105123. /**
  105124. *
  105125. * This post-process allows the modification of rendered colors by using
  105126. * a 'look-up table' (LUT). This effect is also called Color Grading.
  105127. *
  105128. * The object needs to be provided an url to a texture containing the color
  105129. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  105130. * Use an image editing software to tweak the LUT to match your needs.
  105131. *
  105132. * For an example of a color LUT, see here:
  105133. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  105134. * For explanations on color grading, see here:
  105135. * @see http://udn.epicgames.com/Three/ColorGrading.html
  105136. *
  105137. */
  105138. export class ColorCorrectionPostProcess extends PostProcess {
  105139. private _colorTableTexture;
  105140. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105141. }
  105142. }
  105143. declare module BABYLON {
  105144. /** @hidden */
  105145. export var convolutionPixelShader: {
  105146. name: string;
  105147. shader: string;
  105148. };
  105149. }
  105150. declare module BABYLON {
  105151. /**
  105152. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  105153. * input texture to perform effects such as edge detection or sharpening
  105154. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  105155. */
  105156. export class ConvolutionPostProcess extends PostProcess {
  105157. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105158. kernel: number[];
  105159. /**
  105160. * Creates a new instance ConvolutionPostProcess
  105161. * @param name The name of the effect.
  105162. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  105163. * @param options The required width/height ratio to downsize to before computing the render pass.
  105164. * @param camera The camera to apply the render pass to.
  105165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105166. * @param engine The engine which the post process will be applied. (default: current engine)
  105167. * @param reusable If the post process can be reused on the same frame. (default: false)
  105168. * @param textureType Type of textures used when performing the post process. (default: 0)
  105169. */
  105170. constructor(name: string,
  105171. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105172. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  105173. /**
  105174. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105175. */
  105176. static EdgeDetect0Kernel: number[];
  105177. /**
  105178. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105179. */
  105180. static EdgeDetect1Kernel: number[];
  105181. /**
  105182. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105183. */
  105184. static EdgeDetect2Kernel: number[];
  105185. /**
  105186. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105187. */
  105188. static SharpenKernel: number[];
  105189. /**
  105190. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105191. */
  105192. static EmbossKernel: number[];
  105193. /**
  105194. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105195. */
  105196. static GaussianKernel: number[];
  105197. }
  105198. }
  105199. declare module BABYLON {
  105200. /**
  105201. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  105202. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  105203. * based on samples that have a large difference in distance than the center pixel.
  105204. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  105205. */
  105206. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  105207. direction: Vector2;
  105208. /**
  105209. * Creates a new instance CircleOfConfusionPostProcess
  105210. * @param name The name of the effect.
  105211. * @param scene The scene the effect belongs to.
  105212. * @param direction The direction the blur should be applied.
  105213. * @param kernel The size of the kernel used to blur.
  105214. * @param options The required width/height ratio to downsize to before computing the render pass.
  105215. * @param camera The camera to apply the render pass to.
  105216. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  105217. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  105218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105219. * @param engine The engine which the post process will be applied. (default: current engine)
  105220. * @param reusable If the post process can be reused on the same frame. (default: false)
  105221. * @param textureType Type of textures used when performing the post process. (default: 0)
  105222. * @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)
  105223. */
  105224. 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);
  105225. }
  105226. }
  105227. declare module BABYLON {
  105228. /** @hidden */
  105229. export var depthOfFieldMergePixelShader: {
  105230. name: string;
  105231. shader: string;
  105232. };
  105233. }
  105234. declare module BABYLON {
  105235. /**
  105236. * Options to be set when merging outputs from the default pipeline.
  105237. */
  105238. export class DepthOfFieldMergePostProcessOptions {
  105239. /**
  105240. * The original image to merge on top of
  105241. */
  105242. originalFromInput: PostProcess;
  105243. /**
  105244. * Parameters to perform the merge of the depth of field effect
  105245. */
  105246. depthOfField?: {
  105247. circleOfConfusion: PostProcess;
  105248. blurSteps: Array<PostProcess>;
  105249. };
  105250. /**
  105251. * Parameters to perform the merge of bloom effect
  105252. */
  105253. bloom?: {
  105254. blurred: PostProcess;
  105255. weight: number;
  105256. };
  105257. }
  105258. /**
  105259. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105260. */
  105261. export class DepthOfFieldMergePostProcess extends PostProcess {
  105262. private blurSteps;
  105263. /**
  105264. * Creates a new instance of DepthOfFieldMergePostProcess
  105265. * @param name The name of the effect.
  105266. * @param originalFromInput Post process which's input will be used for the merge.
  105267. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  105268. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  105269. * @param options The required width/height ratio to downsize to before computing the render pass.
  105270. * @param camera The camera to apply the render pass to.
  105271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105272. * @param engine The engine which the post process will be applied. (default: current engine)
  105273. * @param reusable If the post process can be reused on the same frame. (default: false)
  105274. * @param textureType Type of textures used when performing the post process. (default: 0)
  105275. * @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)
  105276. */
  105277. 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);
  105278. /**
  105279. * Updates the effect with the current post process compile time values and recompiles the shader.
  105280. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  105281. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  105282. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  105283. * @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
  105284. * @param onCompiled Called when the shader has been compiled.
  105285. * @param onError Called if there is an error when compiling a shader.
  105286. */
  105287. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  105288. }
  105289. }
  105290. declare module BABYLON {
  105291. /**
  105292. * Specifies the level of max blur that should be applied when using the depth of field effect
  105293. */
  105294. export enum DepthOfFieldEffectBlurLevel {
  105295. /**
  105296. * Subtle blur
  105297. */
  105298. Low = 0,
  105299. /**
  105300. * Medium blur
  105301. */
  105302. Medium = 1,
  105303. /**
  105304. * Large blur
  105305. */
  105306. High = 2
  105307. }
  105308. /**
  105309. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  105310. */
  105311. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  105312. private _circleOfConfusion;
  105313. /**
  105314. * @hidden Internal, blurs from high to low
  105315. */
  105316. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  105317. private _depthOfFieldBlurY;
  105318. private _dofMerge;
  105319. /**
  105320. * @hidden Internal post processes in depth of field effect
  105321. */
  105322. _effects: Array<PostProcess>;
  105323. /**
  105324. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  105325. */
  105326. focalLength: number;
  105327. /**
  105328. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105329. */
  105330. fStop: number;
  105331. /**
  105332. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105333. */
  105334. focusDistance: number;
  105335. /**
  105336. * 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.
  105337. */
  105338. lensSize: number;
  105339. /**
  105340. * Creates a new instance DepthOfFieldEffect
  105341. * @param scene The scene the effect belongs to.
  105342. * @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.
  105343. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105344. * @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)
  105345. */
  105346. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  105347. /**
  105348. * 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.
  105349. */
  105350. depthTexture: RenderTargetTexture;
  105351. /**
  105352. * Disposes each of the internal effects for a given camera.
  105353. * @param camera The camera to dispose the effect on.
  105354. */
  105355. disposeEffects(camera: Camera): void;
  105356. /**
  105357. * @hidden Internal
  105358. */
  105359. _updateEffects(): void;
  105360. /**
  105361. * Internal
  105362. * @returns if all the contained post processes are ready.
  105363. * @hidden
  105364. */
  105365. _isReady(): boolean;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /** @hidden */
  105370. export var displayPassPixelShader: {
  105371. name: string;
  105372. shader: string;
  105373. };
  105374. }
  105375. declare module BABYLON {
  105376. /**
  105377. * DisplayPassPostProcess which produces an output the same as it's input
  105378. */
  105379. export class DisplayPassPostProcess extends PostProcess {
  105380. /**
  105381. * Creates the DisplayPassPostProcess
  105382. * @param name The name of the effect.
  105383. * @param options The required width/height ratio to downsize to before computing the render pass.
  105384. * @param camera The camera to apply the render pass to.
  105385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105386. * @param engine The engine which the post process will be applied. (default: current engine)
  105387. * @param reusable If the post process can be reused on the same frame. (default: false)
  105388. */
  105389. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105390. }
  105391. }
  105392. declare module BABYLON {
  105393. /** @hidden */
  105394. export var filterPixelShader: {
  105395. name: string;
  105396. shader: string;
  105397. };
  105398. }
  105399. declare module BABYLON {
  105400. /**
  105401. * Applies a kernel filter to the image
  105402. */
  105403. export class FilterPostProcess extends PostProcess {
  105404. /** The matrix to be applied to the image */
  105405. kernelMatrix: Matrix;
  105406. /**
  105407. *
  105408. * @param name The name of the effect.
  105409. * @param kernelMatrix The matrix to be applied to the image
  105410. * @param options The required width/height ratio to downsize to before computing the render pass.
  105411. * @param camera The camera to apply the render pass to.
  105412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105413. * @param engine The engine which the post process will be applied. (default: current engine)
  105414. * @param reusable If the post process can be reused on the same frame. (default: false)
  105415. */
  105416. constructor(name: string,
  105417. /** The matrix to be applied to the image */
  105418. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105419. }
  105420. }
  105421. declare module BABYLON {
  105422. /** @hidden */
  105423. export var fxaaPixelShader: {
  105424. name: string;
  105425. shader: string;
  105426. };
  105427. }
  105428. declare module BABYLON {
  105429. /** @hidden */
  105430. export var fxaaVertexShader: {
  105431. name: string;
  105432. shader: string;
  105433. };
  105434. }
  105435. declare module BABYLON {
  105436. /**
  105437. * Fxaa post process
  105438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  105439. */
  105440. export class FxaaPostProcess extends PostProcess {
  105441. /** @hidden */
  105442. texelWidth: number;
  105443. /** @hidden */
  105444. texelHeight: number;
  105445. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  105446. private _getDefines;
  105447. }
  105448. }
  105449. declare module BABYLON {
  105450. /** @hidden */
  105451. export var grainPixelShader: {
  105452. name: string;
  105453. shader: string;
  105454. };
  105455. }
  105456. declare module BABYLON {
  105457. /**
  105458. * The GrainPostProcess adds noise to the image at mid luminance levels
  105459. */
  105460. export class GrainPostProcess extends PostProcess {
  105461. /**
  105462. * The intensity of the grain added (default: 30)
  105463. */
  105464. intensity: number;
  105465. /**
  105466. * If the grain should be randomized on every frame
  105467. */
  105468. animated: boolean;
  105469. /**
  105470. * Creates a new instance of @see GrainPostProcess
  105471. * @param name The name of the effect.
  105472. * @param options The required width/height ratio to downsize to before computing the render pass.
  105473. * @param camera The camera to apply the render pass to.
  105474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105475. * @param engine The engine which the post process will be applied. (default: current engine)
  105476. * @param reusable If the post process can be reused on the same frame. (default: false)
  105477. * @param textureType Type of textures used when performing the post process. (default: 0)
  105478. * @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)
  105479. */
  105480. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105481. }
  105482. }
  105483. declare module BABYLON {
  105484. /** @hidden */
  105485. export var highlightsPixelShader: {
  105486. name: string;
  105487. shader: string;
  105488. };
  105489. }
  105490. declare module BABYLON {
  105491. /**
  105492. * Extracts highlights from the image
  105493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  105494. */
  105495. export class HighlightsPostProcess extends PostProcess {
  105496. /**
  105497. * Extracts highlights from the image
  105498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  105499. * @param name The name of the effect.
  105500. * @param options The required width/height ratio to downsize to before computing the render pass.
  105501. * @param camera The camera to apply the render pass to.
  105502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105503. * @param engine The engine which the post process will be applied. (default: current engine)
  105504. * @param reusable If the post process can be reused on the same frame. (default: false)
  105505. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  105506. */
  105507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  105508. }
  105509. }
  105510. declare module BABYLON {
  105511. /** @hidden */
  105512. export var mrtFragmentDeclaration: {
  105513. name: string;
  105514. shader: string;
  105515. };
  105516. }
  105517. declare module BABYLON {
  105518. /** @hidden */
  105519. export var geometryPixelShader: {
  105520. name: string;
  105521. shader: string;
  105522. };
  105523. }
  105524. declare module BABYLON {
  105525. /** @hidden */
  105526. export var geometryVertexShader: {
  105527. name: string;
  105528. shader: string;
  105529. };
  105530. }
  105531. declare module BABYLON {
  105532. /**
  105533. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  105534. */
  105535. export class GeometryBufferRenderer {
  105536. /**
  105537. * Constant used to retrieve the position texture index in the G-Buffer textures array
  105538. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  105539. */
  105540. static readonly POSITION_TEXTURE_TYPE: number;
  105541. /**
  105542. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  105543. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  105544. */
  105545. static readonly VELOCITY_TEXTURE_TYPE: number;
  105546. /**
  105547. * Dictionary used to store the previous transformation matrices of each rendered mesh
  105548. * in order to compute objects velocities when enableVelocity is set to "true"
  105549. * @hidden
  105550. */
  105551. _previousTransformationMatrices: {
  105552. [index: number]: Matrix;
  105553. };
  105554. private _scene;
  105555. private _multiRenderTarget;
  105556. private _ratio;
  105557. private _enablePosition;
  105558. private _enableVelocity;
  105559. private _positionIndex;
  105560. private _velocityIndex;
  105561. protected _effect: Effect;
  105562. protected _cachedDefines: string;
  105563. /**
  105564. * Set the render list (meshes to be rendered) used in the G buffer.
  105565. */
  105566. renderList: Mesh[];
  105567. /**
  105568. * Gets wether or not G buffer are supported by the running hardware.
  105569. * This requires draw buffer supports
  105570. */
  105571. readonly isSupported: boolean;
  105572. /**
  105573. * Returns the index of the given texture type in the G-Buffer textures array
  105574. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  105575. * @returns the index of the given texture type in the G-Buffer textures array
  105576. */
  105577. getTextureIndex(textureType: number): number;
  105578. /**
  105579. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  105580. */
  105581. /**
  105582. * Sets whether or not objects positions are enabled for the G buffer.
  105583. */
  105584. enablePosition: boolean;
  105585. /**
  105586. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  105587. */
  105588. /**
  105589. * Sets wether or not objects velocities are enabled for the G buffer.
  105590. */
  105591. enableVelocity: boolean;
  105592. /**
  105593. * Gets the scene associated with the buffer.
  105594. */
  105595. readonly scene: Scene;
  105596. /**
  105597. * Gets the ratio used by the buffer during its creation.
  105598. * How big is the buffer related to the main canvas.
  105599. */
  105600. readonly ratio: number;
  105601. /** @hidden */
  105602. static _SceneComponentInitialization: (scene: Scene) => void;
  105603. /**
  105604. * Creates a new G Buffer for the scene
  105605. * @param scene The scene the buffer belongs to
  105606. * @param ratio How big is the buffer related to the main canvas.
  105607. */
  105608. constructor(scene: Scene, ratio?: number);
  105609. /**
  105610. * Checks wether everything is ready to render a submesh to the G buffer.
  105611. * @param subMesh the submesh to check readiness for
  105612. * @param useInstances is the mesh drawn using instance or not
  105613. * @returns true if ready otherwise false
  105614. */
  105615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105616. /**
  105617. * Gets the current underlying G Buffer.
  105618. * @returns the buffer
  105619. */
  105620. getGBuffer(): MultiRenderTarget;
  105621. /**
  105622. * Gets the number of samples used to render the buffer (anti aliasing).
  105623. */
  105624. /**
  105625. * Sets the number of samples used to render the buffer (anti aliasing).
  105626. */
  105627. samples: number;
  105628. /**
  105629. * Disposes the renderer and frees up associated resources.
  105630. */
  105631. dispose(): void;
  105632. protected _createRenderTargets(): void;
  105633. }
  105634. }
  105635. declare module BABYLON {
  105636. /** @hidden */
  105637. export var motionBlurPixelShader: {
  105638. name: string;
  105639. shader: string;
  105640. };
  105641. }
  105642. declare module BABYLON {
  105643. /**
  105644. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  105645. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  105646. * As an example, all you have to do is to create the post-process:
  105647. * var mb = new BABYLON.MotionBlurPostProcess(
  105648. * 'mb', // The name of the effect.
  105649. * scene, // The scene containing the objects to blur according to their velocity.
  105650. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  105651. * camera // The camera to apply the render pass to.
  105652. * );
  105653. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  105654. */
  105655. export class MotionBlurPostProcess extends PostProcess {
  105656. /**
  105657. * Defines how much the image is blurred by the movement. Default value is equal to 1
  105658. */
  105659. motionStrength: number;
  105660. /**
  105661. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  105662. */
  105663. /**
  105664. * Sets the number of iterations to be used for motion blur quality
  105665. */
  105666. motionBlurSamples: number;
  105667. private _motionBlurSamples;
  105668. private _geometryBufferRenderer;
  105669. /**
  105670. * Creates a new instance MotionBlurPostProcess
  105671. * @param name The name of the effect.
  105672. * @param scene The scene containing the objects to blur according to their velocity.
  105673. * @param options The required width/height ratio to downsize to before computing the render pass.
  105674. * @param camera The camera to apply the render pass to.
  105675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105676. * @param engine The engine which the post process will be applied. (default: current engine)
  105677. * @param reusable If the post process can be reused on the same frame. (default: false)
  105678. * @param textureType Type of textures used when performing the post process. (default: 0)
  105679. * @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)
  105680. */
  105681. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105682. /**
  105683. * Disposes the post process.
  105684. * @param camera The camera to dispose the post process on.
  105685. */
  105686. dispose(camera?: Camera): void;
  105687. }
  105688. }
  105689. declare module BABYLON {
  105690. /** @hidden */
  105691. export var refractionPixelShader: {
  105692. name: string;
  105693. shader: string;
  105694. };
  105695. }
  105696. declare module BABYLON {
  105697. /**
  105698. * Post process which applies a refractin texture
  105699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  105700. */
  105701. export class RefractionPostProcess extends PostProcess {
  105702. /** the base color of the refraction (used to taint the rendering) */
  105703. color: Color3;
  105704. /** simulated refraction depth */
  105705. depth: number;
  105706. /** the coefficient of the base color (0 to remove base color tainting) */
  105707. colorLevel: number;
  105708. private _refTexture;
  105709. private _ownRefractionTexture;
  105710. /**
  105711. * Gets or sets the refraction texture
  105712. * Please note that you are responsible for disposing the texture if you set it manually
  105713. */
  105714. refractionTexture: Texture;
  105715. /**
  105716. * Initializes the RefractionPostProcess
  105717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  105718. * @param name The name of the effect.
  105719. * @param refractionTextureUrl Url of the refraction texture to use
  105720. * @param color the base color of the refraction (used to taint the rendering)
  105721. * @param depth simulated refraction depth
  105722. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  105723. * @param camera The camera to apply the render pass to.
  105724. * @param options The required width/height ratio to downsize to before computing the render pass.
  105725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105726. * @param engine The engine which the post process will be applied. (default: current engine)
  105727. * @param reusable If the post process can be reused on the same frame. (default: false)
  105728. */
  105729. constructor(name: string, refractionTextureUrl: string,
  105730. /** the base color of the refraction (used to taint the rendering) */
  105731. color: Color3,
  105732. /** simulated refraction depth */
  105733. depth: number,
  105734. /** the coefficient of the base color (0 to remove base color tainting) */
  105735. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105736. /**
  105737. * Disposes of the post process
  105738. * @param camera Camera to dispose post process on
  105739. */
  105740. dispose(camera: Camera): void;
  105741. }
  105742. }
  105743. declare module BABYLON {
  105744. /** @hidden */
  105745. export var sharpenPixelShader: {
  105746. name: string;
  105747. shader: string;
  105748. };
  105749. }
  105750. declare module BABYLON {
  105751. /**
  105752. * The SharpenPostProcess applies a sharpen kernel to every pixel
  105753. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  105754. */
  105755. export class SharpenPostProcess extends PostProcess {
  105756. /**
  105757. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  105758. */
  105759. colorAmount: number;
  105760. /**
  105761. * How much sharpness should be applied (default: 0.3)
  105762. */
  105763. edgeAmount: number;
  105764. /**
  105765. * Creates a new instance ConvolutionPostProcess
  105766. * @param name The name of the effect.
  105767. * @param options The required width/height ratio to downsize to before computing the render pass.
  105768. * @param camera The camera to apply the render pass to.
  105769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105770. * @param engine The engine which the post process will be applied. (default: current engine)
  105771. * @param reusable If the post process can be reused on the same frame. (default: false)
  105772. * @param textureType Type of textures used when performing the post process. (default: 0)
  105773. * @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)
  105774. */
  105775. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105776. }
  105777. }
  105778. declare module BABYLON {
  105779. /**
  105780. * PostProcessRenderPipeline
  105781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105782. */
  105783. export class PostProcessRenderPipeline {
  105784. private engine;
  105785. private _renderEffects;
  105786. private _renderEffectsForIsolatedPass;
  105787. /**
  105788. * @hidden
  105789. */
  105790. protected _cameras: Camera[];
  105791. /** @hidden */
  105792. _name: string;
  105793. /**
  105794. * Initializes a PostProcessRenderPipeline
  105795. * @param engine engine to add the pipeline to
  105796. * @param name name of the pipeline
  105797. */
  105798. constructor(engine: Engine, name: string);
  105799. /**
  105800. * "PostProcessRenderPipeline"
  105801. * @returns "PostProcessRenderPipeline"
  105802. */
  105803. getClassName(): string;
  105804. /**
  105805. * If all the render effects in the pipeline are support
  105806. */
  105807. readonly isSupported: boolean;
  105808. /**
  105809. * Adds an effect to the pipeline
  105810. * @param renderEffect the effect to add
  105811. */
  105812. addEffect(renderEffect: PostProcessRenderEffect): void;
  105813. /** @hidden */
  105814. _rebuild(): void;
  105815. /** @hidden */
  105816. _enableEffect(renderEffectName: string, cameras: Camera): void;
  105817. /** @hidden */
  105818. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  105819. /** @hidden */
  105820. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  105821. /** @hidden */
  105822. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  105823. /** @hidden */
  105824. _attachCameras(cameras: Camera, unique: boolean): void;
  105825. /** @hidden */
  105826. _attachCameras(cameras: Camera[], unique: boolean): void;
  105827. /** @hidden */
  105828. _detachCameras(cameras: Camera): void;
  105829. /** @hidden */
  105830. _detachCameras(cameras: Nullable<Camera[]>): void;
  105831. /** @hidden */
  105832. _update(): void;
  105833. /** @hidden */
  105834. _reset(): void;
  105835. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  105836. /**
  105837. * Disposes of the pipeline
  105838. */
  105839. dispose(): void;
  105840. }
  105841. }
  105842. declare module BABYLON {
  105843. /**
  105844. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  105845. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  105846. */
  105847. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  105848. private _scene;
  105849. private _camerasToBeAttached;
  105850. /**
  105851. * ID of the sharpen post process,
  105852. */
  105853. private readonly SharpenPostProcessId;
  105854. /**
  105855. * @ignore
  105856. * ID of the image processing post process;
  105857. */
  105858. readonly ImageProcessingPostProcessId: string;
  105859. /**
  105860. * @ignore
  105861. * ID of the Fast Approximate Anti-Aliasing post process;
  105862. */
  105863. readonly FxaaPostProcessId: string;
  105864. /**
  105865. * ID of the chromatic aberration post process,
  105866. */
  105867. private readonly ChromaticAberrationPostProcessId;
  105868. /**
  105869. * ID of the grain post process
  105870. */
  105871. private readonly GrainPostProcessId;
  105872. /**
  105873. * Sharpen post process which will apply a sharpen convolution to enhance edges
  105874. */
  105875. sharpen: SharpenPostProcess;
  105876. private _sharpenEffect;
  105877. private bloom;
  105878. /**
  105879. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  105880. */
  105881. depthOfField: DepthOfFieldEffect;
  105882. /**
  105883. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  105884. */
  105885. fxaa: FxaaPostProcess;
  105886. /**
  105887. * Image post processing pass used to perform operations such as tone mapping or color grading.
  105888. */
  105889. imageProcessing: ImageProcessingPostProcess;
  105890. /**
  105891. * Chromatic aberration post process which will shift rgb colors in the image
  105892. */
  105893. chromaticAberration: ChromaticAberrationPostProcess;
  105894. private _chromaticAberrationEffect;
  105895. /**
  105896. * Grain post process which add noise to the image
  105897. */
  105898. grain: GrainPostProcess;
  105899. private _grainEffect;
  105900. /**
  105901. * Glow post process which adds a glow to emmisive areas of the image
  105902. */
  105903. private _glowLayer;
  105904. /**
  105905. * Animations which can be used to tweak settings over a period of time
  105906. */
  105907. animations: Animation[];
  105908. private _imageProcessingConfigurationObserver;
  105909. private _sharpenEnabled;
  105910. private _bloomEnabled;
  105911. private _depthOfFieldEnabled;
  105912. private _depthOfFieldBlurLevel;
  105913. private _fxaaEnabled;
  105914. private _imageProcessingEnabled;
  105915. private _defaultPipelineTextureType;
  105916. private _bloomScale;
  105917. private _chromaticAberrationEnabled;
  105918. private _grainEnabled;
  105919. private _buildAllowed;
  105920. /**
  105921. * Enable or disable the sharpen process from the pipeline
  105922. */
  105923. sharpenEnabled: boolean;
  105924. private _resizeObserver;
  105925. private _hardwareScaleLevel;
  105926. private _bloomKernel;
  105927. /**
  105928. * Specifies the size of the bloom blur kernel, relative to the final output size
  105929. */
  105930. bloomKernel: number;
  105931. /**
  105932. * Specifies the weight of the bloom in the final rendering
  105933. */
  105934. private _bloomWeight;
  105935. /**
  105936. * Specifies the luma threshold for the area that will be blurred by the bloom
  105937. */
  105938. private _bloomThreshold;
  105939. private _hdr;
  105940. /**
  105941. * The strength of the bloom.
  105942. */
  105943. bloomWeight: number;
  105944. /**
  105945. * The strength of the bloom.
  105946. */
  105947. bloomThreshold: number;
  105948. /**
  105949. * The scale of the bloom, lower value will provide better performance.
  105950. */
  105951. bloomScale: number;
  105952. /**
  105953. * Enable or disable the bloom from the pipeline
  105954. */
  105955. bloomEnabled: boolean;
  105956. private _rebuildBloom;
  105957. /**
  105958. * If the depth of field is enabled.
  105959. */
  105960. depthOfFieldEnabled: boolean;
  105961. /**
  105962. * Blur level of the depth of field effect. (Higher blur will effect performance)
  105963. */
  105964. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  105965. /**
  105966. * If the anti aliasing is enabled.
  105967. */
  105968. fxaaEnabled: boolean;
  105969. private _samples;
  105970. /**
  105971. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  105972. */
  105973. samples: number;
  105974. /**
  105975. * If image processing is enabled.
  105976. */
  105977. imageProcessingEnabled: boolean;
  105978. /**
  105979. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  105980. */
  105981. glowLayerEnabled: boolean;
  105982. /**
  105983. * Enable or disable the chromaticAberration process from the pipeline
  105984. */
  105985. chromaticAberrationEnabled: boolean;
  105986. /**
  105987. * Enable or disable the grain process from the pipeline
  105988. */
  105989. grainEnabled: boolean;
  105990. /**
  105991. * @constructor
  105992. * @param name - The rendering pipeline name (default: "")
  105993. * @param hdr - If high dynamic range textures should be used (default: true)
  105994. * @param scene - The scene linked to this pipeline (default: the last created scene)
  105995. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  105996. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  105997. */
  105998. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  105999. /**
  106000. * Force the compilation of the entire pipeline.
  106001. */
  106002. prepare(): void;
  106003. private _hasCleared;
  106004. private _prevPostProcess;
  106005. private _prevPrevPostProcess;
  106006. private _setAutoClearAndTextureSharing;
  106007. private _depthOfFieldSceneObserver;
  106008. private _buildPipeline;
  106009. private _disposePostProcesses;
  106010. /**
  106011. * Adds a camera to the pipeline
  106012. * @param camera the camera to be added
  106013. */
  106014. addCamera(camera: Camera): void;
  106015. /**
  106016. * Removes a camera from the pipeline
  106017. * @param camera the camera to remove
  106018. */
  106019. removeCamera(camera: Camera): void;
  106020. /**
  106021. * Dispose of the pipeline and stop all post processes
  106022. */
  106023. dispose(): void;
  106024. /**
  106025. * Serialize the rendering pipeline (Used when exporting)
  106026. * @returns the serialized object
  106027. */
  106028. serialize(): any;
  106029. /**
  106030. * Parse the serialized pipeline
  106031. * @param source Source pipeline.
  106032. * @param scene The scene to load the pipeline to.
  106033. * @param rootUrl The URL of the serialized pipeline.
  106034. * @returns An instantiated pipeline from the serialized object.
  106035. */
  106036. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106037. }
  106038. }
  106039. declare module BABYLON {
  106040. /** @hidden */
  106041. export var lensHighlightsPixelShader: {
  106042. name: string;
  106043. shader: string;
  106044. };
  106045. }
  106046. declare module BABYLON {
  106047. /** @hidden */
  106048. export var depthOfFieldPixelShader: {
  106049. name: string;
  106050. shader: string;
  106051. };
  106052. }
  106053. declare module BABYLON {
  106054. /**
  106055. * BABYLON.JS Chromatic Aberration GLSL Shader
  106056. * Author: Olivier Guyot
  106057. * Separates very slightly R, G and B colors on the edges of the screen
  106058. * Inspired by Francois Tarlier & Martins Upitis
  106059. */
  106060. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  106061. /**
  106062. * @ignore
  106063. * The chromatic aberration PostProcess id in the pipeline
  106064. */
  106065. LensChromaticAberrationEffect: string;
  106066. /**
  106067. * @ignore
  106068. * The highlights enhancing PostProcess id in the pipeline
  106069. */
  106070. HighlightsEnhancingEffect: string;
  106071. /**
  106072. * @ignore
  106073. * The depth-of-field PostProcess id in the pipeline
  106074. */
  106075. LensDepthOfFieldEffect: string;
  106076. private _scene;
  106077. private _depthTexture;
  106078. private _grainTexture;
  106079. private _chromaticAberrationPostProcess;
  106080. private _highlightsPostProcess;
  106081. private _depthOfFieldPostProcess;
  106082. private _edgeBlur;
  106083. private _grainAmount;
  106084. private _chromaticAberration;
  106085. private _distortion;
  106086. private _highlightsGain;
  106087. private _highlightsThreshold;
  106088. private _dofDistance;
  106089. private _dofAperture;
  106090. private _dofDarken;
  106091. private _dofPentagon;
  106092. private _blurNoise;
  106093. /**
  106094. * @constructor
  106095. *
  106096. * Effect parameters are as follow:
  106097. * {
  106098. * chromatic_aberration: number; // from 0 to x (1 for realism)
  106099. * edge_blur: number; // from 0 to x (1 for realism)
  106100. * distortion: number; // from 0 to x (1 for realism)
  106101. * grain_amount: number; // from 0 to 1
  106102. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  106103. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  106104. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  106105. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  106106. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  106107. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  106108. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  106109. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  106110. * }
  106111. * Note: if an effect parameter is unset, effect is disabled
  106112. *
  106113. * @param name The rendering pipeline name
  106114. * @param parameters - An object containing all parameters (see above)
  106115. * @param scene The scene linked to this pipeline
  106116. * @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)
  106117. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106118. */
  106119. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  106120. /**
  106121. * Sets the amount of blur at the edges
  106122. * @param amount blur amount
  106123. */
  106124. setEdgeBlur(amount: number): void;
  106125. /**
  106126. * Sets edge blur to 0
  106127. */
  106128. disableEdgeBlur(): void;
  106129. /**
  106130. * Sets the amout of grain
  106131. * @param amount Amount of grain
  106132. */
  106133. setGrainAmount(amount: number): void;
  106134. /**
  106135. * Set grain amount to 0
  106136. */
  106137. disableGrain(): void;
  106138. /**
  106139. * Sets the chromatic aberration amount
  106140. * @param amount amount of chromatic aberration
  106141. */
  106142. setChromaticAberration(amount: number): void;
  106143. /**
  106144. * Sets chromatic aberration amount to 0
  106145. */
  106146. disableChromaticAberration(): void;
  106147. /**
  106148. * Sets the EdgeDistortion amount
  106149. * @param amount amount of EdgeDistortion
  106150. */
  106151. setEdgeDistortion(amount: number): void;
  106152. /**
  106153. * Sets edge distortion to 0
  106154. */
  106155. disableEdgeDistortion(): void;
  106156. /**
  106157. * Sets the FocusDistance amount
  106158. * @param amount amount of FocusDistance
  106159. */
  106160. setFocusDistance(amount: number): void;
  106161. /**
  106162. * Disables depth of field
  106163. */
  106164. disableDepthOfField(): void;
  106165. /**
  106166. * Sets the Aperture amount
  106167. * @param amount amount of Aperture
  106168. */
  106169. setAperture(amount: number): void;
  106170. /**
  106171. * Sets the DarkenOutOfFocus amount
  106172. * @param amount amount of DarkenOutOfFocus
  106173. */
  106174. setDarkenOutOfFocus(amount: number): void;
  106175. /**
  106176. * Creates a pentagon bokeh effect
  106177. */
  106178. enablePentagonBokeh(): void;
  106179. /**
  106180. * Disables the pentagon bokeh effect
  106181. */
  106182. disablePentagonBokeh(): void;
  106183. /**
  106184. * Enables noise blur
  106185. */
  106186. enableNoiseBlur(): void;
  106187. /**
  106188. * Disables noise blur
  106189. */
  106190. disableNoiseBlur(): void;
  106191. /**
  106192. * Sets the HighlightsGain amount
  106193. * @param amount amount of HighlightsGain
  106194. */
  106195. setHighlightsGain(amount: number): void;
  106196. /**
  106197. * Sets the HighlightsThreshold amount
  106198. * @param amount amount of HighlightsThreshold
  106199. */
  106200. setHighlightsThreshold(amount: number): void;
  106201. /**
  106202. * Disables highlights
  106203. */
  106204. disableHighlights(): void;
  106205. /**
  106206. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  106207. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  106208. */
  106209. dispose(disableDepthRender?: boolean): void;
  106210. private _createChromaticAberrationPostProcess;
  106211. private _createHighlightsPostProcess;
  106212. private _createDepthOfFieldPostProcess;
  106213. private _createGrainTexture;
  106214. }
  106215. }
  106216. declare module BABYLON {
  106217. /** @hidden */
  106218. export var ssao2PixelShader: {
  106219. name: string;
  106220. shader: string;
  106221. };
  106222. }
  106223. declare module BABYLON {
  106224. /** @hidden */
  106225. export var ssaoCombinePixelShader: {
  106226. name: string;
  106227. shader: string;
  106228. };
  106229. }
  106230. declare module BABYLON {
  106231. /**
  106232. * Render pipeline to produce ssao effect
  106233. */
  106234. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  106235. /**
  106236. * @ignore
  106237. * The PassPostProcess id in the pipeline that contains the original scene color
  106238. */
  106239. SSAOOriginalSceneColorEffect: string;
  106240. /**
  106241. * @ignore
  106242. * The SSAO PostProcess id in the pipeline
  106243. */
  106244. SSAORenderEffect: string;
  106245. /**
  106246. * @ignore
  106247. * The horizontal blur PostProcess id in the pipeline
  106248. */
  106249. SSAOBlurHRenderEffect: string;
  106250. /**
  106251. * @ignore
  106252. * The vertical blur PostProcess id in the pipeline
  106253. */
  106254. SSAOBlurVRenderEffect: string;
  106255. /**
  106256. * @ignore
  106257. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  106258. */
  106259. SSAOCombineRenderEffect: string;
  106260. /**
  106261. * The output strength of the SSAO post-process. Default value is 1.0.
  106262. */
  106263. totalStrength: number;
  106264. /**
  106265. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  106266. */
  106267. maxZ: number;
  106268. /**
  106269. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  106270. */
  106271. minZAspect: number;
  106272. private _samples;
  106273. /**
  106274. * Number of samples used for the SSAO calculations. Default value is 8
  106275. */
  106276. samples: number;
  106277. private _textureSamples;
  106278. /**
  106279. * Number of samples to use for antialiasing
  106280. */
  106281. textureSamples: number;
  106282. /**
  106283. * Ratio object used for SSAO ratio and blur ratio
  106284. */
  106285. private _ratio;
  106286. /**
  106287. * Dynamically generated sphere sampler.
  106288. */
  106289. private _sampleSphere;
  106290. /**
  106291. * Blur filter offsets
  106292. */
  106293. private _samplerOffsets;
  106294. private _expensiveBlur;
  106295. /**
  106296. * If bilateral blur should be used
  106297. */
  106298. expensiveBlur: boolean;
  106299. /**
  106300. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  106301. */
  106302. radius: number;
  106303. /**
  106304. * The base color of the SSAO post-process
  106305. * The final result is "base + ssao" between [0, 1]
  106306. */
  106307. base: number;
  106308. /**
  106309. * Support test.
  106310. */
  106311. static readonly IsSupported: boolean;
  106312. private _scene;
  106313. private _depthTexture;
  106314. private _normalTexture;
  106315. private _randomTexture;
  106316. private _originalColorPostProcess;
  106317. private _ssaoPostProcess;
  106318. private _blurHPostProcess;
  106319. private _blurVPostProcess;
  106320. private _ssaoCombinePostProcess;
  106321. private _firstUpdate;
  106322. /**
  106323. * @constructor
  106324. * @param name The rendering pipeline name
  106325. * @param scene The scene linked to this pipeline
  106326. * @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 }
  106327. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106328. */
  106329. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  106330. /**
  106331. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  106332. */
  106333. dispose(disableGeometryBufferRenderer?: boolean): void;
  106334. private _createBlurPostProcess;
  106335. /** @hidden */
  106336. _rebuild(): void;
  106337. private _bits;
  106338. private _radicalInverse_VdC;
  106339. private _hammersley;
  106340. private _hemisphereSample_uniform;
  106341. private _generateHemisphere;
  106342. private _createSSAOPostProcess;
  106343. private _createSSAOCombinePostProcess;
  106344. private _createRandomTexture;
  106345. /**
  106346. * Serialize the rendering pipeline (Used when exporting)
  106347. * @returns the serialized object
  106348. */
  106349. serialize(): any;
  106350. /**
  106351. * Parse the serialized pipeline
  106352. * @param source Source pipeline.
  106353. * @param scene The scene to load the pipeline to.
  106354. * @param rootUrl The URL of the serialized pipeline.
  106355. * @returns An instantiated pipeline from the serialized object.
  106356. */
  106357. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  106358. }
  106359. }
  106360. declare module BABYLON {
  106361. /** @hidden */
  106362. export var ssaoPixelShader: {
  106363. name: string;
  106364. shader: string;
  106365. };
  106366. }
  106367. declare module BABYLON {
  106368. /**
  106369. * Render pipeline to produce ssao effect
  106370. */
  106371. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  106372. /**
  106373. * @ignore
  106374. * The PassPostProcess id in the pipeline that contains the original scene color
  106375. */
  106376. SSAOOriginalSceneColorEffect: string;
  106377. /**
  106378. * @ignore
  106379. * The SSAO PostProcess id in the pipeline
  106380. */
  106381. SSAORenderEffect: string;
  106382. /**
  106383. * @ignore
  106384. * The horizontal blur PostProcess id in the pipeline
  106385. */
  106386. SSAOBlurHRenderEffect: string;
  106387. /**
  106388. * @ignore
  106389. * The vertical blur PostProcess id in the pipeline
  106390. */
  106391. SSAOBlurVRenderEffect: string;
  106392. /**
  106393. * @ignore
  106394. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  106395. */
  106396. SSAOCombineRenderEffect: string;
  106397. /**
  106398. * The output strength of the SSAO post-process. Default value is 1.0.
  106399. */
  106400. totalStrength: number;
  106401. /**
  106402. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  106403. */
  106404. radius: number;
  106405. /**
  106406. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  106407. * Must not be equal to fallOff and superior to fallOff.
  106408. * Default value is 0.975
  106409. */
  106410. area: number;
  106411. /**
  106412. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  106413. * Must not be equal to area and inferior to area.
  106414. * Default value is 0.0
  106415. */
  106416. fallOff: number;
  106417. /**
  106418. * The base color of the SSAO post-process
  106419. * The final result is "base + ssao" between [0, 1]
  106420. */
  106421. base: number;
  106422. private _scene;
  106423. private _depthTexture;
  106424. private _randomTexture;
  106425. private _originalColorPostProcess;
  106426. private _ssaoPostProcess;
  106427. private _blurHPostProcess;
  106428. private _blurVPostProcess;
  106429. private _ssaoCombinePostProcess;
  106430. private _firstUpdate;
  106431. /**
  106432. * @constructor
  106433. * @param name - The rendering pipeline name
  106434. * @param scene - The scene linked to this pipeline
  106435. * @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 }
  106436. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  106437. */
  106438. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  106439. /**
  106440. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  106441. */
  106442. dispose(disableDepthRender?: boolean): void;
  106443. private _createBlurPostProcess;
  106444. /** @hidden */
  106445. _rebuild(): void;
  106446. private _createSSAOPostProcess;
  106447. private _createSSAOCombinePostProcess;
  106448. private _createRandomTexture;
  106449. }
  106450. }
  106451. declare module BABYLON {
  106452. /** @hidden */
  106453. export var standardPixelShader: {
  106454. name: string;
  106455. shader: string;
  106456. };
  106457. }
  106458. declare module BABYLON {
  106459. /**
  106460. * Standard rendering pipeline
  106461. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  106462. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  106463. */
  106464. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106465. /**
  106466. * Public members
  106467. */
  106468. /**
  106469. * Post-process which contains the original scene color before the pipeline applies all the effects
  106470. */
  106471. originalPostProcess: Nullable<PostProcess>;
  106472. /**
  106473. * Post-process used to down scale an image x4
  106474. */
  106475. downSampleX4PostProcess: Nullable<PostProcess>;
  106476. /**
  106477. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  106478. */
  106479. brightPassPostProcess: Nullable<PostProcess>;
  106480. /**
  106481. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  106482. */
  106483. blurHPostProcesses: PostProcess[];
  106484. /**
  106485. * Post-process array storing all the vertical blur post-processes used by the pipeline
  106486. */
  106487. blurVPostProcesses: PostProcess[];
  106488. /**
  106489. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  106490. */
  106491. textureAdderPostProcess: Nullable<PostProcess>;
  106492. /**
  106493. * Post-process used to create volumetric lighting effect
  106494. */
  106495. volumetricLightPostProcess: Nullable<PostProcess>;
  106496. /**
  106497. * Post-process used to smooth the previous volumetric light post-process on the X axis
  106498. */
  106499. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  106500. /**
  106501. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  106502. */
  106503. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  106504. /**
  106505. * Post-process used to merge the volumetric light effect and the real scene color
  106506. */
  106507. volumetricLightMergePostProces: Nullable<PostProcess>;
  106508. /**
  106509. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  106510. */
  106511. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  106512. /**
  106513. * Base post-process used to calculate the average luminance of the final image for HDR
  106514. */
  106515. luminancePostProcess: Nullable<PostProcess>;
  106516. /**
  106517. * Post-processes used to create down sample post-processes in order to get
  106518. * the average luminance of the final image for HDR
  106519. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  106520. */
  106521. luminanceDownSamplePostProcesses: PostProcess[];
  106522. /**
  106523. * Post-process used to create a HDR effect (light adaptation)
  106524. */
  106525. hdrPostProcess: Nullable<PostProcess>;
  106526. /**
  106527. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  106528. */
  106529. textureAdderFinalPostProcess: Nullable<PostProcess>;
  106530. /**
  106531. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  106532. */
  106533. lensFlareFinalPostProcess: Nullable<PostProcess>;
  106534. /**
  106535. * Post-process used to merge the final HDR post-process and the real scene color
  106536. */
  106537. hdrFinalPostProcess: Nullable<PostProcess>;
  106538. /**
  106539. * Post-process used to create a lens flare effect
  106540. */
  106541. lensFlarePostProcess: Nullable<PostProcess>;
  106542. /**
  106543. * Post-process that merges the result of the lens flare post-process and the real scene color
  106544. */
  106545. lensFlareComposePostProcess: Nullable<PostProcess>;
  106546. /**
  106547. * Post-process used to create a motion blur effect
  106548. */
  106549. motionBlurPostProcess: Nullable<PostProcess>;
  106550. /**
  106551. * Post-process used to create a depth of field effect
  106552. */
  106553. depthOfFieldPostProcess: Nullable<PostProcess>;
  106554. /**
  106555. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106556. */
  106557. fxaaPostProcess: Nullable<FxaaPostProcess>;
  106558. /**
  106559. * Represents the brightness threshold in order to configure the illuminated surfaces
  106560. */
  106561. brightThreshold: number;
  106562. /**
  106563. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  106564. */
  106565. blurWidth: number;
  106566. /**
  106567. * Sets if the blur for highlighted surfaces must be only horizontal
  106568. */
  106569. horizontalBlur: boolean;
  106570. /**
  106571. * Sets the overall exposure used by the pipeline
  106572. */
  106573. exposure: number;
  106574. /**
  106575. * Texture used typically to simulate "dirty" on camera lens
  106576. */
  106577. lensTexture: Nullable<Texture>;
  106578. /**
  106579. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  106580. */
  106581. volumetricLightCoefficient: number;
  106582. /**
  106583. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  106584. */
  106585. volumetricLightPower: number;
  106586. /**
  106587. * Used the set the blur intensity to smooth the volumetric lights
  106588. */
  106589. volumetricLightBlurScale: number;
  106590. /**
  106591. * Light (spot or directional) used to generate the volumetric lights rays
  106592. * The source light must have a shadow generate so the pipeline can get its
  106593. * depth map
  106594. */
  106595. sourceLight: Nullable<SpotLight | DirectionalLight>;
  106596. /**
  106597. * For eye adaptation, represents the minimum luminance the eye can see
  106598. */
  106599. hdrMinimumLuminance: number;
  106600. /**
  106601. * For eye adaptation, represents the decrease luminance speed
  106602. */
  106603. hdrDecreaseRate: number;
  106604. /**
  106605. * For eye adaptation, represents the increase luminance speed
  106606. */
  106607. hdrIncreaseRate: number;
  106608. /**
  106609. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  106610. */
  106611. lensColorTexture: Nullable<Texture>;
  106612. /**
  106613. * The overall strengh for the lens flare effect
  106614. */
  106615. lensFlareStrength: number;
  106616. /**
  106617. * Dispersion coefficient for lens flare ghosts
  106618. */
  106619. lensFlareGhostDispersal: number;
  106620. /**
  106621. * Main lens flare halo width
  106622. */
  106623. lensFlareHaloWidth: number;
  106624. /**
  106625. * Based on the lens distortion effect, defines how much the lens flare result
  106626. * is distorted
  106627. */
  106628. lensFlareDistortionStrength: number;
  106629. /**
  106630. * Lens star texture must be used to simulate rays on the flares and is available
  106631. * in the documentation
  106632. */
  106633. lensStarTexture: Nullable<Texture>;
  106634. /**
  106635. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  106636. * flare effect by taking account of the dirt texture
  106637. */
  106638. lensFlareDirtTexture: Nullable<Texture>;
  106639. /**
  106640. * Represents the focal length for the depth of field effect
  106641. */
  106642. depthOfFieldDistance: number;
  106643. /**
  106644. * Represents the blur intensity for the blurred part of the depth of field effect
  106645. */
  106646. depthOfFieldBlurWidth: number;
  106647. /**
  106648. * For motion blur, defines how much the image is blurred by the movement
  106649. */
  106650. motionStrength: number;
  106651. /**
  106652. * List of animations for the pipeline (IAnimatable implementation)
  106653. */
  106654. animations: Animation[];
  106655. /**
  106656. * Private members
  106657. */
  106658. private _scene;
  106659. private _currentDepthOfFieldSource;
  106660. private _basePostProcess;
  106661. private _hdrCurrentLuminance;
  106662. private _floatTextureType;
  106663. private _ratio;
  106664. private _bloomEnabled;
  106665. private _depthOfFieldEnabled;
  106666. private _vlsEnabled;
  106667. private _lensFlareEnabled;
  106668. private _hdrEnabled;
  106669. private _motionBlurEnabled;
  106670. private _fxaaEnabled;
  106671. private _motionBlurSamples;
  106672. private _volumetricLightStepsCount;
  106673. private _samples;
  106674. /**
  106675. * @ignore
  106676. * Specifies if the bloom pipeline is enabled
  106677. */
  106678. BloomEnabled: boolean;
  106679. /**
  106680. * @ignore
  106681. * Specifies if the depth of field pipeline is enabed
  106682. */
  106683. DepthOfFieldEnabled: boolean;
  106684. /**
  106685. * @ignore
  106686. * Specifies if the lens flare pipeline is enabed
  106687. */
  106688. LensFlareEnabled: boolean;
  106689. /**
  106690. * @ignore
  106691. * Specifies if the HDR pipeline is enabled
  106692. */
  106693. HDREnabled: boolean;
  106694. /**
  106695. * @ignore
  106696. * Specifies if the volumetric lights scattering effect is enabled
  106697. */
  106698. VLSEnabled: boolean;
  106699. /**
  106700. * @ignore
  106701. * Specifies if the motion blur effect is enabled
  106702. */
  106703. MotionBlurEnabled: boolean;
  106704. /**
  106705. * Specifies if anti-aliasing is enabled
  106706. */
  106707. fxaaEnabled: boolean;
  106708. /**
  106709. * Specifies the number of steps used to calculate the volumetric lights
  106710. * Typically in interval [50, 200]
  106711. */
  106712. volumetricLightStepsCount: number;
  106713. /**
  106714. * Specifies the number of samples used for the motion blur effect
  106715. * Typically in interval [16, 64]
  106716. */
  106717. motionBlurSamples: number;
  106718. /**
  106719. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106720. */
  106721. samples: number;
  106722. /**
  106723. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  106724. * @constructor
  106725. * @param name The rendering pipeline name
  106726. * @param scene The scene linked to this pipeline
  106727. * @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)
  106728. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  106729. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106730. */
  106731. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  106732. private _buildPipeline;
  106733. private _createDownSampleX4PostProcess;
  106734. private _createBrightPassPostProcess;
  106735. private _createBlurPostProcesses;
  106736. private _createTextureAdderPostProcess;
  106737. private _createVolumetricLightPostProcess;
  106738. private _createLuminancePostProcesses;
  106739. private _createHdrPostProcess;
  106740. private _createLensFlarePostProcess;
  106741. private _createDepthOfFieldPostProcess;
  106742. private _createMotionBlurPostProcess;
  106743. private _getDepthTexture;
  106744. private _disposePostProcesses;
  106745. /**
  106746. * Dispose of the pipeline and stop all post processes
  106747. */
  106748. dispose(): void;
  106749. /**
  106750. * Serialize the rendering pipeline (Used when exporting)
  106751. * @returns the serialized object
  106752. */
  106753. serialize(): any;
  106754. /**
  106755. * Parse the serialized pipeline
  106756. * @param source Source pipeline.
  106757. * @param scene The scene to load the pipeline to.
  106758. * @param rootUrl The URL of the serialized pipeline.
  106759. * @returns An instantiated pipeline from the serialized object.
  106760. */
  106761. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  106762. /**
  106763. * Luminance steps
  106764. */
  106765. static LuminanceSteps: number;
  106766. }
  106767. }
  106768. declare module BABYLON {
  106769. /**
  106770. * PostProcessRenderPipelineManager class
  106771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106772. */
  106773. export class PostProcessRenderPipelineManager {
  106774. private _renderPipelines;
  106775. /**
  106776. * Initializes a PostProcessRenderPipelineManager
  106777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106778. */
  106779. constructor();
  106780. /**
  106781. * Adds a pipeline to the manager
  106782. * @param renderPipeline The pipeline to add
  106783. */
  106784. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  106785. /**
  106786. * Attaches a camera to the pipeline
  106787. * @param renderPipelineName The name of the pipeline to attach to
  106788. * @param cameras the camera to attach
  106789. * @param unique if the camera can be attached multiple times to the pipeline
  106790. */
  106791. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  106792. /**
  106793. * Detaches a camera from the pipeline
  106794. * @param renderPipelineName The name of the pipeline to detach from
  106795. * @param cameras the camera to detach
  106796. */
  106797. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  106798. /**
  106799. * Enables an effect by name on a pipeline
  106800. * @param renderPipelineName the name of the pipeline to enable the effect in
  106801. * @param renderEffectName the name of the effect to enable
  106802. * @param cameras the cameras that the effect should be enabled on
  106803. */
  106804. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  106805. /**
  106806. * Disables an effect by name on a pipeline
  106807. * @param renderPipelineName the name of the pipeline to disable the effect in
  106808. * @param renderEffectName the name of the effect to disable
  106809. * @param cameras the cameras that the effect should be disabled on
  106810. */
  106811. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  106812. /**
  106813. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  106814. */
  106815. update(): void;
  106816. /** @hidden */
  106817. _rebuild(): void;
  106818. /**
  106819. * Disposes of the manager and pipelines
  106820. */
  106821. dispose(): void;
  106822. }
  106823. }
  106824. declare module BABYLON {
  106825. interface Scene {
  106826. /** @hidden (Backing field) */
  106827. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  106828. /**
  106829. * Gets the postprocess render pipeline manager
  106830. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106831. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106832. */
  106833. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  106834. }
  106835. /**
  106836. * Defines the Render Pipeline scene component responsible to rendering pipelines
  106837. */
  106838. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  106839. /**
  106840. * The component name helpfull to identify the component in the list of scene components.
  106841. */
  106842. readonly name: string;
  106843. /**
  106844. * The scene the component belongs to.
  106845. */
  106846. scene: Scene;
  106847. /**
  106848. * Creates a new instance of the component for the given scene
  106849. * @param scene Defines the scene to register the component in
  106850. */
  106851. constructor(scene: Scene);
  106852. /**
  106853. * Registers the component in a given scene
  106854. */
  106855. register(): void;
  106856. /**
  106857. * Rebuilds the elements related to this component in case of
  106858. * context lost for instance.
  106859. */
  106860. rebuild(): void;
  106861. /**
  106862. * Disposes the component and the associated ressources
  106863. */
  106864. dispose(): void;
  106865. private _gatherRenderTargets;
  106866. }
  106867. }
  106868. declare module BABYLON {
  106869. /** @hidden */
  106870. export var tonemapPixelShader: {
  106871. name: string;
  106872. shader: string;
  106873. };
  106874. }
  106875. declare module BABYLON {
  106876. /** Defines operator used for tonemapping */
  106877. export enum TonemappingOperator {
  106878. /** Hable */
  106879. Hable = 0,
  106880. /** Reinhard */
  106881. Reinhard = 1,
  106882. /** HejiDawson */
  106883. HejiDawson = 2,
  106884. /** Photographic */
  106885. Photographic = 3
  106886. }
  106887. /**
  106888. * Defines a post process to apply tone mapping
  106889. */
  106890. export class TonemapPostProcess extends PostProcess {
  106891. private _operator;
  106892. /** Defines the required exposure adjustement */
  106893. exposureAdjustment: number;
  106894. /**
  106895. * Creates a new TonemapPostProcess
  106896. * @param name defines the name of the postprocess
  106897. * @param _operator defines the operator to use
  106898. * @param exposureAdjustment defines the required exposure adjustement
  106899. * @param camera defines the camera to use (can be null)
  106900. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  106901. * @param engine defines the hosting engine (can be ignore if camera is set)
  106902. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106903. */
  106904. constructor(name: string, _operator: TonemappingOperator,
  106905. /** Defines the required exposure adjustement */
  106906. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  106907. }
  106908. }
  106909. declare module BABYLON {
  106910. /** @hidden */
  106911. export var depthVertexShader: {
  106912. name: string;
  106913. shader: string;
  106914. };
  106915. }
  106916. declare module BABYLON {
  106917. /** @hidden */
  106918. export var volumetricLightScatteringPixelShader: {
  106919. name: string;
  106920. shader: string;
  106921. };
  106922. }
  106923. declare module BABYLON {
  106924. /** @hidden */
  106925. export var volumetricLightScatteringPassPixelShader: {
  106926. name: string;
  106927. shader: string;
  106928. };
  106929. }
  106930. declare module BABYLON {
  106931. /**
  106932. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  106933. */
  106934. export class VolumetricLightScatteringPostProcess extends PostProcess {
  106935. private _volumetricLightScatteringPass;
  106936. private _volumetricLightScatteringRTT;
  106937. private _viewPort;
  106938. private _screenCoordinates;
  106939. private _cachedDefines;
  106940. /**
  106941. * If not undefined, the mesh position is computed from the attached node position
  106942. */
  106943. attachedNode: {
  106944. position: Vector3;
  106945. };
  106946. /**
  106947. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  106948. */
  106949. customMeshPosition: Vector3;
  106950. /**
  106951. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  106952. */
  106953. useCustomMeshPosition: boolean;
  106954. /**
  106955. * If the post-process should inverse the light scattering direction
  106956. */
  106957. invert: boolean;
  106958. /**
  106959. * The internal mesh used by the post-process
  106960. */
  106961. mesh: Mesh;
  106962. /**
  106963. * @hidden
  106964. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  106965. */
  106966. useDiffuseColor: boolean;
  106967. /**
  106968. * Array containing the excluded meshes not rendered in the internal pass
  106969. */
  106970. excludedMeshes: AbstractMesh[];
  106971. /**
  106972. * Controls the overall intensity of the post-process
  106973. */
  106974. exposure: number;
  106975. /**
  106976. * Dissipates each sample's contribution in range [0, 1]
  106977. */
  106978. decay: number;
  106979. /**
  106980. * Controls the overall intensity of each sample
  106981. */
  106982. weight: number;
  106983. /**
  106984. * Controls the density of each sample
  106985. */
  106986. density: number;
  106987. /**
  106988. * @constructor
  106989. * @param name The post-process name
  106990. * @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)
  106991. * @param camera The camera that the post-process will be attached to
  106992. * @param mesh The mesh used to create the light scattering
  106993. * @param samples The post-process quality, default 100
  106994. * @param samplingModeThe post-process filtering mode
  106995. * @param engine The babylon engine
  106996. * @param reusable If the post-process is reusable
  106997. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  106998. */
  106999. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107000. /**
  107001. * Returns the string "VolumetricLightScatteringPostProcess"
  107002. * @returns "VolumetricLightScatteringPostProcess"
  107003. */
  107004. getClassName(): string;
  107005. private _isReady;
  107006. /**
  107007. * Sets the new light position for light scattering effect
  107008. * @param position The new custom light position
  107009. */
  107010. setCustomMeshPosition(position: Vector3): void;
  107011. /**
  107012. * Returns the light position for light scattering effect
  107013. * @return Vector3 The custom light position
  107014. */
  107015. getCustomMeshPosition(): Vector3;
  107016. /**
  107017. * Disposes the internal assets and detaches the post-process from the camera
  107018. */
  107019. dispose(camera: Camera): void;
  107020. /**
  107021. * Returns the render target texture used by the post-process
  107022. * @return the render target texture used by the post-process
  107023. */
  107024. getPass(): RenderTargetTexture;
  107025. private _meshExcluded;
  107026. private _createPass;
  107027. private _updateMeshScreenCoordinates;
  107028. /**
  107029. * Creates a default mesh for the Volumeric Light Scattering post-process
  107030. * @param name The mesh name
  107031. * @param scene The scene where to create the mesh
  107032. * @return the default mesh
  107033. */
  107034. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107035. }
  107036. }
  107037. declare module BABYLON {
  107038. interface Scene {
  107039. /** @hidden (Backing field) */
  107040. _boundingBoxRenderer: BoundingBoxRenderer;
  107041. /** @hidden (Backing field) */
  107042. _forceShowBoundingBoxes: boolean;
  107043. /**
  107044. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  107045. */
  107046. forceShowBoundingBoxes: boolean;
  107047. /**
  107048. * Gets the bounding box renderer associated with the scene
  107049. * @returns a BoundingBoxRenderer
  107050. */
  107051. getBoundingBoxRenderer(): BoundingBoxRenderer;
  107052. }
  107053. interface AbstractMesh {
  107054. /** @hidden (Backing field) */
  107055. _showBoundingBox: boolean;
  107056. /**
  107057. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  107058. */
  107059. showBoundingBox: boolean;
  107060. }
  107061. /**
  107062. * Component responsible of rendering the bounding box of the meshes in a scene.
  107063. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  107064. */
  107065. export class BoundingBoxRenderer implements ISceneComponent {
  107066. /**
  107067. * The component name helpfull to identify the component in the list of scene components.
  107068. */
  107069. readonly name: string;
  107070. /**
  107071. * The scene the component belongs to.
  107072. */
  107073. scene: Scene;
  107074. /**
  107075. * Color of the bounding box lines placed in front of an object
  107076. */
  107077. frontColor: Color3;
  107078. /**
  107079. * Color of the bounding box lines placed behind an object
  107080. */
  107081. backColor: Color3;
  107082. /**
  107083. * Defines if the renderer should show the back lines or not
  107084. */
  107085. showBackLines: boolean;
  107086. /**
  107087. * @hidden
  107088. */
  107089. renderList: SmartArray<BoundingBox>;
  107090. private _colorShader;
  107091. private _vertexBuffers;
  107092. private _indexBuffer;
  107093. /**
  107094. * Instantiates a new bounding box renderer in a scene.
  107095. * @param scene the scene the renderer renders in
  107096. */
  107097. constructor(scene: Scene);
  107098. /**
  107099. * Registers the component in a given scene
  107100. */
  107101. register(): void;
  107102. private _evaluateSubMesh;
  107103. private _activeMesh;
  107104. private _prepareRessources;
  107105. private _createIndexBuffer;
  107106. /**
  107107. * Rebuilds the elements related to this component in case of
  107108. * context lost for instance.
  107109. */
  107110. rebuild(): void;
  107111. /**
  107112. * @hidden
  107113. */
  107114. reset(): void;
  107115. /**
  107116. * Render the bounding boxes of a specific rendering group
  107117. * @param renderingGroupId defines the rendering group to render
  107118. */
  107119. render(renderingGroupId: number): void;
  107120. /**
  107121. * In case of occlusion queries, we can render the occlusion bounding box through this method
  107122. * @param mesh Define the mesh to render the occlusion bounding box for
  107123. */
  107124. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  107125. /**
  107126. * Dispose and release the resources attached to this renderer.
  107127. */
  107128. dispose(): void;
  107129. }
  107130. }
  107131. declare module BABYLON {
  107132. /** @hidden */
  107133. export var depthPixelShader: {
  107134. name: string;
  107135. shader: string;
  107136. };
  107137. }
  107138. declare module BABYLON {
  107139. /**
  107140. * This represents a depth renderer in Babylon.
  107141. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  107142. */
  107143. export class DepthRenderer {
  107144. private _scene;
  107145. private _depthMap;
  107146. private _effect;
  107147. private _cachedDefines;
  107148. private _camera;
  107149. /**
  107150. * Specifiess that the depth renderer will only be used within
  107151. * the camera it is created for.
  107152. * This can help forcing its rendering during the camera processing.
  107153. */
  107154. useOnlyInActiveCamera: boolean;
  107155. /** @hidden */
  107156. static _SceneComponentInitialization: (scene: Scene) => void;
  107157. /**
  107158. * Instantiates a depth renderer
  107159. * @param scene The scene the renderer belongs to
  107160. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  107161. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  107162. */
  107163. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  107164. /**
  107165. * Creates the depth rendering effect and checks if the effect is ready.
  107166. * @param subMesh The submesh to be used to render the depth map of
  107167. * @param useInstances If multiple world instances should be used
  107168. * @returns if the depth renderer is ready to render the depth map
  107169. */
  107170. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107171. /**
  107172. * Gets the texture which the depth map will be written to.
  107173. * @returns The depth map texture
  107174. */
  107175. getDepthMap(): RenderTargetTexture;
  107176. /**
  107177. * Disposes of the depth renderer.
  107178. */
  107179. dispose(): void;
  107180. }
  107181. }
  107182. declare module BABYLON {
  107183. interface Scene {
  107184. /** @hidden (Backing field) */
  107185. _depthRenderer: {
  107186. [id: string]: DepthRenderer;
  107187. };
  107188. /**
  107189. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  107190. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  107191. * @returns the created depth renderer
  107192. */
  107193. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  107194. /**
  107195. * Disables a depth renderer for a given camera
  107196. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  107197. */
  107198. disableDepthRenderer(camera?: Nullable<Camera>): void;
  107199. }
  107200. /**
  107201. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  107202. * in several rendering techniques.
  107203. */
  107204. export class DepthRendererSceneComponent implements ISceneComponent {
  107205. /**
  107206. * The component name helpfull to identify the component in the list of scene components.
  107207. */
  107208. readonly name: string;
  107209. /**
  107210. * The scene the component belongs to.
  107211. */
  107212. scene: Scene;
  107213. /**
  107214. * Creates a new instance of the component for the given scene
  107215. * @param scene Defines the scene to register the component in
  107216. */
  107217. constructor(scene: Scene);
  107218. /**
  107219. * Registers the component in a given scene
  107220. */
  107221. register(): void;
  107222. /**
  107223. * Rebuilds the elements related to this component in case of
  107224. * context lost for instance.
  107225. */
  107226. rebuild(): void;
  107227. /**
  107228. * Disposes the component and the associated ressources
  107229. */
  107230. dispose(): void;
  107231. private _gatherRenderTargets;
  107232. private _gatherActiveCameraRenderTargets;
  107233. }
  107234. }
  107235. declare module BABYLON {
  107236. interface Scene {
  107237. /** @hidden (Backing field) */
  107238. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  107239. /**
  107240. * Gets or Sets the current geometry buffer associated to the scene.
  107241. */
  107242. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  107243. /**
  107244. * Enables a GeometryBufferRender and associates it with the scene
  107245. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  107246. * @returns the GeometryBufferRenderer
  107247. */
  107248. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  107249. /**
  107250. * Disables the GeometryBufferRender associated with the scene
  107251. */
  107252. disableGeometryBufferRenderer(): void;
  107253. }
  107254. /**
  107255. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  107256. * in several rendering techniques.
  107257. */
  107258. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  107259. /**
  107260. * The component name helpful to identify the component in the list of scene components.
  107261. */
  107262. readonly name: string;
  107263. /**
  107264. * The scene the component belongs to.
  107265. */
  107266. scene: Scene;
  107267. /**
  107268. * Creates a new instance of the component for the given scene
  107269. * @param scene Defines the scene to register the component in
  107270. */
  107271. constructor(scene: Scene);
  107272. /**
  107273. * Registers the component in a given scene
  107274. */
  107275. register(): void;
  107276. /**
  107277. * Rebuilds the elements related to this component in case of
  107278. * context lost for instance.
  107279. */
  107280. rebuild(): void;
  107281. /**
  107282. * Disposes the component and the associated ressources
  107283. */
  107284. dispose(): void;
  107285. private _gatherRenderTargets;
  107286. }
  107287. }
  107288. declare module BABYLON {
  107289. /** @hidden */
  107290. export var outlinePixelShader: {
  107291. name: string;
  107292. shader: string;
  107293. };
  107294. }
  107295. declare module BABYLON {
  107296. /** @hidden */
  107297. export var outlineVertexShader: {
  107298. name: string;
  107299. shader: string;
  107300. };
  107301. }
  107302. declare module BABYLON {
  107303. interface Scene {
  107304. /** @hidden */
  107305. _outlineRenderer: OutlineRenderer;
  107306. /**
  107307. * Gets the outline renderer associated with the scene
  107308. * @returns a OutlineRenderer
  107309. */
  107310. getOutlineRenderer(): OutlineRenderer;
  107311. }
  107312. interface AbstractMesh {
  107313. /** @hidden (Backing field) */
  107314. _renderOutline: boolean;
  107315. /**
  107316. * Gets or sets a boolean indicating if the outline must be rendered as well
  107317. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  107318. */
  107319. renderOutline: boolean;
  107320. /** @hidden (Backing field) */
  107321. _renderOverlay: boolean;
  107322. /**
  107323. * Gets or sets a boolean indicating if the overlay must be rendered as well
  107324. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  107325. */
  107326. renderOverlay: boolean;
  107327. }
  107328. /**
  107329. * This class is responsible to draw bothe outline/overlay of meshes.
  107330. * It should not be used directly but through the available method on mesh.
  107331. */
  107332. export class OutlineRenderer implements ISceneComponent {
  107333. /**
  107334. * The name of the component. Each component must have a unique name.
  107335. */
  107336. name: string;
  107337. /**
  107338. * The scene the component belongs to.
  107339. */
  107340. scene: Scene;
  107341. /**
  107342. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  107343. */
  107344. zOffset: number;
  107345. private _engine;
  107346. private _effect;
  107347. private _cachedDefines;
  107348. private _savedDepthWrite;
  107349. /**
  107350. * Instantiates a new outline renderer. (There could be only one per scene).
  107351. * @param scene Defines the scene it belongs to
  107352. */
  107353. constructor(scene: Scene);
  107354. /**
  107355. * Register the component to one instance of a scene.
  107356. */
  107357. register(): void;
  107358. /**
  107359. * Rebuilds the elements related to this component in case of
  107360. * context lost for instance.
  107361. */
  107362. rebuild(): void;
  107363. /**
  107364. * Disposes the component and the associated ressources.
  107365. */
  107366. dispose(): void;
  107367. /**
  107368. * Renders the outline in the canvas.
  107369. * @param subMesh Defines the sumesh to render
  107370. * @param batch Defines the batch of meshes in case of instances
  107371. * @param useOverlay Defines if the rendering is for the overlay or the outline
  107372. */
  107373. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  107374. /**
  107375. * Returns whether or not the outline renderer is ready for a given submesh.
  107376. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  107377. * @param subMesh Defines the submesh to check readyness for
  107378. * @param useInstances Defines wheter wee are trying to render instances or not
  107379. * @returns true if ready otherwise false
  107380. */
  107381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107382. private _beforeRenderingMesh;
  107383. private _afterRenderingMesh;
  107384. }
  107385. }
  107386. declare module BABYLON {
  107387. /**
  107388. * Defines the list of states available for a task inside a AssetsManager
  107389. */
  107390. export enum AssetTaskState {
  107391. /**
  107392. * Initialization
  107393. */
  107394. INIT = 0,
  107395. /**
  107396. * Running
  107397. */
  107398. RUNNING = 1,
  107399. /**
  107400. * Done
  107401. */
  107402. DONE = 2,
  107403. /**
  107404. * Error
  107405. */
  107406. ERROR = 3
  107407. }
  107408. /**
  107409. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  107410. */
  107411. export abstract class AbstractAssetTask {
  107412. /**
  107413. * Task name
  107414. */ name: string;
  107415. /**
  107416. * Callback called when the task is successful
  107417. */
  107418. onSuccess: (task: any) => void;
  107419. /**
  107420. * Callback called when the task is not successful
  107421. */
  107422. onError: (task: any, message?: string, exception?: any) => void;
  107423. /**
  107424. * Creates a new AssetsManager
  107425. * @param name defines the name of the task
  107426. */
  107427. constructor(
  107428. /**
  107429. * Task name
  107430. */ name: string);
  107431. private _isCompleted;
  107432. private _taskState;
  107433. private _errorObject;
  107434. /**
  107435. * Get if the task is completed
  107436. */
  107437. readonly isCompleted: boolean;
  107438. /**
  107439. * Gets the current state of the task
  107440. */
  107441. readonly taskState: AssetTaskState;
  107442. /**
  107443. * Gets the current error object (if task is in error)
  107444. */
  107445. readonly errorObject: {
  107446. message?: string;
  107447. exception?: any;
  107448. };
  107449. /**
  107450. * Internal only
  107451. * @hidden
  107452. */
  107453. _setErrorObject(message?: string, exception?: any): void;
  107454. /**
  107455. * Execute the current task
  107456. * @param scene defines the scene where you want your assets to be loaded
  107457. * @param onSuccess is a callback called when the task is successfully executed
  107458. * @param onError is a callback called if an error occurs
  107459. */
  107460. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107461. /**
  107462. * Execute the current task
  107463. * @param scene defines the scene where you want your assets to be loaded
  107464. * @param onSuccess is a callback called when the task is successfully executed
  107465. * @param onError is a callback called if an error occurs
  107466. */
  107467. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107468. /**
  107469. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  107470. * This can be used with failed tasks that have the reason for failure fixed.
  107471. */
  107472. reset(): void;
  107473. private onErrorCallback;
  107474. private onDoneCallback;
  107475. }
  107476. /**
  107477. * Define the interface used by progress events raised during assets loading
  107478. */
  107479. export interface IAssetsProgressEvent {
  107480. /**
  107481. * Defines the number of remaining tasks to process
  107482. */
  107483. remainingCount: number;
  107484. /**
  107485. * Defines the total number of tasks
  107486. */
  107487. totalCount: number;
  107488. /**
  107489. * Defines the task that was just processed
  107490. */
  107491. task: AbstractAssetTask;
  107492. }
  107493. /**
  107494. * Class used to share progress information about assets loading
  107495. */
  107496. export class AssetsProgressEvent implements IAssetsProgressEvent {
  107497. /**
  107498. * Defines the number of remaining tasks to process
  107499. */
  107500. remainingCount: number;
  107501. /**
  107502. * Defines the total number of tasks
  107503. */
  107504. totalCount: number;
  107505. /**
  107506. * Defines the task that was just processed
  107507. */
  107508. task: AbstractAssetTask;
  107509. /**
  107510. * Creates a AssetsProgressEvent
  107511. * @param remainingCount defines the number of remaining tasks to process
  107512. * @param totalCount defines the total number of tasks
  107513. * @param task defines the task that was just processed
  107514. */
  107515. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  107516. }
  107517. /**
  107518. * Define a task used by AssetsManager to load meshes
  107519. */
  107520. export class MeshAssetTask extends AbstractAssetTask {
  107521. /**
  107522. * Defines the name of the task
  107523. */
  107524. name: string;
  107525. /**
  107526. * Defines the list of mesh's names you want to load
  107527. */
  107528. meshesNames: any;
  107529. /**
  107530. * Defines the root url to use as a base to load your meshes and associated resources
  107531. */
  107532. rootUrl: string;
  107533. /**
  107534. * Defines the filename of the scene to load from
  107535. */
  107536. sceneFilename: string;
  107537. /**
  107538. * Gets the list of loaded meshes
  107539. */
  107540. loadedMeshes: Array<AbstractMesh>;
  107541. /**
  107542. * Gets the list of loaded particle systems
  107543. */
  107544. loadedParticleSystems: Array<IParticleSystem>;
  107545. /**
  107546. * Gets the list of loaded skeletons
  107547. */
  107548. loadedSkeletons: Array<Skeleton>;
  107549. /**
  107550. * Gets the list of loaded animation groups
  107551. */
  107552. loadedAnimationGroups: Array<AnimationGroup>;
  107553. /**
  107554. * Callback called when the task is successful
  107555. */
  107556. onSuccess: (task: MeshAssetTask) => void;
  107557. /**
  107558. * Callback called when the task is successful
  107559. */
  107560. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  107561. /**
  107562. * Creates a new MeshAssetTask
  107563. * @param name defines the name of the task
  107564. * @param meshesNames defines the list of mesh's names you want to load
  107565. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  107566. * @param sceneFilename defines the filename of the scene to load from
  107567. */
  107568. constructor(
  107569. /**
  107570. * Defines the name of the task
  107571. */
  107572. name: string,
  107573. /**
  107574. * Defines the list of mesh's names you want to load
  107575. */
  107576. meshesNames: any,
  107577. /**
  107578. * Defines the root url to use as a base to load your meshes and associated resources
  107579. */
  107580. rootUrl: string,
  107581. /**
  107582. * Defines the filename of the scene to load from
  107583. */
  107584. sceneFilename: string);
  107585. /**
  107586. * Execute the current task
  107587. * @param scene defines the scene where you want your assets to be loaded
  107588. * @param onSuccess is a callback called when the task is successfully executed
  107589. * @param onError is a callback called if an error occurs
  107590. */
  107591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107592. }
  107593. /**
  107594. * Define a task used by AssetsManager to load text content
  107595. */
  107596. export class TextFileAssetTask extends AbstractAssetTask {
  107597. /**
  107598. * Defines the name of the task
  107599. */
  107600. name: string;
  107601. /**
  107602. * Defines the location of the file to load
  107603. */
  107604. url: string;
  107605. /**
  107606. * Gets the loaded text string
  107607. */
  107608. text: string;
  107609. /**
  107610. * Callback called when the task is successful
  107611. */
  107612. onSuccess: (task: TextFileAssetTask) => void;
  107613. /**
  107614. * Callback called when the task is successful
  107615. */
  107616. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  107617. /**
  107618. * Creates a new TextFileAssetTask object
  107619. * @param name defines the name of the task
  107620. * @param url defines the location of the file to load
  107621. */
  107622. constructor(
  107623. /**
  107624. * Defines the name of the task
  107625. */
  107626. name: string,
  107627. /**
  107628. * Defines the location of the file to load
  107629. */
  107630. url: string);
  107631. /**
  107632. * Execute the current task
  107633. * @param scene defines the scene where you want your assets to be loaded
  107634. * @param onSuccess is a callback called when the task is successfully executed
  107635. * @param onError is a callback called if an error occurs
  107636. */
  107637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107638. }
  107639. /**
  107640. * Define a task used by AssetsManager to load binary data
  107641. */
  107642. export class BinaryFileAssetTask extends AbstractAssetTask {
  107643. /**
  107644. * Defines the name of the task
  107645. */
  107646. name: string;
  107647. /**
  107648. * Defines the location of the file to load
  107649. */
  107650. url: string;
  107651. /**
  107652. * Gets the lodaded data (as an array buffer)
  107653. */
  107654. data: ArrayBuffer;
  107655. /**
  107656. * Callback called when the task is successful
  107657. */
  107658. onSuccess: (task: BinaryFileAssetTask) => void;
  107659. /**
  107660. * Callback called when the task is successful
  107661. */
  107662. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  107663. /**
  107664. * Creates a new BinaryFileAssetTask object
  107665. * @param name defines the name of the new task
  107666. * @param url defines the location of the file to load
  107667. */
  107668. constructor(
  107669. /**
  107670. * Defines the name of the task
  107671. */
  107672. name: string,
  107673. /**
  107674. * Defines the location of the file to load
  107675. */
  107676. url: string);
  107677. /**
  107678. * Execute the current task
  107679. * @param scene defines the scene where you want your assets to be loaded
  107680. * @param onSuccess is a callback called when the task is successfully executed
  107681. * @param onError is a callback called if an error occurs
  107682. */
  107683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107684. }
  107685. /**
  107686. * Define a task used by AssetsManager to load images
  107687. */
  107688. export class ImageAssetTask extends AbstractAssetTask {
  107689. /**
  107690. * Defines the name of the task
  107691. */
  107692. name: string;
  107693. /**
  107694. * Defines the location of the image to load
  107695. */
  107696. url: string;
  107697. /**
  107698. * Gets the loaded images
  107699. */
  107700. image: HTMLImageElement;
  107701. /**
  107702. * Callback called when the task is successful
  107703. */
  107704. onSuccess: (task: ImageAssetTask) => void;
  107705. /**
  107706. * Callback called when the task is successful
  107707. */
  107708. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  107709. /**
  107710. * Creates a new ImageAssetTask
  107711. * @param name defines the name of the task
  107712. * @param url defines the location of the image to load
  107713. */
  107714. constructor(
  107715. /**
  107716. * Defines the name of the task
  107717. */
  107718. name: string,
  107719. /**
  107720. * Defines the location of the image to load
  107721. */
  107722. url: string);
  107723. /**
  107724. * Execute the current task
  107725. * @param scene defines the scene where you want your assets to be loaded
  107726. * @param onSuccess is a callback called when the task is successfully executed
  107727. * @param onError is a callback called if an error occurs
  107728. */
  107729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107730. }
  107731. /**
  107732. * Defines the interface used by texture loading tasks
  107733. */
  107734. export interface ITextureAssetTask<TEX extends BaseTexture> {
  107735. /**
  107736. * Gets the loaded texture
  107737. */
  107738. texture: TEX;
  107739. }
  107740. /**
  107741. * Define a task used by AssetsManager to load 2D textures
  107742. */
  107743. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  107744. /**
  107745. * Defines the name of the task
  107746. */
  107747. name: string;
  107748. /**
  107749. * Defines the location of the file to load
  107750. */
  107751. url: string;
  107752. /**
  107753. * Defines if mipmap should not be generated (default is false)
  107754. */
  107755. noMipmap?: boolean | undefined;
  107756. /**
  107757. * Defines if texture must be inverted on Y axis (default is false)
  107758. */
  107759. invertY?: boolean | undefined;
  107760. /**
  107761. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  107762. */
  107763. samplingMode: number;
  107764. /**
  107765. * Gets the loaded texture
  107766. */
  107767. texture: Texture;
  107768. /**
  107769. * Callback called when the task is successful
  107770. */
  107771. onSuccess: (task: TextureAssetTask) => void;
  107772. /**
  107773. * Callback called when the task is successful
  107774. */
  107775. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  107776. /**
  107777. * Creates a new TextureAssetTask object
  107778. * @param name defines the name of the task
  107779. * @param url defines the location of the file to load
  107780. * @param noMipmap defines if mipmap should not be generated (default is false)
  107781. * @param invertY defines if texture must be inverted on Y axis (default is false)
  107782. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  107783. */
  107784. constructor(
  107785. /**
  107786. * Defines the name of the task
  107787. */
  107788. name: string,
  107789. /**
  107790. * Defines the location of the file to load
  107791. */
  107792. url: string,
  107793. /**
  107794. * Defines if mipmap should not be generated (default is false)
  107795. */
  107796. noMipmap?: boolean | undefined,
  107797. /**
  107798. * Defines if texture must be inverted on Y axis (default is false)
  107799. */
  107800. invertY?: boolean | undefined,
  107801. /**
  107802. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  107803. */
  107804. samplingMode?: number);
  107805. /**
  107806. * Execute the current task
  107807. * @param scene defines the scene where you want your assets to be loaded
  107808. * @param onSuccess is a callback called when the task is successfully executed
  107809. * @param onError is a callback called if an error occurs
  107810. */
  107811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107812. }
  107813. /**
  107814. * Define a task used by AssetsManager to load cube textures
  107815. */
  107816. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  107817. /**
  107818. * Defines the name of the task
  107819. */
  107820. name: string;
  107821. /**
  107822. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  107823. */
  107824. url: string;
  107825. /**
  107826. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  107827. */
  107828. extensions?: string[] | undefined;
  107829. /**
  107830. * Defines if mipmaps should not be generated (default is false)
  107831. */
  107832. noMipmap?: boolean | undefined;
  107833. /**
  107834. * Defines the explicit list of files (undefined by default)
  107835. */
  107836. files?: string[] | undefined;
  107837. /**
  107838. * Gets the loaded texture
  107839. */
  107840. texture: CubeTexture;
  107841. /**
  107842. * Callback called when the task is successful
  107843. */
  107844. onSuccess: (task: CubeTextureAssetTask) => void;
  107845. /**
  107846. * Callback called when the task is successful
  107847. */
  107848. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  107849. /**
  107850. * Creates a new CubeTextureAssetTask
  107851. * @param name defines the name of the task
  107852. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  107853. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  107854. * @param noMipmap defines if mipmaps should not be generated (default is false)
  107855. * @param files defines the explicit list of files (undefined by default)
  107856. */
  107857. constructor(
  107858. /**
  107859. * Defines the name of the task
  107860. */
  107861. name: string,
  107862. /**
  107863. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  107864. */
  107865. url: string,
  107866. /**
  107867. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  107868. */
  107869. extensions?: string[] | undefined,
  107870. /**
  107871. * Defines if mipmaps should not be generated (default is false)
  107872. */
  107873. noMipmap?: boolean | undefined,
  107874. /**
  107875. * Defines the explicit list of files (undefined by default)
  107876. */
  107877. files?: string[] | undefined);
  107878. /**
  107879. * Execute the current task
  107880. * @param scene defines the scene where you want your assets to be loaded
  107881. * @param onSuccess is a callback called when the task is successfully executed
  107882. * @param onError is a callback called if an error occurs
  107883. */
  107884. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107885. }
  107886. /**
  107887. * Define a task used by AssetsManager to load HDR cube textures
  107888. */
  107889. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  107890. /**
  107891. * Defines the name of the task
  107892. */
  107893. name: string;
  107894. /**
  107895. * Defines the location of the file to load
  107896. */
  107897. url: string;
  107898. /**
  107899. * Defines the desired size (the more it increases the longer the generation will be)
  107900. */
  107901. size: number;
  107902. /**
  107903. * Defines if mipmaps should not be generated (default is false)
  107904. */
  107905. noMipmap: boolean;
  107906. /**
  107907. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  107908. */
  107909. generateHarmonics: boolean;
  107910. /**
  107911. * 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)
  107912. */
  107913. gammaSpace: boolean;
  107914. /**
  107915. * Internal Use Only
  107916. */
  107917. reserved: boolean;
  107918. /**
  107919. * Gets the loaded texture
  107920. */
  107921. texture: HDRCubeTexture;
  107922. /**
  107923. * Callback called when the task is successful
  107924. */
  107925. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  107926. /**
  107927. * Callback called when the task is successful
  107928. */
  107929. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  107930. /**
  107931. * Creates a new HDRCubeTextureAssetTask object
  107932. * @param name defines the name of the task
  107933. * @param url defines the location of the file to load
  107934. * @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.
  107935. * @param noMipmap defines if mipmaps should not be generated (default is false)
  107936. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  107937. * @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)
  107938. * @param reserved Internal use only
  107939. */
  107940. constructor(
  107941. /**
  107942. * Defines the name of the task
  107943. */
  107944. name: string,
  107945. /**
  107946. * Defines the location of the file to load
  107947. */
  107948. url: string,
  107949. /**
  107950. * Defines the desired size (the more it increases the longer the generation will be)
  107951. */
  107952. size: number,
  107953. /**
  107954. * Defines if mipmaps should not be generated (default is false)
  107955. */
  107956. noMipmap?: boolean,
  107957. /**
  107958. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  107959. */
  107960. generateHarmonics?: boolean,
  107961. /**
  107962. * 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)
  107963. */
  107964. gammaSpace?: boolean,
  107965. /**
  107966. * Internal Use Only
  107967. */
  107968. reserved?: boolean);
  107969. /**
  107970. * Execute the current task
  107971. * @param scene defines the scene where you want your assets to be loaded
  107972. * @param onSuccess is a callback called when the task is successfully executed
  107973. * @param onError is a callback called if an error occurs
  107974. */
  107975. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  107976. }
  107977. /**
  107978. * This class can be used to easily import assets into a scene
  107979. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  107980. */
  107981. export class AssetsManager {
  107982. private _scene;
  107983. private _isLoading;
  107984. protected _tasks: AbstractAssetTask[];
  107985. protected _waitingTasksCount: number;
  107986. protected _totalTasksCount: number;
  107987. /**
  107988. * Callback called when all tasks are processed
  107989. */
  107990. onFinish: (tasks: AbstractAssetTask[]) => void;
  107991. /**
  107992. * Callback called when a task is successful
  107993. */
  107994. onTaskSuccess: (task: AbstractAssetTask) => void;
  107995. /**
  107996. * Callback called when a task had an error
  107997. */
  107998. onTaskError: (task: AbstractAssetTask) => void;
  107999. /**
  108000. * Callback called when a task is done (whatever the result is)
  108001. */
  108002. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108003. /**
  108004. * Observable called when all tasks are processed
  108005. */
  108006. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108007. /**
  108008. * Observable called when a task had an error
  108009. */
  108010. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108011. /**
  108012. * Observable called when a task is successful
  108013. */
  108014. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108015. /**
  108016. * Observable called when a task is done (whatever the result is)
  108017. */
  108018. onProgressObservable: Observable<IAssetsProgressEvent>;
  108019. /**
  108020. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108022. */
  108023. useDefaultLoadingScreen: boolean;
  108024. /**
  108025. * Creates a new AssetsManager
  108026. * @param scene defines the scene to work on
  108027. */
  108028. constructor(scene: Scene);
  108029. /**
  108030. * Add a MeshAssetTask to the list of active tasks
  108031. * @param taskName defines the name of the new task
  108032. * @param meshesNames defines the name of meshes to load
  108033. * @param rootUrl defines the root url to use to locate files
  108034. * @param sceneFilename defines the filename of the scene file
  108035. * @returns a new MeshAssetTask object
  108036. */
  108037. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108038. /**
  108039. * Add a TextFileAssetTask to the list of active tasks
  108040. * @param taskName defines the name of the new task
  108041. * @param url defines the url of the file to load
  108042. * @returns a new TextFileAssetTask object
  108043. */
  108044. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  108045. /**
  108046. * Add a BinaryFileAssetTask to the list of active tasks
  108047. * @param taskName defines the name of the new task
  108048. * @param url defines the url of the file to load
  108049. * @returns a new BinaryFileAssetTask object
  108050. */
  108051. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  108052. /**
  108053. * Add a ImageAssetTask to the list of active tasks
  108054. * @param taskName defines the name of the new task
  108055. * @param url defines the url of the file to load
  108056. * @returns a new ImageAssetTask object
  108057. */
  108058. addImageTask(taskName: string, url: string): ImageAssetTask;
  108059. /**
  108060. * Add a TextureAssetTask to the list of active tasks
  108061. * @param taskName defines the name of the new task
  108062. * @param url defines the url of the file to load
  108063. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108064. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  108065. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108066. * @returns a new TextureAssetTask object
  108067. */
  108068. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  108069. /**
  108070. * Add a CubeTextureAssetTask to the list of active tasks
  108071. * @param taskName defines the name of the new task
  108072. * @param url defines the url of the file to load
  108073. * @param extensions defines the extension to use to load the cube map (can be null)
  108074. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108075. * @param files defines the list of files to load (can be null)
  108076. * @returns a new CubeTextureAssetTask object
  108077. */
  108078. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  108079. /**
  108080. *
  108081. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108082. * @param taskName defines the name of the new task
  108083. * @param url defines the url of the file to load
  108084. * @param size defines the size you want for the cubemap (can be null)
  108085. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108086. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108087. * @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)
  108088. * @param reserved Internal use only
  108089. * @returns a new HDRCubeTextureAssetTask object
  108090. */
  108091. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  108092. /**
  108093. * Remove a task from the assets manager.
  108094. * @param task the task to remove
  108095. */
  108096. removeTask(task: AbstractAssetTask): void;
  108097. private _decreaseWaitingTasksCount;
  108098. private _runTask;
  108099. /**
  108100. * Reset the AssetsManager and remove all tasks
  108101. * @return the current instance of the AssetsManager
  108102. */
  108103. reset(): AssetsManager;
  108104. /**
  108105. * Start the loading process
  108106. * @return the current instance of the AssetsManager
  108107. */
  108108. load(): AssetsManager;
  108109. }
  108110. }
  108111. declare module BABYLON {
  108112. /**
  108113. * Wrapper class for promise with external resolve and reject.
  108114. */
  108115. export class Deferred<T> {
  108116. /**
  108117. * The promise associated with this deferred object.
  108118. */
  108119. readonly promise: Promise<T>;
  108120. private _resolve;
  108121. private _reject;
  108122. /**
  108123. * The resolve method of the promise associated with this deferred object.
  108124. */
  108125. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  108126. /**
  108127. * The reject method of the promise associated with this deferred object.
  108128. */
  108129. readonly reject: (reason?: any) => void;
  108130. /**
  108131. * Constructor for this deferred object.
  108132. */
  108133. constructor();
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. /**
  108138. * Class used to help managing file picking and drag'n'drop
  108139. */
  108140. export class FilesInput {
  108141. /**
  108142. * List of files ready to be loaded
  108143. */
  108144. static readonly FilesToLoad: {
  108145. [key: string]: File;
  108146. };
  108147. /**
  108148. * Callback called when a file is processed
  108149. */
  108150. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  108151. private _engine;
  108152. private _currentScene;
  108153. private _sceneLoadedCallback;
  108154. private _progressCallback;
  108155. private _additionalRenderLoopLogicCallback;
  108156. private _textureLoadingCallback;
  108157. private _startingProcessingFilesCallback;
  108158. private _onReloadCallback;
  108159. private _errorCallback;
  108160. private _elementToMonitor;
  108161. private _sceneFileToLoad;
  108162. private _filesToLoad;
  108163. /**
  108164. * Creates a new FilesInput
  108165. * @param engine defines the rendering engine
  108166. * @param scene defines the hosting scene
  108167. * @param sceneLoadedCallback callback called when scene is loaded
  108168. * @param progressCallback callback called to track progress
  108169. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  108170. * @param textureLoadingCallback callback called when a texture is loading
  108171. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  108172. * @param onReloadCallback callback called when a reload is requested
  108173. * @param errorCallback callback call if an error occurs
  108174. */
  108175. 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);
  108176. private _dragEnterHandler;
  108177. private _dragOverHandler;
  108178. private _dropHandler;
  108179. /**
  108180. * Calls this function to listen to drag'n'drop events on a specific DOM element
  108181. * @param elementToMonitor defines the DOM element to track
  108182. */
  108183. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  108184. /**
  108185. * Release all associated resources
  108186. */
  108187. dispose(): void;
  108188. private renderFunction;
  108189. private drag;
  108190. private drop;
  108191. private _traverseFolder;
  108192. private _processFiles;
  108193. /**
  108194. * Load files from a drop event
  108195. * @param event defines the drop event to use as source
  108196. */
  108197. loadFiles(event: any): void;
  108198. private _processReload;
  108199. /**
  108200. * Reload the current scene from the loaded files
  108201. */
  108202. reload(): void;
  108203. }
  108204. }
  108205. declare module BABYLON {
  108206. /**
  108207. * Defines the root class used to create scene optimization to use with SceneOptimizer
  108208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108209. */
  108210. export class SceneOptimization {
  108211. /**
  108212. * Defines the priority of this optimization (0 by default which means first in the list)
  108213. */
  108214. priority: number;
  108215. /**
  108216. * Gets a string describing the action executed by the current optimization
  108217. * @returns description string
  108218. */
  108219. getDescription(): string;
  108220. /**
  108221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108222. * @param scene defines the current scene where to apply this optimization
  108223. * @param optimizer defines the current optimizer
  108224. * @returns true if everything that can be done was applied
  108225. */
  108226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108227. /**
  108228. * Creates the SceneOptimization object
  108229. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  108230. * @param desc defines the description associated with the optimization
  108231. */
  108232. constructor(
  108233. /**
  108234. * Defines the priority of this optimization (0 by default which means first in the list)
  108235. */
  108236. priority?: number);
  108237. }
  108238. /**
  108239. * Defines an optimization used to reduce the size of render target textures
  108240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108241. */
  108242. export class TextureOptimization extends SceneOptimization {
  108243. /**
  108244. * Defines the priority of this optimization (0 by default which means first in the list)
  108245. */
  108246. priority: number;
  108247. /**
  108248. * 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
  108249. */
  108250. maximumSize: number;
  108251. /**
  108252. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  108253. */
  108254. step: number;
  108255. /**
  108256. * Gets a string describing the action executed by the current optimization
  108257. * @returns description string
  108258. */
  108259. getDescription(): string;
  108260. /**
  108261. * Creates the TextureOptimization object
  108262. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  108263. * @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
  108264. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  108265. */
  108266. constructor(
  108267. /**
  108268. * Defines the priority of this optimization (0 by default which means first in the list)
  108269. */
  108270. priority?: number,
  108271. /**
  108272. * 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
  108273. */
  108274. maximumSize?: number,
  108275. /**
  108276. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  108277. */
  108278. step?: number);
  108279. /**
  108280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108281. * @param scene defines the current scene where to apply this optimization
  108282. * @param optimizer defines the current optimizer
  108283. * @returns true if everything that can be done was applied
  108284. */
  108285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108286. }
  108287. /**
  108288. * Defines an optimization used to increase or decrease the rendering resolution
  108289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108290. */
  108291. export class HardwareScalingOptimization extends SceneOptimization {
  108292. /**
  108293. * Defines the priority of this optimization (0 by default which means first in the list)
  108294. */
  108295. priority: number;
  108296. /**
  108297. * Defines the maximum scale to use (2 by default)
  108298. */
  108299. maximumScale: number;
  108300. /**
  108301. * Defines the step to use between two passes (0.5 by default)
  108302. */
  108303. step: number;
  108304. private _currentScale;
  108305. private _directionOffset;
  108306. /**
  108307. * Gets a string describing the action executed by the current optimization
  108308. * @return description string
  108309. */
  108310. getDescription(): string;
  108311. /**
  108312. * Creates the HardwareScalingOptimization object
  108313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  108314. * @param maximumScale defines the maximum scale to use (2 by default)
  108315. * @param step defines the step to use between two passes (0.5 by default)
  108316. */
  108317. constructor(
  108318. /**
  108319. * Defines the priority of this optimization (0 by default which means first in the list)
  108320. */
  108321. priority?: number,
  108322. /**
  108323. * Defines the maximum scale to use (2 by default)
  108324. */
  108325. maximumScale?: number,
  108326. /**
  108327. * Defines the step to use between two passes (0.5 by default)
  108328. */
  108329. step?: number);
  108330. /**
  108331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108332. * @param scene defines the current scene where to apply this optimization
  108333. * @param optimizer defines the current optimizer
  108334. * @returns true if everything that can be done was applied
  108335. */
  108336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108337. }
  108338. /**
  108339. * Defines an optimization used to remove shadows
  108340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108341. */
  108342. export class ShadowsOptimization extends SceneOptimization {
  108343. /**
  108344. * Gets a string describing the action executed by the current optimization
  108345. * @return description string
  108346. */
  108347. getDescription(): string;
  108348. /**
  108349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108350. * @param scene defines the current scene where to apply this optimization
  108351. * @param optimizer defines the current optimizer
  108352. * @returns true if everything that can be done was applied
  108353. */
  108354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108355. }
  108356. /**
  108357. * Defines an optimization used to turn post-processes off
  108358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108359. */
  108360. export class PostProcessesOptimization extends SceneOptimization {
  108361. /**
  108362. * Gets a string describing the action executed by the current optimization
  108363. * @return description string
  108364. */
  108365. getDescription(): string;
  108366. /**
  108367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108368. * @param scene defines the current scene where to apply this optimization
  108369. * @param optimizer defines the current optimizer
  108370. * @returns true if everything that can be done was applied
  108371. */
  108372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108373. }
  108374. /**
  108375. * Defines an optimization used to turn lens flares off
  108376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108377. */
  108378. export class LensFlaresOptimization extends SceneOptimization {
  108379. /**
  108380. * Gets a string describing the action executed by the current optimization
  108381. * @return description string
  108382. */
  108383. getDescription(): string;
  108384. /**
  108385. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108386. * @param scene defines the current scene where to apply this optimization
  108387. * @param optimizer defines the current optimizer
  108388. * @returns true if everything that can be done was applied
  108389. */
  108390. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108391. }
  108392. /**
  108393. * Defines an optimization based on user defined callback.
  108394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108395. */
  108396. export class CustomOptimization extends SceneOptimization {
  108397. /**
  108398. * Callback called to apply the custom optimization.
  108399. */
  108400. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  108401. /**
  108402. * Callback called to get custom description
  108403. */
  108404. onGetDescription: () => string;
  108405. /**
  108406. * Gets a string describing the action executed by the current optimization
  108407. * @returns description string
  108408. */
  108409. getDescription(): string;
  108410. /**
  108411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108412. * @param scene defines the current scene where to apply this optimization
  108413. * @param optimizer defines the current optimizer
  108414. * @returns true if everything that can be done was applied
  108415. */
  108416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108417. }
  108418. /**
  108419. * Defines an optimization used to turn particles off
  108420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108421. */
  108422. export class ParticlesOptimization extends SceneOptimization {
  108423. /**
  108424. * Gets a string describing the action executed by the current optimization
  108425. * @return description string
  108426. */
  108427. getDescription(): string;
  108428. /**
  108429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108430. * @param scene defines the current scene where to apply this optimization
  108431. * @param optimizer defines the current optimizer
  108432. * @returns true if everything that can be done was applied
  108433. */
  108434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108435. }
  108436. /**
  108437. * Defines an optimization used to turn render targets off
  108438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108439. */
  108440. export class RenderTargetsOptimization extends SceneOptimization {
  108441. /**
  108442. * Gets a string describing the action executed by the current optimization
  108443. * @return description string
  108444. */
  108445. getDescription(): string;
  108446. /**
  108447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108448. * @param scene defines the current scene where to apply this optimization
  108449. * @param optimizer defines the current optimizer
  108450. * @returns true if everything that can be done was applied
  108451. */
  108452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  108453. }
  108454. /**
  108455. * Defines an optimization used to merge meshes with compatible materials
  108456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108457. */
  108458. export class MergeMeshesOptimization extends SceneOptimization {
  108459. private static _UpdateSelectionTree;
  108460. /**
  108461. * Gets or sets a boolean which defines if optimization octree has to be updated
  108462. */
  108463. /**
  108464. * Gets or sets a boolean which defines if optimization octree has to be updated
  108465. */
  108466. static UpdateSelectionTree: boolean;
  108467. /**
  108468. * Gets a string describing the action executed by the current optimization
  108469. * @return description string
  108470. */
  108471. getDescription(): string;
  108472. private _canBeMerged;
  108473. /**
  108474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  108475. * @param scene defines the current scene where to apply this optimization
  108476. * @param optimizer defines the current optimizer
  108477. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  108478. * @returns true if everything that can be done was applied
  108479. */
  108480. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  108481. }
  108482. /**
  108483. * Defines a list of options used by SceneOptimizer
  108484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108485. */
  108486. export class SceneOptimizerOptions {
  108487. /**
  108488. * Defines the target frame rate to reach (60 by default)
  108489. */
  108490. targetFrameRate: number;
  108491. /**
  108492. * Defines the interval between two checkes (2000ms by default)
  108493. */
  108494. trackerDuration: number;
  108495. /**
  108496. * Gets the list of optimizations to apply
  108497. */
  108498. optimizations: SceneOptimization[];
  108499. /**
  108500. * Creates a new list of options used by SceneOptimizer
  108501. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  108502. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  108503. */
  108504. constructor(
  108505. /**
  108506. * Defines the target frame rate to reach (60 by default)
  108507. */
  108508. targetFrameRate?: number,
  108509. /**
  108510. * Defines the interval between two checkes (2000ms by default)
  108511. */
  108512. trackerDuration?: number);
  108513. /**
  108514. * Add a new optimization
  108515. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  108516. * @returns the current SceneOptimizerOptions
  108517. */
  108518. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  108519. /**
  108520. * Add a new custom optimization
  108521. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  108522. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  108523. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  108524. * @returns the current SceneOptimizerOptions
  108525. */
  108526. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  108527. /**
  108528. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  108529. * @param targetFrameRate defines the target frame rate (60 by default)
  108530. * @returns a SceneOptimizerOptions object
  108531. */
  108532. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  108533. /**
  108534. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  108535. * @param targetFrameRate defines the target frame rate (60 by default)
  108536. * @returns a SceneOptimizerOptions object
  108537. */
  108538. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  108539. /**
  108540. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  108541. * @param targetFrameRate defines the target frame rate (60 by default)
  108542. * @returns a SceneOptimizerOptions object
  108543. */
  108544. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  108545. }
  108546. /**
  108547. * Class used to run optimizations in order to reach a target frame rate
  108548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108549. */
  108550. export class SceneOptimizer implements IDisposable {
  108551. private _isRunning;
  108552. private _options;
  108553. private _scene;
  108554. private _currentPriorityLevel;
  108555. private _targetFrameRate;
  108556. private _trackerDuration;
  108557. private _currentFrameRate;
  108558. private _sceneDisposeObserver;
  108559. private _improvementMode;
  108560. /**
  108561. * Defines an observable called when the optimizer reaches the target frame rate
  108562. */
  108563. onSuccessObservable: Observable<SceneOptimizer>;
  108564. /**
  108565. * Defines an observable called when the optimizer enables an optimization
  108566. */
  108567. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  108568. /**
  108569. * Defines an observable called when the optimizer is not able to reach the target frame rate
  108570. */
  108571. onFailureObservable: Observable<SceneOptimizer>;
  108572. /**
  108573. * Gets a boolean indicating if the optimizer is in improvement mode
  108574. */
  108575. readonly isInImprovementMode: boolean;
  108576. /**
  108577. * Gets the current priority level (0 at start)
  108578. */
  108579. readonly currentPriorityLevel: number;
  108580. /**
  108581. * Gets the current frame rate checked by the SceneOptimizer
  108582. */
  108583. readonly currentFrameRate: number;
  108584. /**
  108585. * Gets or sets the current target frame rate (60 by default)
  108586. */
  108587. /**
  108588. * Gets or sets the current target frame rate (60 by default)
  108589. */
  108590. targetFrameRate: number;
  108591. /**
  108592. * Gets or sets the current interval between two checks (every 2000ms by default)
  108593. */
  108594. /**
  108595. * Gets or sets the current interval between two checks (every 2000ms by default)
  108596. */
  108597. trackerDuration: number;
  108598. /**
  108599. * Gets the list of active optimizations
  108600. */
  108601. readonly optimizations: SceneOptimization[];
  108602. /**
  108603. * Creates a new SceneOptimizer
  108604. * @param scene defines the scene to work on
  108605. * @param options defines the options to use with the SceneOptimizer
  108606. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  108607. * @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)
  108608. */
  108609. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  108610. /**
  108611. * Stops the current optimizer
  108612. */
  108613. stop(): void;
  108614. /**
  108615. * Reset the optimizer to initial step (current priority level = 0)
  108616. */
  108617. reset(): void;
  108618. /**
  108619. * Start the optimizer. By default it will try to reach a specific framerate
  108620. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  108621. */
  108622. start(): void;
  108623. private _checkCurrentState;
  108624. /**
  108625. * Release all resources
  108626. */
  108627. dispose(): void;
  108628. /**
  108629. * Helper function to create a SceneOptimizer with one single line of code
  108630. * @param scene defines the scene to work on
  108631. * @param options defines the options to use with the SceneOptimizer
  108632. * @param onSuccess defines a callback to call on success
  108633. * @param onFailure defines a callback to call on failure
  108634. * @returns the new SceneOptimizer object
  108635. */
  108636. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  108637. }
  108638. }
  108639. declare module BABYLON {
  108640. /**
  108641. * Class used to serialize a scene into a string
  108642. */
  108643. export class SceneSerializer {
  108644. /**
  108645. * Clear cache used by a previous serialization
  108646. */
  108647. static ClearCache(): void;
  108648. /**
  108649. * Serialize a scene into a JSON compatible object
  108650. * @param scene defines the scene to serialize
  108651. * @returns a JSON compatible object
  108652. */
  108653. static Serialize(scene: Scene): any;
  108654. /**
  108655. * Serialize a mesh into a JSON compatible object
  108656. * @param toSerialize defines the mesh to serialize
  108657. * @param withParents defines if parents must be serialized as well
  108658. * @param withChildren defines if children must be serialized as well
  108659. * @returns a JSON compatible object
  108660. */
  108661. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  108662. }
  108663. }
  108664. declare module BABYLON {
  108665. /**
  108666. * This represents the different options avilable for the video capture.
  108667. */
  108668. export interface VideoRecorderOptions {
  108669. /** Defines the mime type of the video */
  108670. mimeType: string;
  108671. /** Defines the video the video should be recorded at */
  108672. fps: number;
  108673. /** Defines the chunk size for the recording data */
  108674. recordChunckSize: number;
  108675. }
  108676. /**
  108677. * This can helps recording videos from BabylonJS.
  108678. * This is based on the available WebRTC functionalities of the browser.
  108679. *
  108680. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  108681. */
  108682. export class VideoRecorder {
  108683. private static readonly _defaultOptions;
  108684. /**
  108685. * Returns wehther or not the VideoRecorder is available in your browser.
  108686. * @param engine Defines the Babylon Engine to check the support for
  108687. * @returns true if supported otherwise false
  108688. */
  108689. static IsSupported(engine: Engine): boolean;
  108690. private readonly _options;
  108691. private _canvas;
  108692. private _mediaRecorder;
  108693. private _recordedChunks;
  108694. private _fileName;
  108695. private _resolve;
  108696. private _reject;
  108697. /**
  108698. * True wether a recording is already in progress.
  108699. */
  108700. readonly isRecording: boolean;
  108701. /**
  108702. * Create a new VideoCapture object which can help converting what you see in Babylon to
  108703. * a video file.
  108704. * @param engine Defines the BabylonJS Engine you wish to record
  108705. * @param options Defines options that can be used to customized the capture
  108706. */
  108707. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  108708. /**
  108709. * Stops the current recording before the default capture timeout passed in the startRecording
  108710. * functions.
  108711. */
  108712. stopRecording(): void;
  108713. /**
  108714. * Starts recording the canvas for a max duration specified in parameters.
  108715. * @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.
  108716. * @param maxDuration Defines the maximum recording time in seconds.
  108717. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  108718. * @return a promise callback at the end of the recording with the video data in Blob.
  108719. */
  108720. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  108721. /**
  108722. * Releases internal resources used during the recording.
  108723. */
  108724. dispose(): void;
  108725. private _handleDataAvailable;
  108726. private _handleError;
  108727. private _handleStop;
  108728. }
  108729. }
  108730. declare module BABYLON {
  108731. /**
  108732. * Helper class to push actions to a pool of workers.
  108733. */
  108734. export class WorkerPool implements IDisposable {
  108735. private _workerInfos;
  108736. private _pendingActions;
  108737. /**
  108738. * Constructor
  108739. * @param workers Array of workers to use for actions
  108740. */
  108741. constructor(workers: Array<Worker>);
  108742. /**
  108743. * Terminates all workers and clears any pending actions.
  108744. */
  108745. dispose(): void;
  108746. /**
  108747. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108748. * pended until a worker has completed its action.
  108749. * @param action The action to perform. Call onComplete when the action is complete.
  108750. */
  108751. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108752. private _execute;
  108753. }
  108754. }
  108755. declare module BABYLON {
  108756. /**
  108757. * Class containing a set of static utilities functions for screenshots
  108758. */
  108759. export class ScreenshotTools {
  108760. /**
  108761. * Captures a screenshot of the current rendering
  108762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108763. * @param engine defines the rendering engine
  108764. * @param camera defines the source camera
  108765. * @param size This parameter can be set to a single number or to an object with the
  108766. * following (optional) properties: precision, width, height. If a single number is passed,
  108767. * it will be used for both width and height. If an object is passed, the screenshot size
  108768. * will be derived from the parameters. The precision property is a multiplier allowing
  108769. * rendering at a higher or lower resolution
  108770. * @param successCallback defines the callback receives a single parameter which contains the
  108771. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108772. * src parameter of an <img> to display it
  108773. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108774. * Check your browser for supported MIME types
  108775. */
  108776. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  108777. /**
  108778. * Generates an image screenshot from the specified camera.
  108779. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108780. * @param engine The engine to use for rendering
  108781. * @param camera The camera to use for rendering
  108782. * @param size This parameter can be set to a single number or to an object with the
  108783. * following (optional) properties: precision, width, height. If a single number is passed,
  108784. * it will be used for both width and height. If an object is passed, the screenshot size
  108785. * will be derived from the parameters. The precision property is a multiplier allowing
  108786. * rendering at a higher or lower resolution
  108787. * @param successCallback The callback receives a single parameter which contains the
  108788. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108789. * src parameter of an <img> to display it
  108790. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108791. * Check your browser for supported MIME types
  108792. * @param samples Texture samples (default: 1)
  108793. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108794. * @param fileName A name for for the downloaded file.
  108795. */
  108796. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108797. }
  108798. }
  108799. declare module BABYLON {
  108800. /** @hidden */
  108801. export var blurPixelShader: {
  108802. name: string;
  108803. shader: string;
  108804. };
  108805. }
  108806. declare module BABYLON {
  108807. /** @hidden */
  108808. export var bones300Declaration: {
  108809. name: string;
  108810. shader: string;
  108811. };
  108812. }
  108813. declare module BABYLON {
  108814. /** @hidden */
  108815. export var instances300Declaration: {
  108816. name: string;
  108817. shader: string;
  108818. };
  108819. }
  108820. declare module BABYLON {
  108821. /** @hidden */
  108822. export var pointCloudVertexDeclaration: {
  108823. name: string;
  108824. shader: string;
  108825. };
  108826. }
  108827. // Mixins
  108828. interface Window {
  108829. mozIndexedDB: IDBFactory;
  108830. webkitIndexedDB: IDBFactory;
  108831. msIndexedDB: IDBFactory;
  108832. webkitURL: typeof URL;
  108833. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  108834. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  108835. WebGLRenderingContext: WebGLRenderingContext;
  108836. MSGesture: MSGesture;
  108837. CANNON: any;
  108838. AudioContext: AudioContext;
  108839. webkitAudioContext: AudioContext;
  108840. PointerEvent: any;
  108841. Math: Math;
  108842. Uint8Array: Uint8ArrayConstructor;
  108843. Float32Array: Float32ArrayConstructor;
  108844. mozURL: typeof URL;
  108845. msURL: typeof URL;
  108846. VRFrameData: any; // WebVR, from specs 1.1
  108847. DracoDecoderModule: any;
  108848. setImmediate(handler: (...args: any[]) => void): number;
  108849. }
  108850. interface Document {
  108851. mozCancelFullScreen(): void;
  108852. msCancelFullScreen(): void;
  108853. webkitCancelFullScreen(): void;
  108854. requestPointerLock(): void;
  108855. exitPointerLock(): void;
  108856. mozFullScreen: boolean;
  108857. msIsFullScreen: boolean;
  108858. readonly webkitIsFullScreen: boolean;
  108859. readonly pointerLockElement: Element;
  108860. mozPointerLockElement: HTMLElement;
  108861. msPointerLockElement: HTMLElement;
  108862. webkitPointerLockElement: HTMLElement;
  108863. }
  108864. interface HTMLCanvasElement {
  108865. requestPointerLock(): void;
  108866. msRequestPointerLock?(): void;
  108867. mozRequestPointerLock?(): void;
  108868. webkitRequestPointerLock?(): void;
  108869. /** Track wether a record is in progress */
  108870. isRecording: boolean;
  108871. /** Capture Stream method defined by some browsers */
  108872. captureStream(fps?: number): MediaStream;
  108873. }
  108874. interface CanvasRenderingContext2D {
  108875. msImageSmoothingEnabled: boolean;
  108876. }
  108877. interface MouseEvent {
  108878. mozMovementX: number;
  108879. mozMovementY: number;
  108880. webkitMovementX: number;
  108881. webkitMovementY: number;
  108882. msMovementX: number;
  108883. msMovementY: number;
  108884. }
  108885. interface Navigator {
  108886. mozGetVRDevices: (any: any) => any;
  108887. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  108888. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  108889. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  108890. webkitGetGamepads(): Gamepad[];
  108891. msGetGamepads(): Gamepad[];
  108892. webkitGamepads(): Gamepad[];
  108893. }
  108894. interface HTMLVideoElement {
  108895. mozSrcObject: any;
  108896. }
  108897. interface Math {
  108898. fround(x: number): number;
  108899. imul(a: number, b: number): number;
  108900. }
  108901. interface WebGLProgram {
  108902. context?: WebGLRenderingContext;
  108903. vertexShader?: WebGLShader;
  108904. fragmentShader?: WebGLShader;
  108905. isParallelCompiled: boolean;
  108906. onCompiled?: () => void;
  108907. }
  108908. interface WebGLRenderingContext {
  108909. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  108910. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  108911. vertexAttribDivisor(index: number, divisor: number): void;
  108912. createVertexArray(): any;
  108913. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  108914. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  108915. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  108916. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  108917. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  108918. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  108919. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  108920. // Queries
  108921. createQuery(): WebGLQuery;
  108922. deleteQuery(query: WebGLQuery): void;
  108923. beginQuery(target: number, query: WebGLQuery): void;
  108924. endQuery(target: number): void;
  108925. getQueryParameter(query: WebGLQuery, pname: number): any;
  108926. getQuery(target: number, pname: number): any;
  108927. MAX_SAMPLES: number;
  108928. RGBA8: number;
  108929. READ_FRAMEBUFFER: number;
  108930. DRAW_FRAMEBUFFER: number;
  108931. UNIFORM_BUFFER: number;
  108932. HALF_FLOAT_OES: number;
  108933. RGBA16F: number;
  108934. RGBA32F: number;
  108935. R32F: number;
  108936. RG32F: number;
  108937. RGB32F: number;
  108938. R16F: number;
  108939. RG16F: number;
  108940. RGB16F: number;
  108941. RED: number;
  108942. RG: number;
  108943. R8: number;
  108944. RG8: number;
  108945. UNSIGNED_INT_24_8: number;
  108946. DEPTH24_STENCIL8: number;
  108947. /* Multiple Render Targets */
  108948. drawBuffers(buffers: number[]): void;
  108949. readBuffer(src: number): void;
  108950. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  108951. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  108952. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  108953. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  108954. // Occlusion Query
  108955. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  108956. ANY_SAMPLES_PASSED: number;
  108957. QUERY_RESULT_AVAILABLE: number;
  108958. QUERY_RESULT: number;
  108959. }
  108960. interface WebGLBuffer {
  108961. references: number;
  108962. capacity: number;
  108963. is32Bits: boolean;
  108964. }
  108965. interface WebGLProgram {
  108966. transformFeedback?: WebGLTransformFeedback | null;
  108967. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  108968. }
  108969. interface EXT_disjoint_timer_query {
  108970. QUERY_COUNTER_BITS_EXT: number;
  108971. TIME_ELAPSED_EXT: number;
  108972. TIMESTAMP_EXT: number;
  108973. GPU_DISJOINT_EXT: number;
  108974. QUERY_RESULT_EXT: number;
  108975. QUERY_RESULT_AVAILABLE_EXT: number;
  108976. queryCounterEXT(query: WebGLQuery, target: number): void;
  108977. createQueryEXT(): WebGLQuery;
  108978. beginQueryEXT(target: number, query: WebGLQuery): void;
  108979. endQueryEXT(target: number): void;
  108980. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  108981. deleteQueryEXT(query: WebGLQuery): void;
  108982. }
  108983. interface WebGLUniformLocation {
  108984. _currentState: any;
  108985. }
  108986. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  108987. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  108988. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  108989. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  108990. interface WebGLRenderingContext {
  108991. readonly RASTERIZER_DISCARD: number;
  108992. readonly DEPTH_COMPONENT24: number;
  108993. readonly TEXTURE_3D: number;
  108994. readonly TEXTURE_2D_ARRAY: number;
  108995. readonly TEXTURE_COMPARE_FUNC: number;
  108996. readonly TEXTURE_COMPARE_MODE: number;
  108997. readonly COMPARE_REF_TO_TEXTURE: number;
  108998. readonly TEXTURE_WRAP_R: number;
  108999. readonly HALF_FLOAT: number;
  109000. readonly RGB8: number;
  109001. readonly RED_INTEGER: number;
  109002. readonly RG_INTEGER: number;
  109003. readonly RGB_INTEGER: number;
  109004. readonly RGBA_INTEGER: number;
  109005. readonly R8_SNORM: number;
  109006. readonly RG8_SNORM: number;
  109007. readonly RGB8_SNORM: number;
  109008. readonly RGBA8_SNORM: number;
  109009. readonly R8I: number;
  109010. readonly RG8I: number;
  109011. readonly RGB8I: number;
  109012. readonly RGBA8I: number;
  109013. readonly R8UI: number;
  109014. readonly RG8UI: number;
  109015. readonly RGB8UI: number;
  109016. readonly RGBA8UI: number;
  109017. readonly R16I: number;
  109018. readonly RG16I: number;
  109019. readonly RGB16I: number;
  109020. readonly RGBA16I: number;
  109021. readonly R16UI: number;
  109022. readonly RG16UI: number;
  109023. readonly RGB16UI: number;
  109024. readonly RGBA16UI: number;
  109025. readonly R32I: number;
  109026. readonly RG32I: number;
  109027. readonly RGB32I: number;
  109028. readonly RGBA32I: number;
  109029. readonly R32UI: number;
  109030. readonly RG32UI: number;
  109031. readonly RGB32UI: number;
  109032. readonly RGBA32UI: number;
  109033. readonly RGB10_A2UI: number;
  109034. readonly R11F_G11F_B10F: number;
  109035. readonly RGB9_E5: number;
  109036. readonly RGB10_A2: number;
  109037. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  109038. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  109039. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  109040. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109041. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  109042. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  109043. 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;
  109044. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  109045. readonly TRANSFORM_FEEDBACK: number;
  109046. readonly INTERLEAVED_ATTRIBS: number;
  109047. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  109048. createTransformFeedback(): WebGLTransformFeedback;
  109049. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  109050. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  109051. beginTransformFeedback(primitiveMode: number): void;
  109052. endTransformFeedback(): void;
  109053. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  109054. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109055. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109056. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109057. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  109058. }
  109059. interface ImageBitmap {
  109060. readonly width: number;
  109061. readonly height: number;
  109062. close(): void;
  109063. }
  109064. interface WebGLQuery extends WebGLObject {
  109065. }
  109066. declare var WebGLQuery: {
  109067. prototype: WebGLQuery;
  109068. new(): WebGLQuery;
  109069. };
  109070. interface WebGLSampler extends WebGLObject {
  109071. }
  109072. declare var WebGLSampler: {
  109073. prototype: WebGLSampler;
  109074. new(): WebGLSampler;
  109075. };
  109076. interface WebGLSync extends WebGLObject {
  109077. }
  109078. declare var WebGLSync: {
  109079. prototype: WebGLSync;
  109080. new(): WebGLSync;
  109081. };
  109082. interface WebGLTransformFeedback extends WebGLObject {
  109083. }
  109084. declare var WebGLTransformFeedback: {
  109085. prototype: WebGLTransformFeedback;
  109086. new(): WebGLTransformFeedback;
  109087. };
  109088. interface WebGLVertexArrayObject extends WebGLObject {
  109089. }
  109090. declare var WebGLVertexArrayObject: {
  109091. prototype: WebGLVertexArrayObject;
  109092. new(): WebGLVertexArrayObject;
  109093. };
  109094. // Type definitions for WebVR API
  109095. // Project: https://w3c.github.io/webvr/
  109096. // Definitions by: six a <https://github.com/lostfictions>
  109097. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109098. interface VRDisplay extends EventTarget {
  109099. /**
  109100. * Dictionary of capabilities describing the VRDisplay.
  109101. */
  109102. readonly capabilities: VRDisplayCapabilities;
  109103. /**
  109104. * z-depth defining the far plane of the eye view frustum
  109105. * enables mapping of values in the render target depth
  109106. * attachment to scene coordinates. Initially set to 10000.0.
  109107. */
  109108. depthFar: number;
  109109. /**
  109110. * z-depth defining the near plane of the eye view frustum
  109111. * enables mapping of values in the render target depth
  109112. * attachment to scene coordinates. Initially set to 0.01.
  109113. */
  109114. depthNear: number;
  109115. /**
  109116. * An identifier for this distinct VRDisplay. Used as an
  109117. * association point in the Gamepad API.
  109118. */
  109119. readonly displayId: number;
  109120. /**
  109121. * A display name, a user-readable name identifying it.
  109122. */
  109123. readonly displayName: string;
  109124. readonly isConnected: boolean;
  109125. readonly isPresenting: boolean;
  109126. /**
  109127. * If this VRDisplay supports room-scale experiences, the optional
  109128. * stage attribute contains details on the room-scale parameters.
  109129. */
  109130. readonly stageParameters: VRStageParameters | null;
  109131. /**
  109132. * Passing the value returned by `requestAnimationFrame` to
  109133. * `cancelAnimationFrame` will unregister the callback.
  109134. * @param handle Define the hanle of the request to cancel
  109135. */
  109136. cancelAnimationFrame(handle: number): void;
  109137. /**
  109138. * Stops presenting to the VRDisplay.
  109139. * @returns a promise to know when it stopped
  109140. */
  109141. exitPresent(): Promise<void>;
  109142. /**
  109143. * Return the current VREyeParameters for the given eye.
  109144. * @param whichEye Define the eye we want the parameter for
  109145. * @returns the eye parameters
  109146. */
  109147. getEyeParameters(whichEye: string): VREyeParameters;
  109148. /**
  109149. * Populates the passed VRFrameData with the information required to render
  109150. * the current frame.
  109151. * @param frameData Define the data structure to populate
  109152. * @returns true if ok otherwise false
  109153. */
  109154. getFrameData(frameData: VRFrameData): boolean;
  109155. /**
  109156. * Get the layers currently being presented.
  109157. * @returns the list of VR layers
  109158. */
  109159. getLayers(): VRLayer[];
  109160. /**
  109161. * Return a VRPose containing the future predicted pose of the VRDisplay
  109162. * when the current frame will be presented. The value returned will not
  109163. * change until JavaScript has returned control to the browser.
  109164. *
  109165. * The VRPose will contain the position, orientation, velocity,
  109166. * and acceleration of each of these properties.
  109167. * @returns the pose object
  109168. */
  109169. getPose(): VRPose;
  109170. /**
  109171. * Return the current instantaneous pose of the VRDisplay, with no
  109172. * prediction applied.
  109173. * @returns the current instantaneous pose
  109174. */
  109175. getImmediatePose(): VRPose;
  109176. /**
  109177. * The callback passed to `requestAnimationFrame` will be called
  109178. * any time a new frame should be rendered. When the VRDisplay is
  109179. * presenting the callback will be called at the native refresh
  109180. * rate of the HMD. When not presenting this function acts
  109181. * identically to how window.requestAnimationFrame acts. Content should
  109182. * make no assumptions of frame rate or vsync behavior as the HMD runs
  109183. * asynchronously from other displays and at differing refresh rates.
  109184. * @param callback Define the eaction to run next frame
  109185. * @returns the request handle it
  109186. */
  109187. requestAnimationFrame(callback: FrameRequestCallback): number;
  109188. /**
  109189. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  109190. * Repeat calls while already presenting will update the VRLayers being displayed.
  109191. * @param layers Define the list of layer to present
  109192. * @returns a promise to know when the request has been fulfilled
  109193. */
  109194. requestPresent(layers: VRLayer[]): Promise<void>;
  109195. /**
  109196. * Reset the pose for this display, treating its current position and
  109197. * orientation as the "origin/zero" values. VRPose.position,
  109198. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  109199. * updated when calling resetPose(). This should be called in only
  109200. * sitting-space experiences.
  109201. */
  109202. resetPose(): void;
  109203. /**
  109204. * The VRLayer provided to the VRDisplay will be captured and presented
  109205. * in the HMD. Calling this function has the same effect on the source
  109206. * canvas as any other operation that uses its source image, and canvases
  109207. * created without preserveDrawingBuffer set to true will be cleared.
  109208. * @param pose Define the pose to submit
  109209. */
  109210. submitFrame(pose?: VRPose): void;
  109211. }
  109212. declare var VRDisplay: {
  109213. prototype: VRDisplay;
  109214. new(): VRDisplay;
  109215. };
  109216. interface VRLayer {
  109217. leftBounds?: number[] | Float32Array | null;
  109218. rightBounds?: number[] | Float32Array | null;
  109219. source?: HTMLCanvasElement | null;
  109220. }
  109221. interface VRDisplayCapabilities {
  109222. readonly canPresent: boolean;
  109223. readonly hasExternalDisplay: boolean;
  109224. readonly hasOrientation: boolean;
  109225. readonly hasPosition: boolean;
  109226. readonly maxLayers: number;
  109227. }
  109228. interface VREyeParameters {
  109229. /** @deprecated */
  109230. readonly fieldOfView: VRFieldOfView;
  109231. readonly offset: Float32Array;
  109232. readonly renderHeight: number;
  109233. readonly renderWidth: number;
  109234. }
  109235. interface VRFieldOfView {
  109236. readonly downDegrees: number;
  109237. readonly leftDegrees: number;
  109238. readonly rightDegrees: number;
  109239. readonly upDegrees: number;
  109240. }
  109241. interface VRFrameData {
  109242. readonly leftProjectionMatrix: Float32Array;
  109243. readonly leftViewMatrix: Float32Array;
  109244. readonly pose: VRPose;
  109245. readonly rightProjectionMatrix: Float32Array;
  109246. readonly rightViewMatrix: Float32Array;
  109247. readonly timestamp: number;
  109248. }
  109249. interface VRPose {
  109250. readonly angularAcceleration: Float32Array | null;
  109251. readonly angularVelocity: Float32Array | null;
  109252. readonly linearAcceleration: Float32Array | null;
  109253. readonly linearVelocity: Float32Array | null;
  109254. readonly orientation: Float32Array | null;
  109255. readonly position: Float32Array | null;
  109256. readonly timestamp: number;
  109257. }
  109258. interface VRStageParameters {
  109259. sittingToStandingTransform?: Float32Array;
  109260. sizeX?: number;
  109261. sizeY?: number;
  109262. }
  109263. interface Navigator {
  109264. getVRDisplays(): Promise<VRDisplay[]>;
  109265. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  109266. }
  109267. interface Window {
  109268. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  109269. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  109270. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  109271. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  109272. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  109273. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  109274. }
  109275. interface Gamepad {
  109276. readonly displayId: number;
  109277. }
  109278. interface XRDevice {
  109279. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  109280. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  109281. }
  109282. interface XRSession {
  109283. getInputSources(): Array<any>;
  109284. baseLayer: XRWebGLLayer;
  109285. requestFrameOfReference(type: string): Promise<void>;
  109286. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  109287. end(): Promise<void>;
  109288. requestAnimationFrame: Function;
  109289. addEventListener: Function;
  109290. }
  109291. interface XRSessionCreationOptions {
  109292. outputContext?: WebGLRenderingContext | null;
  109293. immersive?: boolean;
  109294. environmentIntegration?: boolean;
  109295. }
  109296. interface XRLayer {
  109297. getViewport: Function;
  109298. framebufferWidth: number;
  109299. framebufferHeight: number;
  109300. }
  109301. interface XRView {
  109302. projectionMatrix: Float32Array;
  109303. }
  109304. interface XRFrame {
  109305. getDevicePose: Function;
  109306. getInputPose: Function;
  109307. views: Array<XRView>;
  109308. baseLayer: XRLayer;
  109309. }
  109310. interface XRFrameOfReference {
  109311. }
  109312. interface XRWebGLLayer extends XRLayer {
  109313. framebuffer: WebGLFramebuffer;
  109314. }
  109315. declare var XRWebGLLayer: {
  109316. prototype: XRWebGLLayer;
  109317. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  109318. };